Wurschtbrot Posted January 16, 2008 Share Posted January 16, 2008 (edited) well i want to klick some keys every XY Second's therefor i made a little script: expandcollapse popupOpt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Unbenannt - Editor","") If Not WinActive("Unbenannt - Editor","") Then WinActivate("Unbenannt - Editor","") WinWaitActive("Unbenannt - Editor","") Global $REDCooldown1 = 1000 Global $REDCooldown1Temp Global $REDCooldown2 = 2000 Global $REDCooldown2Temp Global $REDCooldown3 = 3000 Global $REDCooldown3Temp Global $REDCooldown4 = 4000 Global $REDCooldown4Temp While 1 If $REDCooldown4 <= TimerDiff($REDCooldown4Temp) Then Send("4") $REDCooldown4Temp = TimerInit() EndIf If $REDCooldown3 <= TimerDiff($REDCooldown3Temp) Then Send("3") $REDCooldown3Temp = TimerInit() EndIf If $REDCooldown2 <= TimerDiff($REDCooldown2Temp) Then Send("2") $REDCooldown2Temp = TimerInit() EndIf If $REDCooldown1 <= TimerDiff($REDCooldown1Temp) Then Send("1") $REDCooldown1Temp = TimerInit() EndIf Sleep(250) WEnd of wich i think it will work do i need to set "Global $REDCooldown4Temp = TimerInit()" or can it be without = TimerInit() this is simplyfied versin of the original and here i dont have the problem any one noticed that he sends all at once sometimes ? its not like the accidently match the time its more like the time resets or rises irrational and all funcs are clear to go maybe there is a better way to do it ? Edited January 16, 2008 by Wurschtbrot Link to comment Share on other sites More sharing options...
Aceguy Posted January 16, 2008 Share Posted January 16, 2008 why not do send(key) sleep(1000) send(new key) sleep(1000) send (new key) sleep(1000) until 1=0 [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
Wurschtbrot Posted January 16, 2008 Author Share Posted January 16, 2008 why not dosend(key)sleep(1000)send(new key)sleep(1000)send (new key)sleep(1000)until 1=0this is a func i call it when i want one of the keys pressed (wichever one is avalible again ) then as fast as possible return to the old func and continue other stuffthen after all other funcs are colled he calles this one again ....if i use sleep the script will pause! i need it more like simultanius (sametime) to other stuffi cannot make it into another autoit exe since i only need it sometimes....with these keys i activate Skills wich have a time Limit (can only be used every 7sec or something ) and i only want to use em as long as i attack the ennemy Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 16, 2008 Share Posted January 16, 2008 Much better way to do this: expandcollapse popupHotKeySet("{ESC}", "_Quit") Global $REDCooldown1 = 1000 Global $REDCooldown1Temp = TimerInit() Global $REDCooldown2 = 2000 Global $REDCooldown2Temp = TimerInit() Global $REDCooldown3 = 3000 Global $REDCooldown3Temp = TimerInit() Global $REDCooldown4 = 4000 Global $REDCooldown4Temp = TimerInit() ; Open notepad to monitor test Run("notepad.exe") WinWait("Untitled - Notepad") $hWin = WinGetHandle("Untitled - Notepad") If Not WinActive($hWin) Then WinActivate($hWin) WinWaitActive($hWin) ; Check timer status every 100ms AdlibEnable("_TimerDispatch", 100) ; Script could be busy doing other things here... While 1 Sleep(20) WEnd ; Function to perform timed operations Func _TimerDispatch() If $REDCooldown4 <= TimerDiff($REDCooldown4Temp) Then ControlSend($hWin, "", "Edit1", "4{ENTER}") $REDCooldown4Temp = TimerInit() EndIf If $REDCooldown3 <= TimerDiff($REDCooldown3Temp) Then ControlSend($hWin, "", "Edit1", "3{ENTER}") $REDCooldown3Temp = TimerInit() EndIf If $REDCooldown2 <= TimerDiff($REDCooldown2Temp) Then ControlSend($hWin, "", "Edit1", "2{ENTER}") $REDCooldown2Temp = TimerInit() EndIf If $REDCooldown1 <= TimerDiff($REDCooldown1Temp) Then ControlSend($hWin, "", "Edit1", "1{ENTER}") $REDCooldown1Temp = TimerInit() EndIf EndFunc ;==>_TimerDispatch ; Function to kill script Func _Quit() Exit EndFunc ;==>_Quit Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Wurschtbrot Posted January 16, 2008 Author Share Posted January 16, 2008 Much better way to do this: expandcollapse popupHotKeySet("{ESC}", "_Quit") Global $REDCooldown1 = 1000 Global $REDCooldown1Temp = TimerInit() Global $REDCooldown2 = 2000 Global $REDCooldown2Temp = TimerInit() Global $REDCooldown3 = 3000 Global $REDCooldown3Temp = TimerInit() Global $REDCooldown4 = 4000 Global $REDCooldown4Temp = TimerInit() ; Open notepad to monitor test Run("notepad.exe") WinWait("Untitled - Notepad") $hWin = WinGetHandle("Untitled - Notepad") If Not WinActive($hWin) Then WinActivate($hWin) WinWaitActive($hWin) ; Check timer status every 100ms ; Function to perform timed operations Func _TimerDispatch() If $REDCooldown4 <= TimerDiff($REDCooldown4Temp) Then ControlSend($hWin, "", "Edit1", "4{ENTER}") $REDCooldown4Temp = TimerInit() EndIf If $REDCooldown3 <= TimerDiff($REDCooldown3Temp) Then ControlSend($hWin, "", "Edit1", "3{ENTER}") $REDCooldown3Temp = TimerInit() EndIf If $REDCooldown2 <= TimerDiff($REDCooldown2Temp) Then ControlSend($hWin, "", "Edit1", "2{ENTER}") $REDCooldown2Temp = TimerInit() EndIf If $REDCooldown1 <= TimerDiff($REDCooldown1Temp) Then ControlSend($hWin, "", "Edit1", "1{ENTER}") $REDCooldown1Temp = TimerInit() EndIf EndFunc ;==>_TimerDispatch ; Function to kill script Func _Quit() Exit EndFunc ;==>_Quit omg ! this is perfect for a LOT of things i have to rewrite my whole script XD if i use it like this : While 1 blah x AdlibEnable("_TimerDispatch", 100) Sleep(20) msgbox() AdlibDisable("_TimerDispatch") Blah y WEnd then it would only run the func while sleep 20 and msg box parallel to the script in between and i guess i can make as many AdlibEnable()'s as i want ? like running 2-3 or more Funcs at once ? Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 16, 2008 Share Posted January 16, 2008 if i use it like this : While 1 blah x AdlibEnable("_TimerDispatch", 100) Sleep(20) msgbox() AdlibDisable("_TimerDispatch") Blah y WEnd then it would only run the func while sleep 20 and msg box parallel to the script in between and i guess i can make as many AdlibEnable()'s as i want ? like running 2-3 or more Funcs at once ? No. AutoIt is not multi threaded, and MsgBox() is a "blocking" function. Nothing else will happen while the message box is up: Global $n = 0 While $n < 5 AdlibEnable("_TimerDispatch", 100) Sleep(20) MsgBox(64, "Test", "Test") AdlibDisable() WEnd Func _TimerDispatch() ConsoleWrite("Debug: $n = " & $n & @LF) $n += 1 EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Wurschtbrot Posted January 16, 2008 Author Share Posted January 16, 2008 No. AutoIt is not multi threaded, and MsgBox() is a "blocking" function. Nothing else will happen while the message box is up: Global $n = 0 While $n < 5 AdlibEnable("_TimerDispatch", 100) Sleep(20) MsgBox(64, "Test", "Test") AdlibDisable() WEnd Func _TimerDispatch() ConsoleWrite("Debug: $n = " & $n & @LF) $n += 1 EndFunc damn well i only have 1 input box 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