Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Pause script & send key



  • Please log in to reply
6 replies to this topic
Felkor
  • Members
  • 5 posts
  • Last active: Mar 03 2015 06:41 PM
  • Joined: 02 Mar 2015

Hello,

 

I'm trying to perform a pause action, and send a key when the pause is toggle.

 

Exemple :

a::
<MyScript>
return


²::Pause,toggle
Send i
return

However, the "send i" doesn't work.
Ok, seems legit, when encountering the "Pause" action, everything stop.

So I've try :

²::Send i
Pause,toggle
return

But in this case the toggle doesn't work, the script doesnt leave the "pause state".

Any idea ? :)



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Multiline hotkeys need to have no command on the same line as the hotkey itself

 

²::
Pause,toggle ; or reversed so Send i is first
Send i
return

 

That should work for you.



Felkor
  • Members
  • 5 posts
  • Last active: Mar 03 2015 06:41 PM
  • Joined: 02 Mar 2015

Thanks for your input ; But i'm not able to make it works.

²::
Pause,toggle
Send i
return

My first script is paused, but i is not send.

When I toggle the pause, the script starts again, and 2 i are sent.

²::
Send i
Pause,toggle
return

When using ², the script is paused and i send.
However, when i'm trying to toggle the script in running mode, (using ² again) nothing happens, nor i send or script running again.



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Hmm, yeah... that's a quirk with Pause mode.

 

So in the first instance, you fire one thread. The pause command makes it pause (it's in a pause ON state). Then when somethign else, a second thread started with the same hotkey, turns off pause, now both threads will one run one after the other and you get a net result of two pauses.

 

In the second instance, the i comes first as you saw. But you can't turn off pause: Pause can only be turned off by a hotkey that starts with the command Pause.

 

I'm sure there is a solution out there to get the behavior you want, but I can't think of it and type it up in the less than a minute I have before I leave, hehe.



Felkor
  • Members
  • 5 posts
  • Last active: Mar 03 2015 06:41 PM
  • Joined: 02 Mar 2015

In fact, I need to send a hotkey allowing me to toggle or not an information to know if the status of the script (pause or running) inside the application.
This was the "easy" way I've found, but not able to get it work ;)

 

If anyone has an idea, i'll take it !



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

If you have just hotkeys firing, consider looking at #IfWinActive.

 

You might also consider doing this:

 

²::
toggle:=!toggle ; toggle here is just a custom variable; it could have any name. Changes value of the variable between 1 and 0
Send i ; this is sent everytime regardless of the state of toggle
return
 
#If toggle ; put all hotkeys you want to enable/disable using ² here. These are inactive when the script turns on. You can fix that by putting toggle:=1 in the auto-execute section
a::MsgBox hi
b::MsgBox bye
 
#If

 

If you have timers, you can put at the beginning of a timer

 

If !toggle ; if toggle is not one, these timers will just return.
   return


Felkor
  • Members
  • 5 posts
  • Last active: Mar 03 2015 06:41 PM
  • Joined: 02 Mar 2015
✓  Best Answer

Yep, job's done :)

 

It's a little dirty, but it works ;)
Thanks for the idea !