Jump to content

Mouse Click Counter in Label


Recommended Posts

Hi, first of all sorry for my english :P .

I want to make a counter of the left mouse button and I want that it is ever active until I press the Stop button and I want that a Label shows the numbers of clicks.

I write this:

#include 
#include 

Global $clicks
$clicks=1

$Form1 = GUICreate("Form1", 251, 134, -1, -1)
$Label1 = GUICtrlCreateLabel("Number = ", 24, 8, 196, 25)
$Button1 = GUICtrlCreateButton("Active", 24, 56, 201, 25, 0)
GUISetState(@SW_SHOW)

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
_Func1()
EndSwitch
WEnd


Func _Func1()
While 1
If _IsPressed(01) Then
GUICtrlSetData($Label1, "Number = " & $clicks)
EndIf
if _IsPressed(01) Then
$clicks+=1
While _IsPressed(01)
Sleep(1)
WEnd
EndIf
WEnd
EndFunc

I don't know how to terminate it, and if I add MouseClick("left",x,x,x,x) it doesn't count the click of the mouse.

I want add this function in an AutoClick of the left button of the mouse, so I want to know how many times the left button is clicked.

I don't know if you understand :ermm:

Sorry again for my english. Thanks ;)

Link to comment
Share on other sites

  • Moderators

Hi, Null33. Posting your code seems to have stripped which files you're including, but you have only two, when you need three. You need GUIConstantsEX.au3 and WindowsConstants.au3 to create the GUI, and Misc.au3 for the _IsPressed function. When I include all three of these files, the code you have works and counts the mouse clicks just fine.

"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

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