Tearlow Posted May 1, 2009 Share Posted May 1, 2009 Hey there people- Been fiddling around with this for a while now but think I need some help to figure it out. I've simply removed most of the functions just to keep it as short as possibly, but this is what the macro is doing- Sending Keystrokes every XXXX seconds. But how on earth would I make the Timer a Constant countdown rather then update every loop? If at all that is... expandcollapse popupAutoItSetOption("MustDeclareVars", 1) HotKeySet("!1", "Test") HotKeySet("!2", "Quit") Dim $i, $Time_Left, $delay, $to, $sleep_i, $time_to_i, $sleep_press, $mindelay, $secs, $Mins, $hours, $secs_Display, $mins_Display, $hours_Display $to = 10; How many times to Repeate $sleep_i = 3500; Interval per Repeate $sleep_press = 50; Sleep per key while 1 ToolTip("IDLE...", -1, -1) sleep(1000) WEnd Func Test() ToolTip("SCRIPT STARTING...", -1, -1) $i = 0 $delay = $sleep_i+$sleep_press; Calculate the time. $mindelay = 0 $time_to_i = Round((($delay+$mindelay)*$to)/1000) $secs = $time_to_i $Mins = Int($secs / 60) $hours = Int($Mins / 60) $secs_Display = $secs - ($Mins * 60) $mins_Display = $Mins - ($hours * 60) $hours_Display = $hours - ($Mins * 60) Do ToolTip("Done in : "&$hours&"h "&$mins_Display&"m "&$secs_Display&"s [Done "&$i&" / "&$to&" ("&($to-$i)&" left)]", -1, -1) sleep($sleep_i) Send("{q down}");Holds the Q key down sleep($sleep_press) Send("{q up}");Releases the Q key $time_to_i = Round($time_to_i-(($delay+$mindelay)/1000)) $secs = $time_to_i $Mins = Int($secs / 60) $hours = Int($Mins / 60) $secs_Display = $secs - ($Mins * 60) $mins_Display = $Mins - ($hours * 60) $hours_Display = $hours - ($Mins * 60) Sleep($mindelay) $i = $i + 1 Until $i = $to SoundPlay(@WindowsDir & "\media\tada.wav",1) EndFunc Func Quit() exit 0 EndFunc I do know that this code is quite messy and I'am going to clean it up quite abit! Thanks in advance Link to comment Share on other sites More sharing options...
exodius Posted May 1, 2009 Share Posted May 1, 2009 Use a For...Next loop?For $x = 10 to 1 Step -1 ToolTip ("Counting down: " & $x, 0, 0) Sleep (500) Next ToolTip ("") SoundPlay(@WindowsDir & "\media\tada.wav",1) MsgBox (0, "Done!", "We're done!") Link to comment Share on other sites More sharing options...
BrettF Posted May 1, 2009 Share Posted May 1, 2009 I'm not totally sure I know what you want. Something like this is simple... It runs for around 5 seconds, pressing the key 20 times in that period. $total_time = 5*1000; = 5 seconds $total_keypress = 20 $current_keypress = 0 $timer = TimerInit() While 1 If $current_keypress > $total_keypress Then Exit If TimerDiff ($timer) > ($total_time/$total_keypress) Then $timer = TimerInit () Send ("A") $current_keypress += 1 EndIf WEnd Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Tearlow Posted May 1, 2009 Author Share Posted May 1, 2009 (edited) Ack, Im terribly sorry for not explaining better then I did! Well, If you run the Script you'll see that it Repeats $to (This is the loop) and $sleep_i + $sleep_press is the actuall delay So that makes up 3550ms per repeate right? So each time the loop is completed it makes a new Tooltip (3550ms per update) appear with the remaining time, this is something I'd wanna see as a constant countdown- The tooltip is in the upper corner between. Hope that more sense... EDIT: What is the BB Code for AutoIT Codebox? Did not find that in the help.. Edited May 1, 2009 by Tearlow 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