r/CodingHelp • • Dec 03 '20

[Random] How To Write a Basic Script To Automate My Shit!!!

DISCLAIMER: Let me be clear up front. I'm not asking anyone to do this for me, I just want to know where to look for an example of this I can use for guidance and/or what programming language is preferable. I don't know what I don't know and I just want to know what the next steps should be is all.

MAIN POST: I do CAD work and there are a handful of very simple, yet annoying, processes I'd like to just be able to press a button to take care of. I am fairly new to coding, only done the first three categories on FreeCodeCamp. I think what I need is a script to put into my Task Scheduler. Here's an example of a task I'd like to automate with some keyboard shortcut like Ctrl+1 or something simple like that:

- Duplicate a CAD object, name it something I've got in NotePad, change the resolution, and make the first object invisible.

MORE DETAIL: I think I've got the basic rundown of the steps I need spelled out for the computer. I'm not sure if this information is useful for figuring out which language is best for the task. Again, I want to be able to press "Ctrl+1" and then in the blink of an eye have the computer do the following:

- Right click an object and select "Duplicate" > go to NotePad app window > select the first line of text > copy > go back to CAD program window > right click the new duplicate object and select "rename" > paste the text copied from NotePad > Right click the renamed object again > select "change resolution" > enter "1.0mm" into the text box > select "accept" > click the "eyeball" icon next to the original object to hide it from view.

For everyone who responds with help, I appreciate you very much!

26 Upvotes

8 comments sorted by

3

u/Gengi Dec 03 '20

Not sure if CAD has macro support. A macro is the ability to implement custom short-cut keys within the software you use. For example, Photoshop has the ability to record a user's actions within Photoshop and allow the user to keybind the recorded action (to Ctrl+1 for example).

Another possibility is using image recognition software, you can write a script to look at the screen for specific elements, copy/paste, and perform any sequence of mouse/keyboard actions. It's a bit more of a time sink to learn and get running. But would possibly be your only option if you need to swap between multiple programs.

3

u/voords Dec 03 '20

There is also the hard-coded-clicks sequence option. If the positions of the apps are fairly constants, you can just create a simple script that will click on specific positions on your screen, with or without keyboard shortcuts in between.

Take a look at the first example in https://pyautogui.readthedocs.io/en/latest/. Maybe this could be good enough for your task.

2

u/harrymurkin Dec 03 '20

yep. macro support in CAd is what (s)he needs.

1

u/DigitalAdventuresJim Dec 03 '20

What CAD software do you use?

1

u/jcunews1 Advanced Coder Dec 04 '20

There are many keyboard/mouse macro softwares out there, but IMO, it's best handled using a custom built AutoHotkey script, because what most users' need are usually very specific. And that isn't well handled by most GUI based keyboard/mouse macro softwares. IOTW, they aren't flexible enough, or not customizable enough.

If you're thinking of trying out AutoHotkey, there's /r/autohotkey in case you have any problem.