Jason786 Posted June 17, 2010 Share Posted June 17, 2010 Hey, I pasted the script below Basically, I wanted it to repeat a continous loop It clicks, closes current window, and then clicks again, but it should stop when it closes all the windows and reaches the Google window I have open I tested it, when the google window is open first, then the script stops, but if the other windows are open then it continues to loop around the first bit and never reaches the elseif Am I using the elseif wrong? HotKeySet("{a}", "_Start") HotKeySet("{s}", "_Pause") HotKeySet("{d}", "_Exit") Global $Active = 0 While 1 If $Active = 1 Then MouseClick("left", 1454, 247, 1) Sleep(5000) Send("{CTRLDOWN}w{CTRLUP}") Sleep(36000) MouseClick("left", 1466, 252, 1) ElseIf WinActive("Google - Mozilla Firefox", "") Then Send("d") EndIf WEnd Func _Start() $Active = 1 EndFunc ;==>_Start Func _Pause() $Active = 0 EndFunc ;==>_Pause Func _Exit() Exit EndFunc ;==>_Exit Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 17, 2010 Share Posted June 17, 2010 no, it's your $Active variable. Your loop checks this first, so when it = 1, it will do that. So even if Google is the only window open, $Active is still = 1 HotKeySet("{a}", "_Start") HotKeySet("{s}", "_Pause") HotKeySet("{d}", "_Exit") Global $Active = 0 While 1 If $Active = 1 Then If Not WinActive("Google - Mozilla Firefox", "") Then MouseClick("left", 1454, 247, 1) Sleep(5000) Send("{CTRLDOWN}w{CTRLUP}") Sleep(36000) MouseClick("left", 1466, 252, 1) ElseIf WinActive("Google - Mozilla Firefox", "") Then Send("d") EndIf EndIf Sleep(10) WEnd Func _Start() $Active = 1 EndFunc ;==>_Start Func _Pause() $Active = 0 EndFunc ;==>_Pause Func _Exit() Exit EndFunc ;==>_Exit 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Jason786 Posted June 17, 2010 Author Share Posted June 17, 2010 no, it's your $Active variable. Your loop checks this first, so when it = 1, it will do that. So even if Google is the only window open, $Active is still = 1 HotKeySet("{a}", "_Start") HotKeySet("{s}", "_Pause") HotKeySet("{d}", "_Exit") Global $Active = 0 While 1 If $Active = 1 Then If Not WinActive("Google - Mozilla Firefox", "") Then MouseClick("left", 1454, 247, 1) Sleep(5000) Send("{CTRLDOWN}w{CTRLUP}") Sleep(36000) MouseClick("left", 1466, 252, 1) ElseIf WinActive("Google - Mozilla Firefox", "") Then Send("d") EndIf EndIf Sleep(10) WEnd Func _Start() $Active = 1 EndFunc ;==>_Start Func _Pause() $Active = 0 EndFunc ;==>_Pause Func _Exit() Exit EndFunc ;==>_Exit Hey, but what I'm saying is that if I have google open when I start it, it goes to the elseif function? Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 17, 2010 Share Posted June 17, 2010 (edited) I'll have to install firefox and test... it should just keep looping until you press "a"... *edit* I should also mention that in your original code: When you first start it and have google open, your $Active=0 so your If statement is false, but your ElseIf is true (google window is active) so it closes. Edited June 17, 2010 by kaotkbliss 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Jason786 Posted June 17, 2010 Author Share Posted June 17, 2010 I'll have to install firefox and test... it should just keep looping until you press "a"...*edit*I should also mention that in your original code:When you first start it and have google open, your $Active=0 so your If statement is false, but your ElseIf is true (google window is active) so it closes.ah, that makes sense thanksso is there a function that makes it loop until the window is open? Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 17, 2010 Share Posted June 17, 2010 If you look at what I posted it enters the while 1 loop checks if $Active=1, if it does not, then it will EndIf, pause for 10 miliseconds and check again. Once $active =1 then it will check to see if the active window is google if not google, then does the mouse clicks sleeps 10 ms and checks again else if it is google, then it will send "d" which exits the script. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
GerrOrneq Posted June 17, 2010 Share Posted June 17, 2010 Hi, Just a quick thought, how about you just use WinExists to see if the Google Window is loaded? and act accordingly depending upon the result. DeMo. Quote of the week:"BASIC programmers never die, they GOSUB and don't RETURN." -- UnknownWisdom of the ages:   I'd be unstoppable... if not for law enforcement and physics. Marriage, the number 1 cause of divorce. Don't steal... the government hates competition. Irish Government Motto: We’ve got what it takes to take what you’ve got. Birthdays are good for you. Statistics show that the people who have the most live the longest. Failure is not an option. It comes bundled with your Microsoft product.-- Ferenc Mantfeld If you learn from your mistakes, then why ain't I a genius?! -- Anonymous Remember, live every day as if it was your last day! one day you will be right. How is it one careless match can start a forest fire, but it takes a whole box to start a campfire? Sure my system is secure, it just locked up again. I haven't lost my mind; I have a tape back-up somewhere. ~Author Unknown Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 17, 2010 Share Posted June 17, 2010 closes current window, and then clicks again, but it should stop when it closes all the windows and reaches the Google window I have openBecause google will always be open for this script, just underneath all other windows. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Jason786 Posted June 17, 2010 Author Share Posted June 17, 2010 Because google will always be open for this script, just underneath all other windows.Cheers, works fine now, is there a way I can make autoit work on a seperate window in the background while I do other things? Or is that not possible since it uses the windows mouse? Link to comment Share on other sites More sharing options...
kaotkbliss Posted June 17, 2010 Share Posted June 17, 2010 You might be able to using controlclick instead of mouseclick. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now