 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Niner82WhiskeyTango Guest
|
Posted: Wed Sep 17, 2008 1:31 am Post subject: Scripts switching between scripts |
|
|
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
|
Posted: Wed Sep 17, 2008 2:05 am Post subject: Update |
|
|
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
|
Posted: Wed Sep 17, 2008 3:12 am Post subject: |
|
|
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 |
|
 |
Niner82WhiskeyTango Guest
|
Posted: Wed Sep 17, 2008 3:46 am Post subject: |
|
|
| 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
|
Posted: Wed Sep 17, 2008 3:57 am Post subject: |
|
|
| Code: | Loop
{
; Script A
ImageSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ImageFile
If ( ErrorLevel = 0 ) ; Image Found
{
; Script B
}
} |
|
|
| Back to top |
|
 |
Niner82WhiskeyTango Guest
|
Posted: Wed Sep 17, 2008 4:21 am Post subject: |
|
|
| Thanks for that mate. |
|
| Back to top |
|
 |
Niner82WhiskeyTango Guest
|
Posted: Wed Sep 17, 2008 4:29 am Post subject: |
|
|
| 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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|