Compiled macro

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
JCFCTech
Newbie
Posts: 2
Joined: Mon Feb 13, 2006 8:05 pm

Compiled macro

Post by JCFCTech » Mon Feb 13, 2006 8:16 pm

I recorded a simple macro that selects all on a screen and copies it to the clipboard. I assigned it to F6. However, when I compile it to create an .exe the macro runs once every time I double click on the icon that I created for it. I would like to distribute the macro to other employees so that they can automate a very tedious process but would like the F6 to trigger the macro on their pc and to continue to run until the enter Shift-Esc. What am I missing? Thanks in advance. Pat

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 13, 2006 9:33 pm

Hi,

A compiled macro is just the macro. It is just a compiled version of the script. Executables only run when you run them. When you run it, it runs the script and then exits. Something needs to be running all the time to detect a hotkey and do something with it. If you exited Macro Scheduler any hot key macros would stop working - nothing is running that knows anything about the hot key. Same deal. An EXE would need to have some code to handle the hotkey and would need to be running ALL the time to know it was pressed.

There are three options:

1) Simples solution - your other employees need to run Macro Scheduler with the script set up within it with a hotkey assigned. They would need a license of course.

2) Create a shortcut to the exe and assign that a hotkey - look in the properties of a desktop shortcut - you will see you can assign a hot key - Windows handles this for you. But the choice is limited.

3) Add an OnEvent KEY_DOWN handler into your macro. Put your code into a subroutine and have the event handler call it. Create a main loop which does nothing but wait for a fraction of a second. The EXE will clearly have to be running all the time so put it in the startup folder. It will now watch for the key stroke itself and run the code when the key is pressed and it will keep running.

OnEvent>KEY_DOWN,VK117,0,RunCode

Label>mainloop
Wait>0.5
Goto>mainloop

SRT>RunCode
..
.. your code here
..
END>RunCode

Remember - the macro needs to be running! It can't do or know anything if it is not alive! So after adding the above code, compile the macro and then you will need to ask your colleagues to put a shortcut in their startup folder so that it always starts on boot up. Or create an installer that does that for them using an install file creator such as Innosetup or Wise.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

JCFCTech
Newbie
Posts: 2
Joined: Mon Feb 13, 2006 8:05 pm

Compiled Macro - thanks

Post by JCFCTech » Tue Feb 14, 2006 4:05 pm

Marcus, thanks for the quick response. I am truly a "beginner" as you can tell from the question but hopefully my skills will grow. Do you have any recommendations for books that could help me learn about scripting? Thanks Pat

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts