Jump to content

If double click / double tap


Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...