Jump to content
Sign in to follow this  
Fabroni

Push one button and then another one react

Recommended Posts

Fabroni

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

Share this post


Link to post
Share on other sites
Andreik

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

Share this post


Link to post
Share on other sites
Fabroni

$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 ?

Share this post


Link to post
Share on other sites
Andreik

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

Share this post


Link to post
Share on other sites
Fabroni

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

Share this post


Link to post
Share on other sites
Andreik

1B is ESC key to exit from script. Look in help file about _IsPressed().


When the words fail... music speaks

Share this post


Link to post
Share on other sites
Fabroni

1B is ESC key to exit from script. Look in help file about _IsPressed().

Thank you so much!

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.