Jump to content

detect doublce click


Recommended Posts

I am trying to write a script which detect double click, so I use the following example to learn how to do it.

#include <Misc.au3>
#include <Math.au3>
#include <Timers.au3>
$dll = DllOpen("user32.dll")
While 1
    If _isPressed("1", $dll) Then

     Local $LeftMouseClickTime = _Timer_Init()
        While Not _isPressed("1", $dll)
            ToolTip(_Timer_Diff($LeftMouseClickTime))
  WEnd
    EndIf
WEnd
DllClose($dll)

The problem is that when I click the mouse, it starts to count the time. But when I click the mouse second time, sometime the count is finished. But sometimes it starts a new count. I think the problem is because it pass the value of _isPressed("1", $dll) to the line If... just below While 1. I have tried to add Sleep(200) like the following:

#include <Misc.au3>
#include <Math.au3>
#include <Timers.au3>
$dll = DllOpen("user32.dll")
While 1
    If _isPressed("1", $dll) Then

     Local $LeftMouseClickTime = _Timer_Init()
        While Not _isPressed("1", $dll)
            ToolTip(_Timer_Diff($LeftMouseClickTime))
  WEnd
    EndIf
Sleep(200)
WEnd
DllClose($dll)

The script is running , but there is no count appear now. I can't figure out why....

Link to comment
Share on other sites

Tell us what you want to do instead of what you're doing and we can probably suggest something better. This is just... Bleh.

And why are you using the UDF timers when we have TimerInit()/TimerDiff() natively?

Link to comment
Share on other sites

@AdmiralAlkex:

Because I don't know there is TimerInit...I just found _Timer_Init, thank you to point this. I have mentioned that I would like to have a script which could detect a double (left) mouse click ( and of course when it detect this, do other things.) I thought the above codes will illustrate better what problem I got stuck. There are two places where it tests if _isPressed("1", $dll) and it gets confused.

So I add sleep(200), but it doesn't count anymore....

Link to comment
Share on other sites

Tuned for my clicks, may not work for you...

#include <Misc.au3>

$dll = DllOpen("user32.dll")

check()

Func check()
If _IsPressed("1", $dll) Then
    Sleep (52)
If Not _IsPressed("1", $dll) Then
    Sleep (52)
If _IsPressed("1", $dll) Then
MsgBox(0,"_IsPressed", "Key Pressed")
EndIf
EndIf
EndIf
EndFunc

Do
check()
Until $dll = 0
DllClose($dll)

EDIT: edited timers, to more accurate result go to http://stopwatch.onlineclock.net/

double click normally on start, then divide the time by 3, and write the result on the 2 timers (sleep)

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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