Jump to content
spuuunit

If double click / double tap

Recommended Posts

spuuunit

I'm trying to make a script that detects if I double click or double tap a key. This is the closest I get, when I double tap "P" (_IsPressed("50")). It only seems to work if I switch to different keys for some reason.
 

#include <Misc.au3>
$hDLL = DllOpen("user32.dll")
$count = 0


While 1
    If _IsPressed("50", $hDLL) Then
        While $count < 40
            $count += 1
            If _IsPressed("50", $hDLL) Then
                MsgBox(0, "Double", "Double click / tap !")
                $count = 10000
            EndIf
            Sleep(1)
        WEnd
        $count = 0
    EndIf
    Sleep(1)
WEnd

Any ideas how this can be done? For example, detect when I double tap "P".

Edited by spuuunit

Share this post


Link to post
Share on other sites
JLogan3o13

Your question is a bit vague - double click where? on what? If, for example, you want to detect a double click on a GUI button, you would do something like this:

If you're looking more for capturing a double click in a specific area like an input field, you may try something like this:

If those don't help, perhaps you could provide more information on exactly what you are trying to do, along with what you have tried on your own already. As an aside, these threads, along with many, many others, were brought up through a relatively simply forum search. You should always do such a search before posting a question.

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
spuuunit

I'm sorry I didn't cleared that out - I'm tying to capture it anywhere, allways. I tried the examples in the links, but since they're only for a self created interface, it's not what I'm looking for.

Share this post


Link to post
Share on other sites
Melba23

spuuunit,

This works for me:

#include <Misc.au3>
#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", "_Exit")

$iPeriod = 100 ; Set limit for double tap interval

$hDLL = DllOpen("user32.dll")

While 1
    ; If "p" pressed
    If _IsPressed("50", $hDLL) Then
        ; Wait for it to be released
        While _IsPressed("50", $hDLL)
            Sleep(10)
        WEnd
        ; Start a timer
        $nBegin = TimerInit()
        ; Wait for set period
        Do
            ; If pressed again
            If _IsPressed("50", $hDLL) Then
                MsgBox($MB_SYSTEMMODAL, "Hi", "Double tap")
                ExitLoop
            EndIf
            Sleep(10)
        Until TimerDiff($nBegin) > 100
    EndIf

WEnd

Func _Exit()
    Exit
EndFunc

But if you want to expand it to look for more keys, please read this announcement before posting any code:

I know it is not what you are doing, but the restriction still applies.

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
spuuunit

Thanks Melba23, works like a charm. :)

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

×