Macro not working when compiled

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 159
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Macro not working when compiled

Post by RNIB » Fri Oct 21, 2016 11:47 am

I'm trying to write a macro that will make a piece of software more accessible to blind and visually impaired users as the software currently can only be navigated with a mouse.

The idea is that the macro runs all the time in the background and just waits for the user to make certain hotkeys. When they do, it performs the required function and then waits again until they press another hotkey.

Code: Select all

//Ctrl+Alt+C = Channel
OnEvent>Key_Down,C,5,Channel
//Ctrl+Alt+D = Dynamic
OnEvent>Key_Down,D,5,Dynamic
//Ctrl+Alt+L = Limiter
OnEvent>Key_Down,L,5,Limiter
//Ctrl+Alt+M = Compressor
OnEvent>Key_Down,M,5,Compressor
//Ctrl+Alt+E = Expander
OnEvent>Key_Down,E,5,Expander
//Ctrl+Alt+G = Gate
OnEvent>Key_Down,G,5,Gate
//Ctrl+Alr+S = DeEs
OnEvent>Key_Down,S,5,DeEs
Label>mainloop
Wait>0.02
Goto>mainloop


//Channel
srt>Channel
SetFocus>System255 - OnAir 3000 Demo
MouseMoveRel>223,50
LClick
LUp
end>Channnel
GoTo>mainloop


//Dynamic
srt>Dynamic
SetFocus>System255 - OnAir 3000 Demo
MouseMoveRel>331,101
LClick
LUp
end>Dynamic
GoTo>mainloop


//Limiter
srt>Limiter
SetFocus>System255 - OnAir 3000 Demo
MouseMoveRel>604,192
LClick
LUp
MouseMove>526,645
end>Limiter
GoTo>mainloop

//Compressor
srt>Compressor
SetFocus>System255 - OnAir 3000 Demo
MouseMoveRel>608,274
LClick
LUp
end>Compressor
GoTo>mainloop

//Expander
srt>Expander
SetFocus>System255 - OnAir 3000 Demo
MouseMoveRel>606,352
LClick
LUp
end>Expander
GoTo>mainloop

//Gate
srt>Gate
SetFocus>System255 - OnAir 3000 Demo
MouseMoveRel>608,431
LClick
LUp
end>Gate
GoTo>mainloop

//DeEs
srt>DeEs
SetFocus>System255 - OnAir 3000 Demo
MouseMoveRel>229,103
LClick
LUp
end>DeEs
GoTo>mainloop

This works fine when run within Macro Scheduler but when I compile it as an .exe and run that it will perform the first hotkey action but then does nothing for the subsequent ones. The macro doesn't quit it just won't respond to anything so presumably is caught in some kind of loop or dead end.

I found the exact same thing happened when I ran it within MS when I had the GoTo>Mainloop before the end of subroutine tags so I moved it to after the end tag. Without the GoTo>mainloop tags the macro would simply terminate after the first hotkey was pressed.

How can I get the macro to keep running correctly and just wait for the user to press a hotkey?

If it makes a difference the hotkeys could be pressed in any sequence and conceivably the same hotkey could be pressed multiple times.

RNIB
Macro Veteran
Posts: 159
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Macro not working when compiled

Post by RNIB » Fri Oct 21, 2016 1:16 pm

Fixed it. Just moved the mainloop to the start.

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Macro not working when compiled

Post by JRL » Fri Oct 21, 2016 1:19 pm

The following works for me.
I fixed the end of subroutine Channel which had one too many n's.
Remarked out the lines to set focus to System255 (don't have teh software)
Added lines to set focus to Notepad (I have notepad)
Added lines to send text to Notepad (so I could see something happen)
Added a short Wait

You can remove all of the Goto>mainloop lines except the first one. They're not hurting anything but they're not accomplishing anything either. The script never reaches them.


Code: Select all

//Ctrl+Alt+C = Channel
OnEvent>Key_Down,C,5,Channel
//Ctrl+Alt+D = Dynamic
OnEvent>Key_Down,D,5,Dynamic
//Ctrl+Alt+L = Limiter
OnEvent>Key_Down,L,5,Limiter
//Ctrl+Alt+M = Compressor
OnEvent>Key_Down,M,5,Compressor
//Ctrl+Alt+E = Expander
OnEvent>Key_Down,E,5,Expander
//Ctrl+Alt+G = Gate
OnEvent>Key_Down,G,5,Gate
//Ctrl+Alr+S = DeEs
OnEvent>Key_Down,S,5,DeEs

Label>mainloop
Wait>0.02
Goto>mainloop

//Channel
srt>Channel
SetFocus Notepad*
//SetFocus>System255 - OnAir 3000 Demo
MouseMoveRel>223,50
Wait>1
Send>Channel%crlf%
LClick
LUp
end>Channel
GoTo>mainloop
//Dynamic
srt>Dynamic
SetFocus Notepad*
//SetFocus>System255 - OnAir 3000 Demo
Wait>1
Send>Dynamic%crlf%
MouseMoveRel>331,101
LClick
LUp
end>Dynamic
GoTo>mainloop

//Limiter
srt>Limiter
SetFocus Notepad*
//SetFocus>System255 - OnAir 3000 Demo
Wait>1
Send>Limiter%crlf%
MouseMoveRel>604,192
LClick
LUp
MouseMove>526,645
end>Limiter
GoTo>mainloop

//Compressor
srt>Compressor
SetFocus Notepad*
//SetFocus>System255 - OnAir 3000 Demo
Wait>1
Send>Compressor%crlf%
MouseMoveRel>608,274
LClick
LUp
end>Compressor
GoTo>mainloop
//Expander
srt>Expander
SetFocus Notepad*
//SetFocus>System255 - OnAir 3000 Demo
Wait>1
Send>Expander%crlf%
MouseMoveRel>606,352
LClick
LUp
end>Expander
GoTo>mainloop
//Gate
srt>Gate
SetFocus Notepad*
//SetFocus>System255 - OnAir 3000 Demo
Wait>1
Send>Gate%crlf%
MouseMoveRel>608,431
LClick
LUp
end>Gate
GoTo>mainloop
//DeEs
srt>DeEs
SetFocus Notepad*
//SetFocus>System255 - OnAir 3000 Demo
Wait>1
Send>DeEs%crlf%
MouseMoveRel>229,103
LClick
LUp
end>DeEs
GoTo>mainloop

RNIB
Macro Veteran
Posts: 159
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Macro not working when compiled

Post by RNIB » Fri Oct 21, 2016 1:23 pm

Ahh interesting. I wasn't sure that I needed the goto>mainloops but without them the macro seemed to stop after the first hotkey was pressed but then that may have been because I had misspelled channel.

Cheers JRL, I'll give that a whirl.

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Macro not working when compiled

Post by JRL » Fri Oct 21, 2016 1:24 pm

Fixed it. Just moved the mainloop to the start.
That makes no sense. If the mainloop is at the start none of the OnEvent Lines will run.

RNIB
Macro Veteran
Posts: 159
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Macro not working when compiled

Post by RNIB » Fri Oct 21, 2016 1:27 pm

I don't dispute that, but for some reason it works :?

I'm just trying out your version which I'm sure will get things working the way they should.

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Macro not working when compiled

Post by JRL » Fri Oct 21, 2016 1:28 pm

I'm guessing that you still have an older compiled version running.

RNIB
Macro Veteran
Posts: 159
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: Macro not working when compiled

Post by RNIB » Fri Oct 21, 2016 1:34 pm

No, nothing running at all.

I had just changed the start of the code to this:

Code: Select all

Label>mainloop
//Ctrl+Alt+C = Channel
OnEvent>Key_Down,C,5,Channel
//Ctrl+Alt+D = Dynamic
OnEvent>Key_Down,D,5,Dynamic
//Ctrl+Alt+L = Limiter
OnEvent>Key_Down,L,5,Limiter
//Ctrl+Alt+M = Compressor
OnEvent>Key_Down,M,5,Compressor
//Ctrl+Alt+E = Expander
OnEvent>Key_Down,E,5,Expander
//Ctrl+Alt+G = Gate
OnEvent>Key_Down,G,5,Gate
//Ctrl+Alr+S = DeEs
OnEvent>Key_Down,S,5,DeEs
Wait>0.02
Goto>mainloop
As I say, when compiled this worked fine but without Label>Mainloop being at the very start it would stop working after the first hotkey was pressed. I can't even begin to explain why just that it did.

Anyway, I've tried your amendments, putting Label>mainloop back where it should be and it all works perfectly both within MS and as a compiled .exe so thanks again for your help. :D

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Macro not working when compiled

Post by JRL » Fri Oct 21, 2016 2:21 pm

Now I see. You only moved the first line of the loop. I thought you had moved the entire loop to the top.

Glad you put things back as they were and glad it is working for you. Marcus would need to confirm or deny but I would be concerned about having the OnEvents inside a loop. I'd be concerned about the possibility of consuming memory. That said, the only real changes I made to your script was the spelling correction and adding a Wait>. Wait> is likely the most useful script aid to employ when trying to automate OPW (other people's windows). Wait> is great!

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