Sign in to follow this  
Followers 0
Stephen89

_ispressed()

4 posts in this topic

hi i just want to know if i can do if _ispressed() statement that will just toggle when i press a key 2 times...

example if i press "{X}" key twice in 500 milli sec it will send "{Y}"

so if i just hold down "{X}" it shouldn't send "{Y}"

how can i do this?

Share this post


Link to post
Share on other sites



Stephen89,

Something along these lines should do the trick for you: :graduated:

#include <Misc.au3>

; Escape to exit
HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    DllClose($dll)
    Exit
EndFunc

$dll =DllOpen("user32.dll")

While 1

    ; Wait for X press
    If _IsPressed("58", $dll) Then
        ; Wait for X release
        While _IsPressed("58", $dll)
            Sleep(10)
        WEnd
        ; Clear flag
        $fDbl = False
        $iBegin = TimerInit()
        ; Wait for 500ms
        While TimerDiff($iBegin) < 500
            ; If X pressed again within the 500ms
            If _IsPressed("58", $dll) Then
                ConsoleWrite("XX" & @CRLF)
                ; Set flag
                $fDbl = True
                ; Wait for X release
                While _IsPressed("58", $dll)
                    Sleep(10)
                WEnd
                ; Leave the waiting loop
                ExitLoop
            EndIf
        WEnd
        ; If no second X within 500ms
        If $fDbl = False Then ConsoleWrite("X" & @CRLF)

    EndIf

WEnd

You will have to to change the ConsoleWrite lines to Send, of course. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Stephen89,

Something along these lines should do the trick for you: :graduated:

#include <Misc.au3>

; Escape to exit
HotKeySet("{ESC}", "On_Exit")
Func On_Exit()
    DllClose($dll)
    Exit
EndFunc

$dll =DllOpen("user32.dll")

While 1

    ; Wait for X press
    If _IsPressed("58", $dll) Then
        ; Wait for X release
        While _IsPressed("58", $dll)
            Sleep(10)
        WEnd
        ; Clear flag
        $fDbl = False
        $iBegin = TimerInit()
        ; Wait for 500ms
        While TimerDiff($iBegin) < 500
            ; If X pressed again within the 500ms
            If _IsPressed("58", $dll) Then
                ConsoleWrite("XX" & @CRLF)
                ; Set flag
                $fDbl = True
                ; Wait for X release
                While _IsPressed("58", $dll)
                    Sleep(10)
                WEnd
                ; Leave the waiting loop
                ExitLoop
            EndIf
        WEnd
        ; If no second X within 500ms
        If $fDbl = False Then ConsoleWrite("X" & @CRLF)

    EndIf

WEnd

You will have to to change the ConsoleWrite lines to Send, of course. :(

M23

thanks alot i will try it now and see if it works :D

Share this post


Link to post
Share on other sites

Stephen89,

i will try it now and see if it works

Of course it works or I would not have posted it. :graduated:

But it might not work exactly as you want - so by all means try it and see! :D

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :(


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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