BoscoB Posted January 15, 2007 Share Posted January 15, 2007 I have the following script that works as I need it but want to input a exitloop so that if I press a key (specified if need be) that the loop is exited. The documention only shows examples from what I can see of if a variable reaches a trigger point. CODEHotKeySet("{ESC}", "Terminate") HotKeySet("1", "Normal") HotKeySet("2", "Fast") Opt("SendKeyDelay", 60) While 1 Sleep(100) WEnd Func Terminate() Exit 1 EndFunc Func Normal() $i = 0 WinActivate("????2", "") While $i <= 9999 Send("z", 1) $i = $i + 1 WEnd EndFunc Func Fast() $i = 0 WinActivate("????2","") Opt("SendKeyDelay", 3) While $i <= 999 Send("z", 1) $i = $i + 1 WEnd EndFunc Can this be done or do I need to re-evaluate my code and try a different approach? BoscoB Link to comment Share on other sites More sharing options...
phantom Posted January 15, 2007 Share Posted January 15, 2007 (edited) does this help? #include <Misc.au3> If _IsPressed ("09") Then $i = 10000 09 is the tab button Edited January 15, 2007 by phantom Link to comment Share on other sites More sharing options...
Outshynd Posted January 15, 2007 Share Posted January 15, 2007 Make a hotkey that sets $i to 10000? Link to comment Share on other sites More sharing options...
herewasplato Posted January 15, 2007 Share Posted January 15, 2007 (edited) _IsPressed involves a lot of "included code" for such a simple request.Outshynd pointed out a good way for the OP's specific code since it uses:While $i <= 9999This sample code should work no matter what expression is driving the loop:HotKeySet("{ESC}", "dummy") While 1 Sleep(100) ToolTip("Looping") If @HotKeyPressed = "{ESC}" Then ExitLoop WEnd Func dummy() EndFunc ;==>dummy Edited January 15, 2007 by herewasplato yffulf 1 [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
BoscoB Posted January 16, 2007 Author Share Posted January 16, 2007 does this help?#include <Misc.au3>If _IsPressed ("09") Then $i = 1000009 is the tab buttonThat worked perfectly, thank you!BoscoB Link to comment Share on other sites More sharing options...
herewasplato Posted January 16, 2007 Share Posted January 16, 2007 _IsPressed involves a lot of "included code" for such a simple request.What I meant by this is - using _IsPressed the way it was suggested adds 440+ lines of code to your script when you only needed 4 lines to do what the OP asked for. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Shevilie Posted January 16, 2007 Share Posted January 16, 2007 (edited) I know its a small script, and i would use another approach to the problem. I would rather use a second variable. All loops would have this $endloop = 0 While (Your argument) or ($endloop = 1) WEndoÝ÷ Ù8^¯y§îËb¢v¬¶¬jëh×6Func EndLoop() $exitloop = 1 EndFunc oÝ÷ Ø Ý{azÚ)¡ûazÇ+ZºÚ"µÍÛØ[ ÌÍÙ^]ÛÜHÝÙ^TÙ] ][ÝÝ ][ÝË ][ÝÑ[ÛÜ ][ÝÊB This way you can use it in differnet loops without the same variables etc (Non tested) Edited January 16, 2007 by Shevilie Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
herewasplato Posted January 16, 2007 Share Posted January 16, 2007 I know its a small script, and i would use another approach to the problem. I would rather use a second variable. All loops would have this $endloop = 0 While (Your argument) or ($endloop = 1) WEndoÝ÷ Ù8^¯y§îËb¢v¬¶¬jëh×6 Func EndLoop() $exitloop = 1 EndFunc oÝ÷ Ø Ý{azÚ)¡ûazÇ+ZºÚ"µÍÛØ[ ÌÍÙ^]ÛÜHÝÙ^TÙ] ][ÝÝ ][ÝË ][ÝÑ[ÛÜ ][ÝÊBoÝ÷ Ù8b³²Êj{¬z+bØ}êçzÙh¢0ØhºÛazƦzö«¦åzÇpÚ'µë-yßêº^N«yªÞjÙ^jËmÂÞjÊ'²ØZ·*.(!¶z-Á©í¶(¶¬®{TájÜ"Z''±ÛayË«éíZ¥{õÙh¢!WÿN§üLb´º(¦X§yƧ{ë-yÙh¢Ñh¯ó^ÆÙh¢"xLb´º(§}¶+n+aj·^®ÚÆZ{azZ Êjw±¦·¬²*'Â+aÞ¶§¢w®¦z{m¡ª^®Ê'ì-£ â¶)àr^"ØbKajܨºgÛhºÇªº@Ú®¢Ø§²×vêºN®«¨µh«¨´êêºméh¢"W(ا¹æ¬àjÊ'zíæ«éÛ"²Úîy8b±Êz+#ºËm¢)eºËkjצÊ"Ò'æ¥'ÞÊ°¢é]«Þjz-êÞÆ+¢wb¶*'Â+a{ajÕ¡W¿XIÝ)nëmꮢÒý8^ñ1Ò袮¢Ù¶Â)ejYhÃ*.¶±Öè¶h¢Ù¨½ê'¶!jׯz·(u謶èZ0jëh×6HotKeySet("{ESC}", "dummy") For $i = 1 To 10000 While 1 Sleep(100) ToolTip("Looping") If @HotKeyPressed = "{ESC}" Then ExitLoop 2 WEnd Next Func dummy() EndFunc ;==>dummy [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Shevilie Posted January 16, 2007 Share Posted January 16, 2007 Well the or was a typo And after looking through your script i would also prefer the HotKeySet("{ESC}", "dummy") For $i = 1 To 10000 While 1 Sleep(100) ToolTip("Looping") If @HotKeyPressed = "{ESC}" Then ExitLoop 2 WEnd Next Func dummy() EndFunc ;==>dummy Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit 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