Jump to content

Not HotKey, but HotButton


DaLiMan
 Share

Recommended Posts

See the help file for GUI examples.

You can make a script that performs an action when you click on a button.

<{POST_SNAPBACK}>

Yes I know that,

but what I want is press a button and then stop this process until another button is pressed in a single GUI which is always on top.

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop

    Case $msg = $Button_12
    ; do stuff until button_13 is pressed

    Case $msg = $Button_13
    ;
    Case Else
    ;;;
    EndSelect
WEnd
Exit
Link to comment
Share on other sites

Here's an example.

#include <GUIConstants.au3>
GUICreate('New GUI')
$Button_12 = GUICtrlCreateButton("Button_12", 50, 10, 70, 25)
$Button_13 = GUICtrlCreateButton("Button_13", 150, 10, 70, 25)
GUISetState()

Dim $x = 0
Dim $Busy = 0

While 1
    Sleep(100)
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        GUIDelete()
        ExitLoop
    Case $msg = $Button_13
        If $Busy Then $Busy = NOT $Busy
        $x = -1
    
    Case $msg = $Button_12 OR $Busy
        If NOT $Busy Then $Busy = 1
       ; do stuff until button_13 is pressed
        $x = $x + 1
        ToolTip("$x = " & $x)
        Sleep(100)
        
    Case Else
       ;;;
        
    EndSelect
WEnd
Link to comment
Share on other sites

Great thanx,

I can rebuild from here..... :lmao:

Question:

Must button13 come before the rest? 

BTW: It's not 100% proof is it?

I found several times I needed to click Button13 twice or three times before it stopped.

<{POST_SNAPBACK}>

Try to remove the Sleep(100).

That should do the job.

Link to comment
Share on other sites

Try this out.

#include <GUIConstants.au3>
GUICreate('New GUI')
$Button_12 = GUICtrlCreateButton("Button_12", 50, 10, 70, 25)
$Button_13 = GUICtrlCreateButton("Button_13", 150, 10, 70, 25)
GUISetState()

Dim $x = 0
Dim $Busy = 0

While 1
    Sleep(100)
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        GUIDelete()
        ExitLoop
    Case $msg = $Button_13
        If $Busy Then $Busy = NOT $Busy
        $x = -1
    
    Case $msg = $Button_12 OR $Busy
       Call("_dountilbutton_13ispressed")
        $x = $x + 1
        ToolTip("$x = " & $x)
        Sleep(100)
        
    Case Else
      ;;;
        
    EndSelect
WEnd
Func _dountilbutton_13ispressed()
    Do
       If NOT $Busy Then $Busy = 1
       EndIf
   Until $msg = $button_13
EndFunc

I hope this works.

.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...