Fi0da Posted April 13, 2010 Posted April 13, 2010 (edited) Hello Masters! I was maked an script and i need 2 funcions together. The 1st where the mouse draws an Web.Its a simple didactic application. While mouse draws it i want the countdown always active. Well...when i press F6 the mouse draws ...but if i press F8, it stop and the countdown run. When i press F6 again, mouse moves again but countdown stop I believe that I'm not getting because of the function "While" in the countdown function I searched the help for a way to make the timer run without "While", but I do not think wheel. I appreciate if any of the patients and attentive ScriptMasters gives a solution. expandcollapse popup; <AUT2EXE VERSION: 3.1.1.0> ; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-START: C:\Program Files\AutoIt3\Include\GUIConstants.au3> ; ---------------------------------------------------------------------------- ; ------------------------------------------------------------------------------ ; ; AutoIt Version: 3.1.0 ; Language: English ; Description: Constants to be used in GUI applications. ; ; ------------------------------------------------------------------------------ ; Events and messages Global Const $GUI_EVENT_CLOSE = -3 ; == GUI generated with Koda == $Form1 = GUICreate("The Spider's WEB", 455, 303, 300, 100) GUISetFont(14, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("F6 Start WEB", 16, 48, 174, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("F7 Pause", 16, 80, 84, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("F8 CountDown", 16, 112,198, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("Numpad 8 Distance Up", 16, 144, 198, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("Numpad 5 Distance Down", 16, 232, 223, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $GUIDistance = GUICtrlCreateLabel("150", 120, 184, 34, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlCreateLabel("Distance =", 16, 186, 80, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) ; HotKeySet("{F6}", "PaintStar") HotKeySet("{F7}", "Pause") HotKeySet("{F8}", "CountDown") HotKeySet("{NUMPAD8}", "DistanceUp") HotKeySet("{NUMPAD5}", "DistanceDown") HotKeySet ("{PgUp}", "IntervalUp") HotKeySet ("{PgDn}", "IntervalDown") HotKeySet ("{Pause}","Stop") Global $EventType; False = lose, True = win Global $EventName[2] = ["Limpa", "Limpa_2"] $LimpaIntervalo = 10000 ; milliseconds $Timerinit = TimerInit();start timer Global $x Global $y Global $Distance = 150 func PaintStar () $pos = MouseGetPos () $x = $pos[0] $y = $pos[1] Call("WAP") EndFunc func WAP () While 1 MouseDown("Left") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x, $y - $Distance) Sleep(25) Send(" ") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x + $Distance/1.3636363, $y - $Distance/1.3636363) Sleep(25) Send(" ") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x + $Distance, $y) Sleep(25) Send(" ") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x + $Distance/1.3636363, $y + $Distance/1.3636363) Sleep(25) Send(" ") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x, $y + $Distance) Sleep(25) Send(" ") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x - $Distance/1.3636363, $y + $Distance/1.3636363) Sleep(25) Send(" ") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x - $Distance, $y) Sleep(25) Send(" ") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x - $Distance/1.3636363, $y - $Distance/1.3636363) Sleep(25) Send(" ") MouseMove($x, $y) Sleep(25) Send(" ") MouseMove($x - $Distance, $y) Sleep(100) Send(" ") MouseMove($x - $Distance/1.3636363, $y - $Distance/1.3636363) Sleep(100) Send(" ") MouseMove($x, $y - $Distance) Sleep(100) Send(" ") MouseMove($x + $Distance/1.3636363, $y - $Distance/1.3636363) Sleep(100) Send(" ") MouseMove($x + $Distance, $y) Sleep(100) Send(" ") MouseMove($x + $Distance/1.3636363, $y + $Distance/1.3636363) Sleep(100) Send(" ") MouseMove($x, $y + $Distance) Sleep(100) Send(" ") MouseMove($x - $Distance/1.3636363, $y + $Distance/1.3636363) Sleep(100) Send(" ") MouseMove($x - $Distance, $y) Sleep(25) Send(" ") MouseMove($x - $Distance/2, $y) Sleep(100) Send(" ") MouseMove($x - ($Distance/1.3636363)/2, $y - ($Distance/1.3636363)/2) Sleep(100) Send(" ") MouseMove($x, $y - $Distance/2) Sleep(100) Send(" ") MouseMove($x + ($Distance/1.3636363)/2, $y - ($Distance/1.3636363)/2) Sleep(100) Send(" ") MouseMove($x + $Distance/2, $y) Sleep(100) Send(" ") MouseMove($x + ($Distance/1.3636363)/2, $y + ($Distance/1.3636363)/2) Sleep(100) Send(" ") MouseMove($x, $y + $Distance/2) Sleep(100) Send(" ") MouseMove($x - ($Distance/1.3636363)/2, $y + ($Distance/1.3636363)/2) Sleep(100) Send(" ") MouseMove($x - $Distance/2, $y) MouseUp("Left") WEnd EndFunc func Pause () While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd EndFunc func DistanceUp () $Distance = $Distance + 5 GUiCtrlSetData($GUIDistance, $Distance) ToolTip("Distance is " & $Distance, 0, 0) Sleep(500) ToolTip("") EndFunc Func DistanceDown () If $Distance > 0 Then $Distance = $Distance - 5 GUICtrlSetData($GUIDistance, $Distance) ToolTip("Distance is " & $Distance, 0, 0) Sleep(500) ToolTip("") EndFunc While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Func CountDown () While 1 $Time = TimerDiff($TimerInit) Tooltip("Seconds until close " & $EventName[$EventType] & ": " & Round(($LimpaIntervalo - $Time)/1000), 10, 10) If $EventName = ("Limpa") Then MsgBox (4096,"Limpa","You Loooose") ElseIf $EventName = ("Limpa_2") Then MsgBox (4096,"Limpa","You Win :)") EndIf If $Time > $LimpaIntervalo Then $Timerinit = TimerInit();reset timer Call($EventName[$EventType]) $EventType = Not $EventType Sleep(350) EndIf Wend EndFunc;>>>>>Exit ;------------------------------------------------------------------------------- func IntervalUp () $LimpaIntervalo = $LimpaIntervalo*3 $Time = TimerDiff($TimerInit) $Timerinit = Timerinit ();reset timer ToolTip("Time add is " & $Time,0,0) Sleep(500) ToolTip("") EndFunc Func IntervalDown () $LimpaIntervalo = $LimpaIntervalo/3 $Time = TimerDiff($TimerInit) $Timerinit = Timerinit ();reset timer ToolTip("Time loss is " & $Time,0,0) Sleep(500) ToolTip("") EndFunc Func Stop () Exit EndFunc Best Reggards Edited April 13, 2010 by Fi0da I read ... I update ... I learn ...
PsaltyDS Posted April 13, 2010 Posted April 13, 2010 Look at AdLibRegister() in the help file. It can periodically interrupt your script to do something (like update a timer) and then returns control to the script right where it left off. 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
MHz Posted April 13, 2010 Posted April 13, 2010 Or AdlibEnable() if you want to continue running AutoIt 3.1.0. If you are going to use the latest version of AutoIt 3.3.6.0, note that you will lose the decompile option so you may need to backup your source.
Fi0da Posted April 14, 2010 Author Posted April 14, 2010 @PsaltyDS thankyou for u fast reply...iv got v3.3.6 but i preffer steel in beta V3.1 grats.Or AdlibEnable() if you want to continue running AutoIt 3.1.0. MHz ill continue running 3.1.0 ...im fammilyarized whit it.Now...i saw in Help and examples but sorry...i dont know how to do it run.Can u edit a simple example ???when the F8 is press, I need that CountDown running together mouse movments.I Aprecciate anny reply.Tkx All I read ... I update ... I learn ...
PsaltyDS Posted April 14, 2010 Posted April 14, 2010 ...iv got v3.3.6 but i preffer steel in beta V3.1Keeping your scripts on a 5.25" floppy and running them on Windows 98ME? 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
Fi0da Posted April 14, 2010 Author Posted April 14, 2010 Keeping your scripts on a 5.25" floppy and running them on Windows 98ME? No:)...im run in MSX Man...i just told this cose this new vers dont have "Decompile"Perhaps ill try get 2 versions...3.3 for Edite and Built and 3.1 for decomp.Then backing to my Script..... I read ... I update ... I learn ...
GEOSoft Posted April 14, 2010 Posted April 14, 2010 (edited) here is just a suggestion. If you have a need to decompile your own code (that means bad planning right from the start) Then do that now, update all the source code that will have to change and then put them away safely as scripts so decompiling is never an issue. If on the other hand, you use decompile on other people code, you will find yourself very unwelcome around here in exceptionally short order. Edited April 14, 2010 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Fi0da Posted April 15, 2010 Author Posted April 15, 2010 Dear GEO Yes..i dont remember this... When i make an Script and compile it, really i have the writed together whit the .exe. Just Sry for that reply...my intention wasn't that. I Dont decompile annother people code...i just wanna solve mine source on the main post ...Waiting for a serious member... I read ... I update ... I learn ...
GEOSoft Posted April 15, 2010 Posted April 15, 2010 Dear GEOYes..i dont remember this...When i make an Script and compile it, really i have the writed together whit the .exe.Just Sry for that reply...my intention wasn't that.I Dont decompile annother people code...i just wanna solve mine source on the main post...Waiting for a serious member...Then do as I mentioned. Decompile all of your scripts and save then as au3 files then put them away someplace. Depending on being able to decompile the source is a very bad backup strategy and IMHO it's no backup strategy at all. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
MHz Posted April 15, 2010 Posted April 15, 2010 (edited) MHz ill continue running 3.1.0 ...im fammilyarized whit it. Now...i saw in Help and examples but sorry...i dont know how to do it run. Can u edit a simple example ??? when the F8 is press, I need that CountDown running together mouse movments. Using Adlibenable() is easy once you understand it so clear your mind. This is a basic structure with comments of how adlib works. I put priority on comments rather then working code of demonstration. ; this script should flow freely and the working function does its task ; call Adlibenable to run adlib function to run every 500 ms Adlibenable('_adlib_function', 500) ; script continues while _adlib_function() is also running periodically ; call this function to start main action _This_Is_The_Working_Function() ; now we can turn off _adlib_function running by using AdlibDisable() Adlibdisable() Exit Func _adlib_function() ; only non blocking code witch runs every X ms as defined ; do your counter within here. No loops, no Msgbox etc which block EndFunc Func _This_Is_The_Working_Function() ; This is the main block of code do what you want EndFunc Points to remember: Adlibenable runs a function every X ms as defined. Each time the adlib functionality runs, the main script pauses while the code in your adlib function runs, so no blocking functions to ensure smooth running of your script.You can only have 1 adlib function at once. You can use latest AutoIt version for improved and renamed AdlibRegister() which does more.Use AdlibDisable() to stop adlib functionality and continue as normal with the script.Use AutoIt 3.1.0 as long as you like though support maybe limited as we usually use the latest version here. Edit: Minor corrections Edited April 15, 2010 by MHz
Fi0da Posted April 15, 2010 Author Posted April 15, 2010 Very good .... It worked as I wanted:) Also, I liked this new version did an improvisation that worked right. I thank all who contributed and contribute to helping beginners. The way you explain the functions gives the learner "Thinking" in creating I'll continue reading the new posts and new doubts. Congrats to Admin I read ... I update ... I learn ...
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