Sign in to follow this  
Followers 0
r1se

hold a key to activate the script ?

4 posts in this topic

Hey !

i want to hold f to activate my script, when i release the button f, the script should be paused.

regards

Share this post


Link to post
Share on other sites



Hey !

i want to hold f to activate my script, when i release the button f, the script should be paused.

regards

mmm second thread and not much progress.

This is an AutoIt3 support forum, not a script request forum.

So, start reading and researching first and come back when you have a real question.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Like Jos says, please search the forums or read the helpfile.

But, have fun...

GUICreate("Keypress example", 100, 40)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
    EndSwitch

    If _IsPressed(46) Then
        ToolTip("Running", 0,0)
    Else
        ToolTip("Not Running", 0,0)
    EndIf
WEnd

Func _IsPressed($hexKey)
    $hexKey = DllCall("user32", "int", "GetAsyncKeyState", "int", '0x' & $hexKey)
    If Not @error And BitAND($hexKey[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc  ;==>_IsPressed

Edit: Typo.

Edited by Miniz

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hey !

i want to hold f to activate my script, when i release the button f, the script should be paused.

regards

Something like this i suppose.

#include <Misc.au3>
HotKeySet("f", "myFunction")

While 1
    Sleep(100)
WEnd

Func myFunction()
    If Not _IsPressed(46) Then Return
    While 1
        If Not _IsPressed(46) Then Return
        ConsoleWrite("F is still pressed" & @LF)
    WEnd
EndFunc   ;==>myFunction

EDIT:

actually that one aborts... not pauses...

Try this instead :-)

#include <Misc.au3>
HotKeySet("f", "myFunction")
HotKeySet("{ESC}", "_Exit")

While 1
    Sleep(100)
WEnd

Func myFunction()
    While 1
        _Pause() ;put this function before anything you do.
        ConsoleWrite("F is pressed" & @LF)
        Sleep(100)
    WEnd
EndFunc   ;==>myFunction

Func _Pause()
    If Not _IsPressed(46) Then ConsoleWrite("F released" & @LF)
    While Not _IsPressed(46)
        Sleep(100)
    WEnd
EndFunc   ;==>_Pause

Func _Exit()
    Exit
EndFunc   ;==>_Exit
Edited by Djarlo

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