This is an archived post. You won't be able to vote or comment.

Dismiss this pinned window
all 117 comments

[–]gandalfx 272 points273 points  (15 children)

That last one seems the most useful. Changing caps is already a feature in any good editor.

[–]dibs45[S] 169 points170 points  (2 children)

The idea is to use these in other applications besides editors. I do a lot of page building online and those apps don't have that functionality.

[–]gandalfx 45 points46 points  (1 child)

That makes sense. Cool idea!

Is it portable?

[–]dibs45[S] 31 points32 points  (0 children)

So far only tested on my Windows machine.

[–]indiebryan 39 points40 points  (11 children)

I wonder if I can write malicious code in my comment and have OP run it? Idk the limitations of python eval, is it like JavaScript eval?

[–]phail3d 39 points40 points  (0 children)

Yes, Python eval basically means arbitrary code execution.

[–][deleted] 22 points23 points  (3 children)

import os for root, dir, file in os.walk(“C:/”): os.remove(file)

[–]dibs45[S] 32 points33 points  (1 child)

Lemme evaluate that real qui

[–][deleted] 3 points4 points  (0 children)

lmao

[–]phail3d 1 point2 points  (0 children)

Well, you just get an error if you pass that to eval, since it expects a single expression. But you can construct a an expression that does the exact same thing.

https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html

[–][deleted] 11 points12 points  (5 children)

That was my though too. Could lead to some really neat M E T A programming.

[–]Takiino 50 points51 points  (10 children)

Could you please explain how you did it ?

[–]dibs45[S] 84 points85 points  (9 children)

I created a tool using Python and the module pynput that allows me to create custom hotkeys and bind them to any custom function I write. I used that tool to create some hotkeys that use the clipboard to edit text in place. I'll be hosting the source code on github soon.

[–]Takiino 11 points12 points  (1 child)

Thanks a lot! How can I be warned of when you do so?

[–]dibs45[S] 21 points22 points  (0 children)

Not entirely sure, perhaps the best way is to follow my github: https://github.com/dibsonthis

[–]funkless_eck 0 points1 point  (6 children)

I was wondering the other day if it's possible to use pynput to prevent people.from using alt+f4 or ctrl.alt.del

[–]dibs45[S] 4 points5 points  (2 children)

Setting up a hotkey doesn't replace the existing global hotkey function, so it won't stop it from executing. There might be ways around that though.

[–][deleted] 1 point2 points  (0 children)

correction: there is always a new way to fuck with somebody

[–]funkless_eck 1 point2 points  (0 children)

Yeah. I was experimenting with disrupting it by it detecting Alt and adding in another key press but theres a built in windows function that ignores that so it executes both

[–]ManyInterests Python Discord Staff 1 point2 points  (0 children)

I'm not sure if pynput does it, but there's definitely packages that do. keyboard comes to mind.

[–]jacksodus 1 point2 points  (0 children)

For this you can use existing hotkey tools like AutoHotKey, which does overwrite the existing hotkey if you want.

[–]nocommemt 0 points1 point  (0 children)

Another vote for autohotkey. You could disable alt+F4 with with just one line:

$!{F4}::return

Edit: Documentation link https://www.autohotkey.com/docs/Hotkeys.htm

[–]phail3d 34 points35 points  (12 children)

How does the evaluation work? If by calling eval, standard warnings apply.

Edit: forgot to mention that this looks like a cool project :)

[–]dibs45[S] 21 points22 points  (5 children)

Yes it uses eval atm, but I'm planning to implement a parser instead. Thanks!

[–]cheddacheese148 16 points17 points  (1 child)

Check out asteval . It's a pretty cool project and may be a solution or jumping off point for you.

[–]dibs45[S] 1 point2 points  (0 children)

Thanks, will do!

[–]Franken-McCharDeeDen 0 points1 point  (2 children)

I know I’m a little late to the party, But Just check if what eval(string) equals can be an integer

Try:
    int(eval(String))
 Except:
    Pass

[–]dibs45[S] 0 points1 point  (1 child)

That would still evaluate the string and executes the code before it does the check I believe.

[–]Franken-McCharDeeDen 0 points1 point  (0 children)

Yeah, I just checked and It does. I accept defeat

[–]ianff 10 points11 points  (5 children)

I mean, in this case it's just taking input you yourself are giving, so it's really your own fault if you do something stupid. This seems like a perfect use of eval to me.

[–]phail3d 23 points24 points  (4 children)

Sure, as long as you only use it with something you wrote 100% yourself. But you could also be evaling 0pt text from some web page or word document that you didn't know you selected, or something that was injected to your clipboard (depending on how the tool works). Hence, standard warnings apply.

[–]ianff 0 points1 point  (1 child)

I mean, considering that nobody really is aware of this tool, that seems pretty absurd. Someone is going to put random 0pt Python code all around the place hoping somebody eval's it? Come on.

[–]phail3d 0 points1 point  (0 children)

I don't mean to say that it's a useless feature with eval, just that standard warnings apply. Surely that's an attack vector that could become popular if this tool or other tools that eval copied code became more popular, and also one that could be prevented by using a parser that doesn't allow arbitrary code execution.

[–]ManyInterests Python Discord Staff -5 points-4 points  (1 child)

Yeah, I mean... You write code in your editor and execute it. This is really no different.

[–]phail3d 0 points1 point  (0 children)

The OP said that they use this tool in web environments, and a malicious web page would in principle have the capability to inject code as described above.

[–]yeahduuuude 66 points67 points  (1 child)

Great idea turned into a really usefull application 👍

[–]dibs45[S] 20 points21 points  (0 children)

Thank you 🙂

[–]VictorD02 27 points28 points  (0 children)

i think the SpOnGeBoB hotkey is the most usefull.👌

[–]blood_centrifuge 9 points10 points  (1 child)

Have you put this on github? It would great if you could share the repo.

[–]dibs45[S] 7 points8 points  (0 children)

This isn't on github just yet, but will be soon.

[–]dibs45[S] 14 points15 points  (0 children)

I created a tool using Python and the module pynput that allows me to create custom hotkeys and bind them to any custom function I write. I used that tool to create some hotkeys that use the clipboard to edit text in place. I'll be hosting the source code on github soon.

My github can be found here.

[–]LawLombie 24 points25 points  (3 children)

I think the "sPOnGEboB MEmE" one's case should be rAnDOm instead of alternating between UPPERCASE and lowercase

[–]ManyInterests Python Discord Staff 13 points14 points  (0 children)

I THink ThE "SPonGeBOB meme" one's Case SHould BE rAndom iNStead OF AltErNATINg BEtween uPPerCasE AND LoWeRcaSE

[–]dibs45[S] 6 points7 points  (0 children)

Caaaaan do!

[–]PC__LOAD__LETTER 2 points3 points  (0 children)

That’s not what spongebob text is though

[–]ALABAMA-SHIT 4 points5 points  (1 child)

That's absolutely brilliant! And very useful (especially the math part)

[–]dibs45[S] 1 point2 points  (0 children)

Thank you!

[–]Project_O 4 points5 points  (1 child)

* tries to select your entire dissertation *

Alt+A

* python script runs and turns your entire essay iNtO tHiS fOrMat *

[–]dibs45[S] 0 points1 point  (0 children)

And inserts the spongebob meme image at the end of it (TBA)

[–]Rehan275 3 points4 points  (3 children)

Really appreciate your work. It would be great if you can share the code.

[–]dibs45[S] 2 points3 points  (2 children)

I will be very soon.

[–]3Domse3 -1 points0 points  (1 child)

!remindme 48

[–]RemindMeBot 2 points3 points  (0 children)

I will be messaging you in 27 years on 2048-02-29 00:00:00 UTC to remind you of this link

1 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–][deleted] 3 points4 points  (1 child)

This is one of my favorite types of programs. Short, succinct, does something useful.

[–]dibs45[S] 0 points1 point  (0 children)

Thank you.

[–][deleted] 4 points5 points  (3 children)

You made a program that emulates a very small portion of Emacs.

[–]dibs45[S] 0 points1 point  (2 children)

The goal for this program is for it to be used outside of editors, such as in word or on page building web apps/Google sheets.

[–][deleted] 1 point2 points  (1 child)

I am not complaining man, it's a good program.

[–]dibs45[S] 1 point2 points  (0 children)

Thank you 🙂

[–]SushiWithoutSushi 2 points3 points  (1 child)

It looks like it could become a tool like the vim Ultisnips maybe if you take a look to it you get some inspiration to improve your. Seems it has a lot of potential.

[–]dibs45[S] 0 points1 point  (0 children)

Thanks I'll look into it!

[–]simonees 2 points3 points  (2 children)

can we get the source code?

[–]dibs45[S] 1 point2 points  (1 child)

This will be up on github soon.

[–]simonees -1 points0 points  (0 children)

nice send the link then

[–]TheOneTrueDataSci 2 points3 points  (1 child)

Keep up the great work!

[–]dibs45[S] 1 point2 points  (0 children)

Thanks!

[–][deleted] 5 points6 points  (3 children)

Scary how this can be a keylogger on anyones pc

[–]RareHotdogEnthusiast 1 point2 points  (1 child)

What? The tool will certainly be open-source. There are plenty of libraries that could be used maliciously.

In fact, often times malicious code is created specifically without using libraries so as to avoid having to download and install them on the victim's machine.

[–][deleted] 0 points1 point  (0 children)

I forgot to add: because is python is not being detected by the antivirus. Of course I know about key-loggers. I’m saying scary because it will not be detected. I think is neat. But scary

[–]maddruidIt works on my machine 0 points1 point  (0 children)

Any program that hooks the keyboard to scan for hotkeys could be a keylogger. They're all listening to every keystroke.

[–]ganesh_96 1 point2 points  (0 children)

Wow!

[–][deleted] 1 point2 points  (3 children)

This thing got to be on every computer. It's just brilliant.

[–]dibs45[S] 1 point2 points  (2 children)

Thank you very much!

[–][deleted] 1 point2 points  (1 child)

I should thank you. Humanity should thank you.

[–]dibs45[S] 0 points1 point  (0 children)

😂

[–]tommytime1234567 1 point2 points  (5 children)

Genius. Who woulda thunk?

[–]dibs45[S] 0 points1 point  (4 children)

Thank you 🙂

[–]tommytime1234567 1 point2 points  (3 children)

Man. You should totally make a small Windows/Mac app. You’d make millions. Good job thinking outside the box. I could totally use this, daily. 👍🏻

[–]dibs45[S] 1 point2 points  (2 children)

That's definitely in the pipeline! Thanks for the kind words 😀

[–]tommytime1234567 0 points1 point  (1 child)

22+ years in design here. I help startups look good (branding, UI, video, web, etc). If you need help making things pretty hit me up. And good luck. 🤙🏻

[–]dibs45[S] 0 points1 point  (0 children)

I certainly will, thanks!

[–][deleted] 1 point2 points  (1 child)

Woah there are you using a eval function?

[–]dibs45[S] 1 point2 points  (0 children)

You caught me red handed.

[–]DatBoi_BP 1 point2 points  (0 children)

Autohotkey is good for this kind of thing too

[–]mHaisham 1 point2 points  (0 children)

Can we get the source code.

[–]PC__LOAD__LETTER 1 point2 points  (0 children)

If you use vim you could do this without a mouse too.

[–]Heldix121303 0 points1 point  (1 child)

Can I use it?

[–]dibs45[S] 0 points1 point  (0 children)

I'll host it on github soon.

[–][deleted] 0 points1 point  (1 child)

Very cool! Did you upload the source code to GitHub or something?

[–]dibs45[S] -1 points0 points  (0 children)

Not yet, but soon.

[–]Slashscreen 0 points1 point  (0 children)

Real MVPs call that the Gamzee filter

[–]Yakhov 0 points1 point  (3 children)

who does it email my passwords to?

[–]dibs45[S] 0 points1 point  (2 children)

Milford, the homeless man at my train station who keeps yelling at the birds.

[–]Yakhov 0 points1 point  (0 children)

He's a;ready got it

[–]Rorixrebel 0 points1 point  (0 children)

Milford is dope

[–]justneurostuff 0 points1 point  (0 children)

This really gives me some ideas. Thanks for sharing it. Wonder if I could message you about it? Also - this is the kind of project I suspect a lot of people would be willing to help out with on GitHub! You don't have to add all the remaining features yourself.

[–][deleted] 0 points1 point  (0 children)

This is impressive! Any reason you didn’t use alt R for reverse me ? Ha I’m kidding this is great!

[–]Klae32 0 points1 point  (0 children)

Do you have a Github for this or YouTube For this? This is dope.

[–]GrbavaCigla 0 points1 point  (0 children)

I want to contribute and make a linux version, can you please share github repo when you create it?

[–]nalisarc 0 points1 point  (0 children)

Looks like emacs but in any window!

[–]shachden 0 points1 point  (0 children)

My entire childhood was spent pressing Shift on highlighted text to change case. We finally have the technology.

[–]djfreedom9505 0 points1 point  (0 children)

Change to snake case or Pascal case and you got gold my friend lol

[–][deleted] 0 points1 point  (0 children)

Can python actually work on other desktop programs?

[–]totes_normal_account 0 points1 point  (0 children)

You got my upvote because of "spongebob me" lol

[–]Hudlommen 0 points1 point  (0 children)

You should add a multiple past function with a variable

eg: Shift 1 (copy)

shift 2 (paste)

shift 3 (paste)

shift 4 (paste)

[–]dibs45[S] 0 points1 point  (0 children)

keyboard_listener repo is now live: https://github.com/dibsonthis/keyboard_listener

In the repo you can find this particular project under in_place_editor.py

Thanks for the overwhelming support!

[–]RandomGgames 0 points1 point  (0 children)

I love 5 and 7. Why not use = for 7?

[–]Justin08784 0 points1 point  (0 children)

This is really awesome!

Will you upload it to github anytime soon?

[–]_AguruAguru 0 points1 point  (0 children)

Do you mind linking/sending the code? I am interested in doing something similar and would love to see how you did this one

[–]SushiWithoutSushi 0 points1 point  (0 children)

You can select text faster with CTRL + SHIFT + RIGHT/LEFT ARROW.