Jump to content

Push one button and then another one react


Recommended Posts

I would like to make script like whenever you press button 1, wait 10 second and then send button 2

Below is my code

Global $Paused, $Runner

HotKeySet("{PAUSE}", "Pause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{F12}", "Start") 

While 1
    Sleep(100)
WEnd

Func Pause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func Start()
    $Runner = Not $Runner
    While $Runner

        ;if button 1 was push, wait 10 seconds and send button2 --> getting stuck here
        Sleep(10000)
        Send("{2}")

    WEnd
EndFunc
Link to comment
Share on other sites

I would like to make script like whenever you press button 1, wait 10 second and then send button 2

Below is my code

Global $Paused, $Runner

HotKeySet("{PAUSE}", "Pause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{F12}", "Start") 

While 1
    Sleep(100)
WEnd

Func Pause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func Start()
    $Runner = Not $Runner
    While $Runner

        ;if button 1 was push, wait 10 seconds and send button2 --> getting stuck here
        Sleep(10000)
        Send("{2}")

    WEnd
EndFunc
$GUI = GUICreate("TEST",400,400,-1,-1)
$B1 = GUICtrlCreateButton("No1",150,150,100,50)
$B2 = GUICtrlCreateButton("No2",150,250,100,50)
GUISetState()
While 1
     $MSG = GUIGetMsg()
     Switch $MSG
        Case -3
            Exit
        Case $B1
            TrayTip("","BUTTON 1 WAS PRESSED",3)
            SecondButton()
        Case $B2
            TrayTip("","BUTTON 2 WAS PRESSED",3)
    EndSwitch
WEnd

Func SecondButton()
    Sleep(10000)
    ControlClick("TEST","",$B2)
EndFunc

When the words fail... music speaks.

Link to comment
Share on other sites

$GUI = GUICreate("TEST",400,400,-1,-1)
$B1 = GUICtrlCreateButton("No1",150,150,100,50)
$B2 = GUICtrlCreateButton("No2",150,250,100,50)
GUISetState()
While 1
     $MSG = GUIGetMsg()
     Switch $MSG
        Case -3
            Exit
        Case $B1
            TrayTip("","BUTTON 1 WAS PRESSED",3)
            SecondButton()
        Case $B2
            TrayTip("","BUTTON 2 WAS PRESSED",3)
    EndSwitch
WEnd

Func SecondButton()
    Sleep(10000)
    ControlClick("TEST","",$B2)
EndFunc

Thanks but I dont mean graphic button. They are button number on keyboard. Can you please help me ?

Link to comment
Share on other sites

Thanks but I dont mean graphic button. They are button number on keyboard. Can you please help me ?

If you press TAB key after 10 sec script send A.

If you press ESC key then Exit.

#include <Misc.au3>

While 1
    If _IsPressed("09") Then
        Sleep(10000)
        Send("A")
    ElseIf _IsPressed("1B") Then
        Exit
    EndIf
    Sleep(15)
WEnd
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

If you press TAB key after 10 sec script send A.

If you press ESC key then Exit.

#include <Misc.au3>

While 1
    If _IsPressed("09") Then
        Sleep(10000)
        Send("A")
    ElseIf _IsPressed("1B") Then
        Exit
    EndIf
    Sleep(15)
WEnd
Great. By the way how can you get the value TAB is 09? Is there any website to list all those value? Edited by Fabroni
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...