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 

Breaking or Pausing an infinite loop at any time?

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



Joined: 14 Mar 2010
Posts: 5

PostPosted: Sun Mar 14, 2010 9:52 am    Post subject: Breaking or Pausing an infinite loop at any time? Reply with quote

Hi, I'm new to the AHK community, I came here because I was interested in using AHK for my gaming purposes.

I recently wanted to run an infinite loop to go through a tedious and lengthy process, ie. manufacturing.

I looked through a lot of the help topics, but they didn't seem to address what I needed or at least an answer that suited my needs.

I was wondering if it was possible to create an infinite loop that would CONSTANTLY listen for a specific hotkey so that I could break the loop at any given time.

While reading some of the user feedbacks, I did manage to script something that would listen in on multiple occasions, but it's very redundant.
I was just wondering if there was a more compact and cleaner way of doing that.

I appreciate everyone's feedback.

Here's what I did:

Code:

#a::
WinWait, Sakexe 2008-01-02a | data folder enable...,
IfWinNotActive, Sakexe 2008-01-02a | data folder enable..., , WinActivate, Sakexe 2008-01-02a | data folder enable...,
WinWaitActive, Sakexe 2008-01-02a | data folder enable...,

#MaxThreadsPerHotkey 3
^`::  ; Ctrl+` hotkey (change this hotkey to suit your preferences).
#MaxThreadsPerHotkey 1
if KeepWinZRunning  ; This means an underlying thread is already running the loop below.
{
    KeepWinZRunning := false  ; Signal that thread's loop to stop.
    return  ; End this thread so that the one underneath will resume and see the change made by the line above.
}
; Otherwise:
KeepWinZRunning := true
Loop
{
   MouseClick, left,  695,  355


if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 300

if not KeepWinZRunning
        break

   Send, {DOWN}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

if not KeepWinZRunning
        break

   Sleep, 100

if not KeepWinZRunning
        break

   Send, {ENTER}

    if not KeepWinZRunning  ; The user signaled the loop to stop by pressing Ctrl+` again.
        break  ; Break out of this loop.
}
KeepWinZRunning := false  ; Reset in preparation for the next press of this hotkey.
return


It seems to work well, but if I just keep thinking, there's gotta be a better way, like the way they do them in the games itself!

EDIT: Just to keep it nice and compact
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Sun Mar 14, 2010 1:30 pm    Post subject: Reply with quote

Try this:
Code:
#a::
KeepWinZRunning=1
Loop
   Send("{1000}a{1000}b{1000}c", KeepWinZRunning)
Return

~Escape::KeepWinZRunning:=0

Send(keys,ByRef exit=""){
   exit_:=exit
   Loop,Parse,Keys,{
   {
      If exit_ && !exit
         Exit
      If RegExMatch(A_LoopField,"^\d\d+\}"){
         Sleep % RegExReplace(A_LoopField,"^\d\d+\K}.*")
         If !(keys:=SubStr(A_LoopField,InStr(A_LoopField,"}")+1))
            Continue
      } else keys:= "{" . A_LoopField
      If exit_ && !exit
         Exit
      Send % keys
   }
}

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Hiro



Joined: 14 Mar 2010
Posts: 5

PostPosted: Sun Mar 14, 2010 7:01 pm    Post subject: Reply with quote

wow..

I wasn't expecting this..

This is more technical than I imagined.

I just kept thinking I was missing a step or two or that there was some trick out there that I didn't know about..

..but this is out of my league, no wait..
..let's have a closer look at this..

I'll examine the code with <--- arrows, then
Code:

#a::
<----------------- this I know, is windows + a, to specify a hotkey

KeepWinZRunning=1
<----------- this is to tell AHK to keep the window open, I'm not sure why it's named WinZ, however.

Loop
<--------------beginning of loop 1

   Send("{1000}a{1000}b{1000}c", KeepWinZRunning)
<-------okay, here's where you pole vault.. that's sending a command to AHK, I can guess that {1000} is the sleep time to check, but a, b, c? I know that we would like to infinitely keepwinzrunning as that the underlying principle of this loop.

Return
<----------specify end of loop 1

<----Okay, I kind of understand the need for two loops, one's the code and the other's the constant listen for feedback, but..hmm..what's going on here? Why return now? I thought those were supposed to be at the end or something

~Escape::KeepWinZRunning:=0
<------------------- !!!! Holy!! So this is it??! The ~ represents the "native" key function, so it can't be blocked?! Is that what that means? Native Escape triggers windowz to stop running.

Send(keys,ByRef exit=""){
<--------------- send command keys, By Refence of exit=nothing to AHK and open the 1st parenthesis, no idea what's going on here

   exit_:=exit
<------------ designate exit_ to be exit

   Loop,Parse,Keys,{
<----------- This opens loop 2, parses (I still don't understand this term's general meaning, wiki defines it as "analyze syntactically by assigning a constituent structure to (a sentence)" but I'll definitely need an analogy of some sort to help me visualize that one), and there's keys from the previous send command, and another parenthesis (2nd) is open (is there a term for this?)

   {
<----------- 3rd parenthesis is open

      If exit_ && !exit
<---------------- If exit_ AND !exit is true..

         Exit
<---------------- exit.. from what? The loop?

      If RegExMatch(A_LoopField,"^\d\d+\}"){
<-------------If.. registry/register/regular expression? match of A_loopfield command then ugh..has a match of ^\d\d+\} of the next line ..and open parenthesis.. (4th)

         Sleep % RegExReplace(A_LoopField,"^\d\d+\K}.*")
<---- sleep ( that is not a %var%..) Regular expression replacement of a_loopfield command..with holy hell..^\d\d+\ (huh? K?) } dot wildcard this closes parenthesis is for the 4th open one, i believe

         If !(keys:=SubStr(A_LoopField,InStr(A_LoopField,"}")+1))
<---- If !(i'm guessing !=not) assigned keys=Sub String (A_loopfield (a built-in command of the loop) such that within the string's a_loopfield command, there is a close parenthesis, plus 1 (to offset?) of regular expression match is true

            Continue
<---- then continue the loop 2

      } else keys:= "{" . A_LoopField
<--- close parenthesis, otherwise assign keys to open parenthesis (5th) dot A_loopfield (is this really a command or variable?)

      If exit_ && !exit
<------- if exit_ AND !exit are true

         Exit
<----------- exit again, exit what?

      Send % keys
<-------------- send something keys

   }
<------------- closes 2nd parenthesis

}
<-----------closes 1st parenthesis
<-------why isn't there a return here also?
<-------What happened to a,b,c?
<-------Okay, what you seem to be doing here is that you're adding what if scenarios to keep the loop going and under specific conditions you throw the } back in to close the loops, but hmm..what does that mean?



This it the extent of my knowledge, if you would be so kind to help me understand this, that would of course, be very kind.

But otherwise, thank you very much for even responding with such a sophisticated code for my gaming needs.

I truly hope that with this experience, I could do more scripting (OR even coding!) in other means later in life too, for whatever the purpose. Perhaps the next one will be to autostart an application in minimize mode in which, it normally does not, or to customize individual folders, like Hiro's personal KICKASS folder! Or maybe, to autorun a program with another program, ie my old dos games to run with dosbox (which, it already does, but perhaps I could do the same with other combinations of programs) Or to simply create an alarm clock to remind me of certain events in my life.

I'm pretty sure the ability to break a loop at any given time is a very helpful logic for any macro task. Especially in troubleshooting.
So any attempts in the future in other scripting and coding will be undoubtedly less frustrating.

Cheers

EDIT: Examined code a [strikeout]second[/strikeout] several time[s] through [haha]
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Sun Mar 14, 2010 8:49 pm    Post subject: Reply with quote

hope this helps Wink
Code:
#a::
KeepWinZRunning=1 ;can be any variable
Loop ;Send some keys, here letters abc again and again, you can use any string, digit or key like {UP}{Down 2}{Enter}{Click}...
   Send("{1000}a{1000}b{1000}c", KeepWinZRunning) ;KeepWinZRunning is passed ByRef so function will know Escape was pressed
Return ;actually not requred here due to Exit command in function but looks better so you know hotkey ends here

~Escape::KeepWinZRunning:=0 ;This will tell the function to Exit now

Send(keys,ByRef exit=""){ ;Declares a function with 2 parameters, exit is ByRef so function can recognize when Escape is pressed
   exit_:=exit ;Remember exit variable to check only if a variable was passed, so it is possible to use the function without a exip possibility
   Loop,Parse,Keys,{ ;Parse trough keys separeted by {, { is an option here, not a parenthesis for Loop!
   { ;this is theparenthesis for the Loop above
      If exit_ && !exit
         Exit ;exit will exit the current AutoHotkey thread (here #a subroutine), see Exit command for more info

      If RegExMatch(A_LoopField,"^\d\d+\}"){ ;See documentation, ^ means must start with digit and have some more digits and closed by }
         Sleep % RegExReplace(A_LoopField,"^\d\d+\K}.*") ;Replace everything from } in A_LoopField to receive sleep time only
         If !(keys:=SubStr(A_LoopField,InStr(A_LoopField,"}")+1)) ;Since a sleep {1000} was found it will be cut of as send command does not need that
            Continue ;continue if keys is empty
      } else keys:= "{" . A_LoopField ;else append '{' that was excluded from Loop,Parse since it is used as a separator
      If exit_ && !exit ;check again if needs exiting before sending keys
         Exit ;exit AutoHotkey thread
      Send % keys ;send keys without sleep value
   }
} ;end of function, Return is not needed here so empty value will be returned

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
closed



Joined: 07 Feb 2008
Posts: 509

PostPosted: Sun Mar 14, 2010 9:14 pm    Post subject: Reply with quote

If you want a totally different approach for instantly killing a loop:

you can make two programs

master that run's and kill's the loop with hotkey (F4) that toggles between run the loop or kill it:
master.ahk
Code:
F4::
status := !status

if status=1
Run, loop.ahk,%A_ScriptDir%

if status=0
winget,pid,pid,loop.ahk
process,close,%pid%

return



loopprogram that is started and killed by the master

example
loop.ahk ( you need the exact name to use in the masterprogram)
Code:
loop
{

MsgBox,,, %A_Index%,1
}

esc::
ExitApp,



the esc is just to be able to terminate if something goes wrong Smile
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Sun Mar 14, 2010 9:21 pm    Post subject: Reply with quote

Or easily use AutoHotkey.dll
_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Hiro



Joined: 14 Mar 2010
Posts: 5

PostPosted: Tue Mar 16, 2010 7:58 am    Post subject: Reply with quote

Well, forgive my n00bness, HotKeyIt..

..in the end, I still couldn't decipher how your code works, and I'm sure it's a very effective one, but I need a class or two :/

EDIT: There were so many areas that I couldn't understand what or why it was happening.. like why you would need to send a,b,c, without sleep time at the last exit, and what exactly is happening at ^\d\d+\K}.*?
If \d = digit, \d x 2? And what's with the arbitrary K? Too many unknowns :/ Can't even understand the general gist of the script really..

In the end, I went around looking at other scripts, notably Wonderland Player's Alchemy Compounding Code..

I borrowed his legal terms and pause/end codes and they seem to work beautifully and I could actually understand it! I was in tears..

Since I'm only using his stuff for personal use, I don't think there's much problem there.

Here's what I finally did with my code:

Code:

Program = Macro Counteragent + Mixture Production
Version = Version 1.0
Title = %Author% - %Version%

; Copyrights, Disclaimer and Limitation
About =
(
%Author% - Hiro

Copyright ©2010
%Version%
Free for Non-Commercial Use
All Lefts Reversed

Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.

Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIfIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
)


;Defaults

EdtMouse = 10
VarPause = 0

#MaxThreadsPerHotkey 2
^+A::  ; Ctrl+Shift+A hotkey

WinWait, Sakexe 2008-01-02a | data folder enable...,
IfWinNotActive, Sakexe 2008-01-02a | data folder enable..., , WinActivate, Sakexe 2008-01-02a | data folder enable...,
WinWaitActive, Sakexe 2008-01-02a | data folder enable...,

   SplashTexton, , , %Name% Program Starting..
   Sleep 2000
   SplashTextoff

   SendRaw, @warp geffen_in 140 141
   Sleep, 500
   Send, {ENTER}
   Sleep, 1000
   MouseMove, 710, 380
   Sleep,100
   Send {Click 2, Right}
   Sleep, 100
   Send +{Click 2, Right}
   Sleep,100
   Send ^{Click 2, Right}
   Sleep, 100

#MaxThreadsPerHotkey 1
if KeepWinZRunning
{
    KeepWinZRunning := false
    return

}
; Otherwise:
KeepWinZRunning := true

Loop
{
   MouseClick, left,  710,  380
   Sleep, 150
   Send, {ENTER}
   Sleep, 300
   Send, {DOWN}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 500
   MouseClick, left,  710,  380
   Sleep, 150
   Send, {ENTER}
   Sleep, 300
   Send, {DOWN}
   Sleep, 150
   Send, {ENTER}
   Sleep, 150
   Send, {ENTER}
   Sleep, 300
   Send, {DOWN}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   
If not KeepWinZRunning
   break
   
}
KeepWinZRunning := false
return

^+p::
Pause::
If (VarPause = 0)
{
   Splashtexton, , , %Name% pause
   VarPause = 1
   Pause, On, 1
}
Else
{
   Splashtexton, , , %Name% continue
   VarPause = 0
   Pause, Off, 1
}
Sleep, 2000
Splashtextoff
Return

END::
Splashtexton, , , %Name% closing Program..
Sleep, 2000
Splashtextoff
ExitApp


Please give any feedback if you see the need to, thanks.

Thank you for your contribution, too, yume.
Back to top
View user's profile Send private message
Hiro



Joined: 14 Mar 2010
Posts: 5

PostPosted: Thu Mar 18, 2010 6:08 am    Post subject: Reply with quote

HotKeyIt wrote:
hope this helps Wink
Code:
#a::
KeepWinZRunning=1 ;can be any variable
Loop ;Send some keys, here letters abc again and again, you can use any string, digit or key like {UP}{Down 2}{Enter}{Click}...
   Send("{1000}a{1000}b{1000}c", KeepWinZRunning) ;KeepWinZRunning is passed ByRef so function will know Escape was pressed
Return ;actually not requred here due to Exit command in function but looks better so you know hotkey ends here

~Escape::KeepWinZRunning:=0 ;This will tell the function to Exit now

Send(keys,ByRef exit=""){ ;Declares a function with 2 parameters, exit is ByRef so function can recognize when Escape is pressed
   exit_:=exit ;Remember exit variable to check only if a variable was passed, so it is possible to use the function without a exip possibility
   Loop,Parse,Keys,{ ;Parse trough keys separeted by {, { is an option here, not a parenthesis for Loop!
   { ;this is theparenthesis for the Loop above
      If exit_ && !exit
         Exit ;exit will exit the current AutoHotkey thread (here #a subroutine), see Exit command for more info

      If RegExMatch(A_LoopField,"^\d\d+\}"){ ;See documentation, ^ means must start with digit and have some more digits and closed by }
         Sleep % RegExReplace(A_LoopField,"^\d\d+\K}.*") ;Replace everything from } in A_LoopField to receive sleep time only
         If !(keys:=SubStr(A_LoopField,InStr(A_LoopField,"}")+1)) ;Since a sleep {1000} was found it will be cut of as send command does not need that
            Continue ;continue if keys is empty
      } else keys:= "{" . A_LoopField ;else append '{' that was excluded from Loop,Parse since it is used as a separator
      If exit_ && !exit ;check again if needs exiting before sending keys
         Exit ;exit AutoHotkey thread
      Send % keys ;send keys without sleep value
   }
} ;end of function, Return is not needed here so empty value will be returned


Mmmm..still very curious about HotKeyIt's script..

..is there anyone around that can help me understand this better?
Like some analogy or an "english" step-by-step translation about the process..even just a concept map is a start..

I still can't relate to it with my current understanding.. :/

For example,
If I script closing a door, tell me that I'd first have to locate the handle, then I'd have mobilize my arm and fingers to wrap around the handle, then mobilize my legs to push the door while keeping my arm steady, then when the door is fully closed. ie. click sound, release hand from handle, end program.

So if someone can use a similar approach, I would understand it best like so.
Back to top
View user's profile Send private message
Hiro



Joined: 14 Mar 2010
Posts: 5

PostPosted: Fri Apr 16, 2010 6:23 pm    Post subject: Reply with quote

Well, since no one's replied, I'll just post this if anyone needs reference to it.

This is one of the final version, I came up with.
Hope someone will find it useful

Code:

Program = Macro Counteragent + Mixture Production
Version = Version 1.0
Title = %Author% - %Version%

; Copyrights, Disclaimer and Limitation
About =
(
%Author% - Hiro

Copyright ©2010
%Version%
Free for Non-Commercial Use
All Lefts Reversed

Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.

Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIfIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
)


;Defaults

EdtMouse = 10
VarPause = 0

#MaxThreadsPerHotkey 2
^+A::  ; Ctrl+Shift+A hotkey

WinWait, .: Weiss Ragnarok Online - Experience the future! :.,
IfWinNotActive, .: Weiss Ragnarok Online - Experience the future! :., , WinActivate, .: Weiss Ragnarok Online - Experience the future! :.,
WinWaitActive, .: Weiss Ragnarok Online - Experience the future! :.,

   SplashTexton, , , %Name% Program Starting..
   Sleep 2000
   SplashTextoff

   Send, {ESC}
   Sleep, 100
   ImageSearch, Px, Py, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ProgramFiles%\WeissRO\ScreenShot\SO.bmp
   if ErrorLevel = 1
       {
   Send, {ENTER}
   Sleep, 100
   }
   else if ErrorLevel = 0
   {
   Send, {ESC}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   }
   else if ErrorLevel = 2
   {
   MsgBox, Could not conduct search.
   ExitApp
   }
   SendRaw, @warp geffen_in 140 141
   Sleep, 100
   Send, {ENTER}
   Sleep, 2500
   MouseMove, 580, 400
   Sleep, 250
   Send, {Click 2, Right}
   Sleep, 500
   Send, +{Click 2, Right}
   Sleep, 500
   Send, ^{Click 2, Right}
   Sleep, 500

#MaxThreadsPerHotkey 1
if KeepWinZRunning
{
    KeepWinZRunning := false
    return

}
; Otherwise:
KeepWinZRunning := true

Loop
{
   WinWait, .: Weiss Ragnarok Online - Experience the future! :.,
   IfWinNotActive, .: Weiss Ragnarok Online - Experience the future! :., ,          WinActivate, .: Weiss Ragnarok Online - Experience the future! :.,
   WinWaitActive, .: Weiss Ragnarok Online - Experience the future! :.,    

   MouseMove, 700, 420
   Sleep, 250
   Send, {Click 2, Left}
   Sleep, 350
   Send, {ENTER}
   Sleep, 500
   Send, {DOWN}
   Sleep, 200
   Send, {ENTER}
   Sleep, 350
   Send, {ENTER}
   Sleep, 350
   Send, {ENTER}
   Sleep, 350
   Send, {ENTER}
   Sleep, 350
   Send, {ENTER}
   Sleep, 350
   Send, {ENTER}
   Sleep, 350
   Send, {ENTER}
   Sleep, 350
   ImageSearch, Px, Py, 0, 0, A_ScreenWidth, A_ScreenHeight, *5 %A_ProgramFiles%\WeissRO\ScreenShot\NE.bmp
   if ErrorLevel = 1
   {
   }
   else if ErrorLevel = 0
   {
   MsgBox, You do not have sufficient materials to continue..
   Send, {ENTER}
   Sleep, 100
   ExitApp
   }
   else if ErrorLevel = 2
   {
   MsgBox, Could not conduct the search.
   ExitApp
   }
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 100
   Send, {ENTER}
   Sleep, 500
   
If not KeepWinZRunning
   break
   
}
KeepWinZRunning := false
return

^+p::
Pause::
If (VarPause = 0)
{
   Splashtexton, , , %Name% pause
   VarPause = 1
   Pause, On, 1
}
Else
{
   Splashtexton, , , %Name% continue
   VarPause = 0
   Pause, Off, 1
}
Sleep, 2000
Splashtextoff
Return

END::
Splashtexton, , , %Name% closing Program..
Sleep, 2000
Splashtextoff
ExitApp
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