Sign in to follow this  
Followers 0
Kreatorul

Pause a control?

7 posts in this topic

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 :geek: but i'm not the best learner :lmao::ph34r:

Share this post


Link to post
Share on other sites



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 :geek: but i'm not the best learner :lmao::ph34r:

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

Share this post


Link to post
Share on other sites

And where I set the sleep time? :lmao:

I want something like a Sleep(random(1000,4000) but not pause the whole script and with guictrlsetstate I can't do that...

Share this post


Link to post
Share on other sites

And where I set the sleep time? :lmao:

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.

:ph34r:


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 :lmao:. Any way to make it work with this coordonates? :ph34r: Like this it would take a little bit more time to fall down.

Edited by Kreatorul

Share this post


Link to post
Share on other sites

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 :geek:. Any way to make it work with this coordonates? :ph34r: 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."

:ph34r: As Mr. Montoya would say in Princess Bride: "That word, 'better' - I don't think it means what you think it means!" :lmao:


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

Share this post


Link to post
Share on other sites

I am moving it with GuiSetPosition :lmao: Here is the code

#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 :ph34r:

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0