sandin Posted August 25, 2007 Share Posted August 25, 2007 Here's the script: expandcollapse popup#include <GuiConstants.au3> #Include <Constants.au3> #include <Process.au3> #include <INet.au3> #include <misc.au3> hotkeyset("{NUMPAD0}", "STOPP") hotkeyset("{NUMPAD1}", "func4") hotkeyset("{NUMPAD2}", "end") Global $ggg Global $starttime1 Global $starttime2 Global $starttime3 Global $starttime4 Global $aaa Global $bbb Global $ccc Global $mmm Global $nnn Global $ooo $time = 5000;5 sec $starttime4=TimerInit() $time2 = 120000;2 min AdlibEnable("myadlib", 10) func myadlib () if $aaa=1 Then if TimerDiff($starttime1)>$time Then call ("func1") EndIf EndIf if $bbb=1 Then if TimerDiff($starttime2)>$time Then call ("func2") EndIf EndIf if $ccc=1 Then if TimerDiff($starttime3)>$time Then call ("func3") EndIf EndIf If TimerDiff($starttime4)>$time2 Then msgbox(262144, "time ended", "time ended, script will close now.") call ("end") EndIf EndFunc Func STOPP () $ggg += 1 TrayTip("notice", "you have called stop " & $ggg & " times.", 10) $aaa = 0 $bbb = 0 $ccc = 0 While 1 Sleep(10) Wend EndFunc func end () Exit EndFunc func again () ;nothing EndFunc func func1 () $mmm += 1 sleep (1000) TrayTip('notice', 'You have called func1 ' & $mmm & ' times.', 10) $starttime1=TimerInit() EndFunc func func2 () $nnn += 1 sleep (1000) TrayTip('notice', 'You have called func2 ' & $nnn & ' times.', 10) $starttime2=TimerInit() EndFunc func func3 () $ooo += 1 sleep (1000) TrayTip('notice', 'You have called func3 ' & $ooo & ' times.', 10) $starttime3=TimerInit() EndFunc Func func4 () call ("func1") $aaa = 1 call ("func2") $bbb = 1 call ("func3") $ccc = 1 $xkoordinata = 0 $ykoordinata = 0 $speed2 = 10 while 1 call ("again") MouseDown( "Right") MouseMove(337, 299 , $speed2) MouseDown( "Right") MouseMove( 287 , 246 , $speed2) MouseDown( "Right") MouseMove( 432 , 246 , $speed2) MouseDown( "Right") MouseMove( 402 , 171 , $speed2) MouseDown( "Right") MouseMove( 467, 191, $speed2) MouseDown( "Right") MouseMove( 517 , 253 , $speed2) MouseDown( "Right") MouseMove( 447 ,301, $speed2) MouseDown( "Right") MouseMove( 397 ,311, $speed2) MouseUp("Right") WEnd EndFunc while 1 sleep (10) WEnd and the problem is following: If I hold down NumPad0 till it counts more than 100 times, then run the func with NumPad1, let it do 1 circle, and then hit NumPad0 to stop it, after running func4 with NumPad1 adlib won't work anymore. Why's that??? Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
martin Posted August 25, 2007 Share Posted August 25, 2007 Here's the script: expandcollapse popup#include <GuiConstants.au3> #Include <Constants.au3> #include <Process.au3> #include <INet.au3> #include <misc.au3> hotkeyset("{NUMPAD0}", "STOPP") hotkeyset("{NUMPAD1}", "func4") hotkeyset("{NUMPAD2}", "end") Global $ggg Global $starttime1 Global $starttime2 Global $starttime3 Global $starttime4 Global $aaa Global $bbb Global $ccc Global $mmm Global $nnn Global $ooo $time = 5000;5 sec $starttime4=TimerInit() $time2 = 120000;2 min AdlibEnable("myadlib", 10) func myadlib () if $aaa=1 Then if TimerDiff($starttime1)>$time Then call ("func1") EndIf EndIf if $bbb=1 Then if TimerDiff($starttime2)>$time Then call ("func2") EndIf EndIf if $ccc=1 Then if TimerDiff($starttime3)>$time Then call ("func3") EndIf EndIf If TimerDiff($starttime4)>$time2 Then msgbox(262144, "time ended", "time ended, script will close now.") call ("end") EndIf EndFunc Func STOPP () $ggg += 1 TrayTip("notice", "you have called stop " & $ggg & " times.", 10) $aaa = 0 $bbb = 0 $ccc = 0 While 1 Sleep(10) Wend EndFunc func end () Exit EndFunc func again () ;nothing EndFunc func func1 () $mmm += 1 sleep (1000) TrayTip('notice', 'You have called func1 ' & $mmm & ' times.', 10) $starttime1=TimerInit() EndFunc func func2 () $nnn += 1 sleep (1000) TrayTip('notice', 'You have called func2 ' & $nnn & ' times.', 10) $starttime2=TimerInit() EndFunc func func3 () $ooo += 1 sleep (1000) TrayTip('notice', 'You have called func3 ' & $ooo & ' times.', 10) $starttime3=TimerInit() EndFunc Func func4 () call ("func1") $aaa = 1 call ("func2") $bbb = 1 call ("func3") $ccc = 1 $xkoordinata = 0 $ykoordinata = 0 $speed2 = 10 while 1 call ("again") MouseDown( "Right") MouseMove(337, 299 , $speed2) MouseDown( "Right") MouseMove( 287 , 246 , $speed2) MouseDown( "Right") MouseMove( 432 , 246 , $speed2) MouseDown( "Right") MouseMove( 402 , 171 , $speed2) MouseDown( "Right") MouseMove( 467, 191, $speed2) MouseDown( "Right") MouseMove( 517 , 253 , $speed2) MouseDown( "Right") MouseMove( 447 ,301, $speed2) MouseDown( "Right") MouseMove( 397 ,311, $speed2) MouseUp("Right") WEnd EndFunc while 1 sleep (10) WEnd and the problem is following: If I hold down NumPad0 till it counts more than 100 times, then run the func with NumPad1, let it do 1 circle, and then hit NumPad0 to stop it, after running func4 with NumPad1 adlib won't work anymore. Why's that??? Don't know. Put $aaa = 0 at the start of func1, $bbb = 0 at the start of func 2, $ccc = 0 at the start of fun3 so that myadlib doesn't call them while they are still executing. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
sandin Posted August 25, 2007 Author Share Posted August 25, 2007 I've tried to make: $aaa = 0 in the beginning of the func, and: $aaa = 1 in the end of the func, and it's still the same. I even tried with AdlibDisable(), and AdlibEnable("myadlib", 10), in the beginning and the end of the func, but it's still the same. Adlib stops working... Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
sylvanie Posted August 25, 2007 Share Posted August 25, 2007 (edited) hello, you have too much infinte recursive while, and I noticed that it can make some trouble shoot with adlibenable the first while 1 give us the time to press 0 1 2, ok when you press 0 1 0 1 then you are calling 4 functions without terminating ones : 0: while 1 sleep - > 1 : while 1 ... -> 0 : wend while 1 etc ... wend so, a simple way to notice func4 that it has to terminate the while loop is to use a global, which is updated by the stop function : expandcollapse popup#include <GuiConstants.au3> #Include <Constants.au3> #include <Process.au3> #include <INet.au3> #include <misc.au3> hotkeyset("{NUMPAD0}", "STOPP") hotkeyset("{NUMPAD1}", "func4") hotkeyset("{NUMPAD2}", "end") Global $ggg Global $starttime1 Global $starttime2 Global $starttime3 Global $starttime4 Global $aaa Global $bbb Global $ccc Global $mmm Global $nnn Global $ooo Global $func4_is_running=0; global to notice func4 if it has to continue the loop or not $time = 5000;5 sec $starttime4=TimerInit() $time2 = 120000;2 min AdlibEnable("myadlib", 10) func myadlib () if $aaa=1 Then if TimerDiff($starttime1)>$time Then call ("func1") EndIf EndIf if $bbb=1 Then if TimerDiff($starttime2)>$time Then call ("func2") EndIf EndIf if $ccc=1 Then if TimerDiff($starttime3)>$time Then call ("func3") EndIf EndIf If TimerDiff($starttime4)>$time2 Then msgbox(262144, "time ended", "time ended, script will close now.") call ("end") EndIf EndFunc Func STOPP () $ggg += 1 TrayTip("notice", "you have called stop " & $ggg & " times.", 10) $aaa = 0 $bbb = 0 $ccc = 0 $func4_is_running=0; will notice func4 that it must terminate the current loop and exit EndFunc func end () Exit EndFunc func again () ;nothing EndFunc func func1 () $mmm += 1 sleep (1000) TrayTip('notice', 'You have called func1 ' & $mmm & ' times.', 10) $starttime1=TimerInit() EndFunc func func2 () $nnn += 1 sleep (1000) TrayTip('notice', 'You have called func2 ' & $nnn & ' times.', 10) $starttime2=TimerInit() EndFunc func func3 () $ooo += 1 sleep (1000) TrayTip('notice', 'You have called func3 ' & $ooo & ' times.', 10) $starttime3=TimerInit() EndFunc Func func4 () $func4_is_running=1 $break_while=1 call ("func1") $aaa = 1 call ("func2") $bbb = 1 call ("func3") $ccc = 1 $xkoordinata = 0 $ykoordinata = 0 $speed2 = 10 while $func4_is_running=1 call ("again") MouseDown( "Right") MouseMove(337, 299 , $speed2);you can test $func4_is_running before each action if you want to interrupt the loop before ending the current step MouseDown( "Right") MouseMove( 287 , 246 , $speed2) MouseDown( "Right") MouseMove( 432 , 246 , $speed2) MouseDown( "Right") MouseMove( 402 , 171 , $speed2) MouseDown( "Right") MouseMove( 467, 191, $speed2) MouseDown( "Right") MouseMove( 517 , 253 , $speed2) MouseDown( "Right") MouseMove( 447 ,301, $speed2) MouseDown( "Right") MouseMove( 397 ,311, $speed2) MouseUp("Right") WEnd EndFunc while 1 sleep (10) WEnd Edited August 25, 2007 by sylvanie Link to comment Share on other sites More sharing options...
sandin Posted August 25, 2007 Author Share Posted August 25, 2007 oh lol, thank you it works, but now it has diferent problem, now when I press NumPad0 for func4 to end I must w8 till func4 do full circle, so is there a way to make it end in the same time as I pressed Num0 (without waiting for fun4 to finish what it started)? Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 25, 2007 Moderators Share Posted August 25, 2007 Is this remotely similar to anything you are attempting (Just remembered it... it's been a while and I've slept once or twice since then )http://www.autoitscript.com/forum/index.ph...st&p=270164 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
sandin Posted August 26, 2007 Author Share Posted August 26, 2007 Is this remotely similar to anything you are attempting (Just remembered it... it's been a while and I've slept once or twice since then )http://www.autoitscript.com/forum/index.ph...st&p=270164this is very interesting script, but it's not what I was having in mind. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
sylvanie Posted August 26, 2007 Share Posted August 26, 2007 verify the value of $func4_is_running before each Mousedown while $func4_is_running=1 call ("again") if $func4_is_running=0 then exitloop MouseDown( "Right") MouseMove(337, 299 , $speed2);you can test $func4_is_running before each action if you want to interrupt the loop before ending the current step if $func4_is_running=0 then exitloop MouseDown( "Right") MouseMove( 287 , 246 , $speed2) if $func4_is_running=0 then exitloop MouseDown( "Right") MouseMove( 432 , 246 , $speed2) if $func4_is_running=0 then exitloop MouseDown( "Right") MouseMove( 402 , 171 , $speed2) .... WEnd Link to comment Share on other sites More sharing options...
sandin Posted August 26, 2007 Author Share Posted August 26, 2007 thank you it's perfect. how did u figure that out (about while recursion and adlib)? I would have never though of that... Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
therks Posted August 26, 2007 Share Posted August 26, 2007 That's not what Call() is for. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
sylvanie Posted August 26, 2007 Share Posted August 26, 2007 It s just a personnal observation. I have this problem with some scripts which include several infinite loop, or action which take 100% cpu. Now I don't know realy why this problem exists. Link to comment Share on other sites More sharing options...
sandin Posted August 26, 2007 Author Share Posted August 26, 2007 That's not what Call() is for.so, if I remove Call("again") func (which has nothing inside of it), I won't get recursion error after while $func4_is_running=1 makes ~383 loops? Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
therks Posted August 26, 2007 Share Posted August 26, 2007 Beats me. That's just not what Call() is for. Call is for calling functions with variable strings. If you want to call the function "MyFunc" use MyFunc(). Func MyFunc() MsgBox(0, 'MyFunc', 'Don''t use Call() for me.') EndFunc MyFunc() My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 26, 2007 Moderators Share Posted August 26, 2007 so, if I remove Call("again") func (which has nothing inside of it), I won't get recursion error after while $func4_is_running=1 makes ~383 loops?You'll still get the recursion error. Try placing a Return statement at the bottom of each function where the function would normally return and you'll not have to concern yourself with recursion (unless you keep calling the function from within itself). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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