AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help with Script A unpausing Script B and vise versa

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
defrostedchemist



Joined: 09 Sep 2008
Posts: 6

PostPosted: Thu May 21, 2009 2:29 am    Post subject: Need help with Script A unpausing Script B and vise versa Reply with quote

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! Very Happy
Back to top
View user's profile Send private message
PausedActivator
Guest





PostPosted: Thu May 21, 2009 10:53 am    Post subject: Reply with quote

The AHK help ! Arrow "sending data between scripts"
Back to top
defrostedchemist



Joined: 09 Sep 2008
Posts: 6

PostPosted: Fri May 22, 2009 7:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Sat May 23, 2009 3:27 am    Post subject: Reply with quote

Quote:
However, once paused, it seems that Script_A will no longer recieve messages and cannot be unpaused by Script_B.
Here's why:
Quote:
MaxThreads - This integer is normally omitted, in which case the monitor function is limited to one thread at a time.
Source: AutoHotkey Documentation: OnMessage

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
View user's profile Send private message Visit poster's website
defrostedchemist



Joined: 09 Sep 2008
Posts: 6

PostPosted: Sat May 23, 2009 6:21 am    Post subject: Reply with quote

Wow, that works wonderfully. Thank you for the help. Cool
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group