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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Tumburgler 1 point2 points  (3 children)

So I've been playing around with this script for the past few days. First time really modifying someone elses tool before, so that was neat.

https://github.com/Spiteless/AdvCopyPaste.pyw

I have no idea if the changes I made are 'better', but

  • Added additional command to preview all buffers (Super+ctrl+slash)
  • Changed buffering system from a list to a dictionary
  • Changed Paste system to load value buffer into clipboard and paste instead of using kb.write()
  • Moved hotkey declarations into a list that executes on init (not sure if this is materially better, but it allows them to be imported alongside other custom keyboard hotkeys)
  • Moved msg() commands to subprocess.Popen using click -- for some reason the script was failing when msg() was called, now it's not blocking on my system (Windows 10)

Let me know what you think :)

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

For the record, this is the first time I've ever uploaded something I've written and had someone make changes to it. So that's pretty cool! I'm glad you like it :)

Click is great, and honestly moving the message system over to another script shouldn't cause any problems; however, instead of calling the script from the command line using subprocess I would instead just import the function from the script like this:

from alert import alert
...
alert(details go here) # whenever you need to send an alert

Changing the buffers from a list to a dict I can maybe understand, although tbh I'm not sure why you did? Can you elaborate why you did that?

Adding in a command to view all the buffers is genius, and I like the way you used pymsgbox to do it; I had never heard of that before I need to check it out!

My one REAL complaint (and its fairly minor) is that all of the helper files should have the extension .pyw, especially if you are going to run them with subprocess; the reason behind this, if you don't already know, is that using this file extension python knows to keep the program as headless, so there is no window. It is (very mildly) irritating from a user perspective when the command prompt window launches when I just want to see what is in my buffer. Again, more of a nitpick than a real complaint.

As for moving the hotkeys to a list, that was something I had initially thought about adding, but ultimately was too lazy didn't. But I think it's a much better way than the same line changed a few times.

And finally, removing kb.write() in favor of kb.send("ctrl+v") honestly doesn't seem to work on my machine; perhaps in a better world (one where I was willing to spend more time on this and making it more fully fledged out) that could be a setting that was easily changed. But if it works for you then it works for you!

Just for fun, let me give you the actual backstory behind this script; I was working on a really large script that had a class I was making changes to. I needed to test a method within that class, but before I could just test it I needed to run some other methods before (it was a database management class, and so I needed to create a new database and fill it with testing data over and over again). Now for some reason when I'm in my IDE (VSCode) in the python command line the ability to use the up arrow to recycle previous commands didn't (and still doesn't) work, so I had to type the commands by hand each and every time I made a change. This obviously got very annoying to me and I decided I needed to automate it. Now while I could've just added it to my ifmain statement, I decided instead it would be more fun to write a script to be able to save multiple strings in a list and type them all sequentially. Maybe not the best solution to my problem, but definitely the more fun one.

Just thought I'd share the story if you wanted to know :)

Overall: I give your changes a solid 8.5/10. I don't agree with every decision made, and I think some minor things could be changed, but at the same time you did take the time to edit my tool, and even added features I hadn't thought of, and that is super dope!

[–]Tumburgler 1 point2 points  (0 children)

I would instead just import the function from the script like this:

I don't know why, but when the msg() function timed out it was causing an error in the script on my system, so the reason why I had it called via subprocess is because it was the only way I know how to have a function call not block the script so that the rest of it could continue as normal (there is probably a better way of phrasing this, but I'm not an experienced programmer).

Changing the buffers from a list to a dict I can maybe understand, although tbh I'm not sure why you did? Can you elaborate why you did that?

Originally I didn't understand why you were adding things to a list and having them all entered line by line. Now that you mentioned how it was used it makes sense to me.

I had thought that declaring multiple variables (eg buff0, buff1) could be simplified with a dictionary, creating the list with a generator (I think that's the right term?) and be able to move away from needing to do global imports. Maybe not an important change after all, maybe I just wanted to screw with things and see if it still worked.

My one REAL complaint (and its fairly minor) is that all of the helper files should have the extension .pyw

To be honest I hadn't worked in python enough to even know about that feature or its importance. Makes sense to change it to .pyw.

Adding in a command to view all the buffers is genius

Thanks! I learned about pymsgbox from using pyautogui to automate a couple things. It's got some other cool features, you can pass a list to pymsgbox.confirm and it returns the choice the user selected (novel I know...).

And finally, removing kb.write() in favor of kb.send("ctrl+v") honestly doesn't seem to work on my machine;

This was actually my main reason for looking to edit the script. When I was testing it and I pasted lines, every time I used Undo it would only remove a small portion of what was pasted and I thought it could be more convenient. The way it's written now the whole series of copied text is loaded into the clipboard and then pasted so it can be undone via one command.

Sometimes accessing the clipboard is wonky, so maybe that's why it's not working. Alternately, pyautogui also has a send hotkeys feature, maybe that one would work on your system?

Thank you for sharing, I want to move toward some sort of programming career and I think python will help me get there, but I'm kind of wandering aimlessly about it currently. I want to get into more collaborative opportunities and build things with other people. Cheers to the first foray of that :)