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 

Scripts switching between scripts

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





PostPosted: Wed Sep 17, 2008 1:31 am    Post subject: Scripts switching between scripts Reply with quote

If I knew the proper terminology to look for, I could have found it already. So I'll explain it best I can literate, and you can probably figure out what Im trying to do.

Basically, this is what I've got going.

Script runs every 15 minutes. It clicks a series of links and buttons. That part works fine. The thing I need it to do now, is if ImageSearch detects a certain message/popup, it needs to temporarily abort the aforementioned primary script and run another script, and then return back to the primary script when it's done. That secondary script is going to have to run about every 24 hours, but I'd like imagesearch to scan for it every other hour.

So, here is an outline of what I think it should look like:
-------
Script A Running
Script A uses ImageSearch to scan for message
If message seen, will go to Script B. If not, will continue on about the loop.

Script B:
Temporarily pause Script A
Run Script Commands
Return to Script A
-------

Im somewhat new to the program. I haven't figured out how to make subscripts coincide with eachother. If they are even called that. Hence my dilemma. Help is much appreciated.



Here is the scriptage I have so far:

Lets call this one Script A, the Primary Script:


Code:
#X::
Loop, 9999

{
    CoordMode, Mouse, Screen
    MouseClick , Left , 48, 120, 1, 10,
    MouseClick , Right , 48, 120, 1, 10,
    Sleep, 1000
    Send R
    Sleep, 1600
    Send {Enter}
    Sleep, 1600
    Send {Enter}
    Sleep, 1600
    Send {Enter}
    Sleep, 100
    CoordMode, Mouse, Screen
    MouseClick , Left , 297, 118, 1, 10,
    MouseClick , Left , 72, 552, 1, 10,
    Sleep, 10000
    ImageSearch, OutputVarX, OutputVarY, 225, 254, 480, 715, C:\Userdocs\Administrator\My

Documents\deposit.bmp
    MouseMove, %OutputVarX%, %OutputVarY%
    Click
    Sleep, 885100
}
    return



Somewhere between these, ImageSearch needs to try and detect quoteprompt.bmp and run Script B if it is detected.

And Script B:

Code:
    CoordMode, Mouse, Screen
    MouseClick , Left , 101, 753, 1, 10,
    Sleep, 5000
    MouseClick , Right , 370, 98, 1, 10,
    Sleep, 150
    Send, O
    Sleep, 15000
    MouseClick , Left , 1008, 10, 1, 10,     
    Sleep, 3000
    Send, {Enter}
Back to top
Niner82WhiskeyTango
Guest





PostPosted: Wed Sep 17, 2008 2:05 am    Post subject: Update Reply with quote

Guess I should have made an account. Can't edit last post.

I've done some hunting. The term I should be calling Script B is actually "Subroutine". What Im looking to do is put that subroutine in a loop. The rest of the loop is going to repeat 100 times before the subroutine is needed. The subroutine needs to be called upon by an Imagesearch done every 2 hours.
Back to top
Mustang



Joined: 17 May 2007
Posts: 421
Location: England

PostPosted: Wed Sep 17, 2008 3:12 am    Post subject: Reply with quote

It's a little hard to understand what you are requesting
Maybe something like this:
Code:
Loop
{
    Loop, 100
    {
        ; Script A
    }
    ; Script B
}


Here is an example of it working:
Code:
Loop
{
    Loop, 100
    {
        ToolTip, %A_Index%
    }
    MsgBox, 100 Loops Completed
}
Back to top
View user's profile Send private message
Niner82WhiskeyTango
Guest





PostPosted: Wed Sep 17, 2008 3:46 am    Post subject: Reply with quote

Ah, yeah. I didn't mean I wanted it to loop 100 times before it did it's thing. I meant it might loop up to a hundred times before it's needed. I got the script working though. I put it on a 12 hour timer. I tested it with shorter timings and it seems to work. Although I'd rather have it triggered by a ImageSearch instead.
Back to top
Mustang



Joined: 17 May 2007
Posts: 421
Location: England

PostPosted: Wed Sep 17, 2008 3:57 am    Post subject: Reply with quote

Code:
Loop
{
    ; Script A
    ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile
    If ( ErrorLevel = 0 ) ; Image Found
    {
        ; Script B
    }
}
Back to top
View user's profile Send private message
Niner82WhiskeyTango
Guest





PostPosted: Wed Sep 17, 2008 4:21 am    Post subject: Reply with quote

Thanks for that mate.
Back to top
Niner82WhiskeyTango
Guest





PostPosted: Wed Sep 17, 2008 4:29 am    Post subject: Reply with quote

Code:
#X::
Loop, 9999
{
    ; CoordMode, Mouse, Screen
    MouseClick , Left , 48, 120, 1, 10,
    MouseClick , Right , 48, 120, 1, 10,
    Sleep, 1000
    Send R
    Sleep, 1600
    Send {Enter}
    Sleep, 1600
    Send {Enter}
    Sleep, 1600
    Send {Enter}
    Sleep, 100
    CoordMode, Mouse, Screen
    MouseClick , Left , 297, 118, 1, 10,
    MouseClick , Left , 72, 552, 1, 10,
    Sleep, 10000
    ImageSearch, OutputVarX, OutputVarY, 225, 254, 480, 715, C:\Userdocs\Administrator\My

Documents\deposit.bmp
    MouseMove, %OutputVarX%, %OutputVarY%
    Click
    Sleep, 885100
    ImageSearch, OutputVarX, OutputVarY, 49, 265, 999, 557, C:\Userdocs\Administrator\My

Documents\voteprompt.bmp
    If ( ErrorLevel = 0 ) ; Image Found
    {
Return
    CoordMode, Mouse, Screen
    MouseClick , Left , 101, 753, 1, 10,
    Sleep, 5000
    MouseClick , Right , 370, 98, 1, 10,
    Sleep, 850
    Send, O
    Sleep, 15000
    MouseClick , Left , 1008, 10, 1, 10,     
    Sleep, 3000
    Send, {Enter}
return
    }
}



Here she is. I don't have time to test it yet, but I shall. Thanks again.
Back to top
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