Kreatorul Posted October 17, 2006 Share Posted October 17, 2006 How can I make a control wait a few seconds before i let him continue his job? If I use sleep it pauses the whole script and I don't want that...any other way around? Sorry for asking for help this often but i'm not the best learner Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 17, 2006 Share Posted October 17, 2006 How can I make a control wait a few seconds before i let him continue his job?If I use sleep it pauses the whole script and I don't want that...any other way around?Sorry for asking for help this often but i'm not the best learner You can use GuiCtrlSetState() with $GUI_ENABLE/$GUI_DISABLE. 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...
Kreatorul Posted October 17, 2006 Author Share Posted October 17, 2006 And where I set the sleep time? I want something like a Sleep(random(1000,4000) but not pause the whole script and with guictrlsetstate I can't do that... Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 17, 2006 Share Posted October 17, 2006 And where I set the sleep time? I want something like a Sleep(random(1000,4000) but not pause the whole script and with guictrlsetstate I can't do that...You can't in a single command. I think I would toggle the Enable/Disable state with a function, and call that function with an AdlibEnable(). This would allow the rest of the script to continue as normal. 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...
Kreatorul Posted October 17, 2006 Author Share Posted October 17, 2006 (edited) Still couldn't do this by calling a function with adlibenable and guictrlsetstate but I thought of a better solution for what I want to do but this doesen't work either. I tryed to put the button with the coordinates random(0, -1000) verticaly because it's a button that falls down for a game . Any way to make it work with this coordonates? Like this it would take a little bit more time to fall down. Edited October 17, 2006 by Kreatorul Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 17, 2006 Share Posted October 17, 2006 Still couldn't do this by calling a function with adlibenable and guictrlsetstate but I thought of a better solution for what I want to do but this doesen't work either. I tryed to put the button with the coordinates random(0, -1000) verticaly because it's a button that falls down for a game . Any way to make it work with this coordonates? Like this it would take a little bit more time to fall down.Post some code so we can see what you are talking about. GuiCtrlSetState() will find the control regardless of it's coordinates, because it uses the control ID, which doesn't change. At least, it doesn't change unless you are deleting/recreating the button... you should be moving it with GuiCtrlSetPos(). "...I thought of a better solution for what I want to do but this doesen't work either." As Mr. Montoya would say in Princess Bride: "That word, 'better' - I don't think it means what you think it means!" 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...
Kreatorul Posted October 17, 2006 Author Share Posted October 17, 2006 I am moving it with GuiSetPosition Here is the code expandcollapse popup#include <GuiConstants.au3> #Include <Misc.au3> $window = GUICreate("Game", 500, 500) ;Vars: $can=GuiCtrlCreateButton("Lada", 270, 450, 80, 50) $pica=GuiCtrlCreateButton("Cade", 450, 20) $pica2=GuiCtrlCreateButton("Cade alta", 350, 10) GuiCtrlCreateLabel("You Scored:", 10, 5) $score=GuiCtrlCreateLabel("0", 70, 5) GuiSetState() While 1 $posc=ControlGetPos("Game", "", $can) $posp=ControlGetPos("Game", "", $pica) $posp2=ControlGetPos("Game", "", $pica2) $msg=GuiGetMsg() If $msg=$Gui_event_close Then Exit If _Ispressed("27") Then GuiCtrlSetPos($can, $posc[0]+5, $posc[1]) If _Ispressed("25") Then GuiCtrlSetPos($can, $posc[0]-5, $posc[1]) GuiCtrlSetPos($pica, $posp[0], $posp[1]+random(1, 1.5)) If $posp[1]=500 Then GuiCtrlSetPos($pica, random(0, 470), 0) EndIf if Intersection($window, $can, $pica) Then GuiCtrlSetPos($pica, random(0, 470), random(0, -500)) GuiCtrlSetData($score, GuiCtrlRead($score) + 1) EndIf GuiCtrlSetPos($pica2, $posp2[0], $posp2[1]+random(1, 1.5)) If $posp2[1]=500 Then GuiCtrlSetPos($pica2, random(0, 470), 0) EndIf if Intersection($window, $can, $pica2) Then GuiCtrlSetPos($pica2, random(0, 470), random(0, -500)) GuiCtrlSetData($score, GuiCtrlRead($score) + 1) Sleep(10) EndIf Wend Func Intersection($hWnd, $nControl1, $nControl2) ;True if they have intersected in any way. $rect1 = ControlGetPos($hWnd, "", $nControl1) $rect2 = ControlGetPos($hWnd, "", $nControl2) if ((($rect1[0] < ($rect2[0]+$rect2[2])) and ($rect2[0] < ($rect1[0]+$rect1[2])) and ($rect1[1] < ($rect2[1] + $rect2[3])))) Then Return ($rect2[1] < ($rect1[1]+$rect1[3])) Else Return False EndIf EndFunc 10x man, I apreciate your help 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