 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
defrostedchemist
Joined: 09 Sep 2008 Posts: 6
|
Posted: Thu May 21, 2009 2:29 am Post subject: Need help with Script A unpausing Script B and vise versa |
|
|
Hi, I have a question about using a script to pause or unpause a second script and vise versa.
Basically, I have two scripts that currently work just fine in tandem.
I am looking for a better way to do the pausing and unpausing of the two scripts that does not involve sending keystrokes.
I could try to combine both scripts with use of timers, however, they are already each quite complex and this way works fine.
I would just like if it didnt have to send keystrokes for the tandem scripts to pause each other.
Script A
| Code: | ;Script A
Loop{
;Long and Boring highly repetitive task
;Blah
;Blah
;Blah
;Send Keystrokes to unpause Script B.
Send {Shift Down}
Sleep 50
Send {F11 Down}
Sleep 100
Send {F11 Up}
Sleep 50
Send {Shift Up}
Sleep 100
;Pause Script A.
Pause,On
}
+F10::Pause,Off |
Script B
| Code: | ;Script B
Loop{
;Short but complex timer and image search based task
;BlahBlahBlah
;Send Keystrokes to unpause Script A.
Send {Shift Down}
Sleep 50
Send {F11 Down}
Sleep 100
Send {F11 Up}
Sleep 50
Send {Shift Up}
Sleep 100
;Pause Script B.
Pause,On
}
+F11::Pause,Off |
Anyone have any ideas?
Thanks in advance!  |
|
| Back to top |
|
 |
PausedActivator Guest
|
Posted: Thu May 21, 2009 10:53 am Post subject: |
|
|
The AHK help ! "sending data between scripts" |
|
| Back to top |
|
 |
defrostedchemist
Joined: 09 Sep 2008 Posts: 6
|
Posted: Fri May 22, 2009 7:53 pm Post subject: |
|
|
Thanks for the tip!
I'm still having a bit of trouble though.
So far, I can get Script_B to send a message to Script_A to pause Script_A.
However, once paused, it seems that Script_A will no longer recieve messages and cannot be unpaused by Script_B.
| Code: | ;Script_A
Loop{
;Long and Boring highly repetitive task
;Blah
;Blah
;Blah
}
OnMessage(0x4a,"Receive_WM_COPYDATA")
Receive_WM_COPYDATA()
{
Pause Toggle
} |
| Code: | ;Script_B
TargetScriptTitle=Script_A.ahk ahk_class AutoHotkey
SetTitleMatchMode 2
DetectHiddenWindows On
Loop{
SendMessage, 0x4a, 0, &CopyDataStruct,, %TargetScriptTitle% ;To pause Script_A (Works great!)
;Short but complex timer and image search based task
;BlahBlahBlah
SendMessage, 0x4a, 0, &CopyDataStruct,, %TargetScriptTitle% ;To unpause Script_A (Will not recieve message)
;Sleep some unit of time
} |
The only things I know of that work while a script are paused are hotkeys and hot strings.
Is there anyway to get a script to accept a message while it is paused?
Thanks again! |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7295 Location: Australia
|
Posted: Sat May 23, 2009 3:27 am Post subject: |
|
|
| Quote: | | However, once paused, it seems that Script_A will no longer recieve messages and cannot be unpaused by Script_B. | Here's why:
Here's a better method, which can be used from Script_B.ahk without any extra code in Script_A.ahk:
| Code: | DetectHiddenWindows, On
SetTitleMatchMode, 2
PostMessage, 0x111, 65403,,, Script_A.ahk ahk_class AutoHotkey
|
|
|
| Back to top |
|
 |
defrostedchemist
Joined: 09 Sep 2008 Posts: 6
|
Posted: Sat May 23, 2009 6:21 am Post subject: |
|
|
Wow, that works wonderfully. Thank you for the help.  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|