Jump to content

Count Mousecliks


Vegar
 Share

Recommended Posts

i'm making a script that count's how many times you have left clicked on the mouse...

but i got kind of stuck so i need som help :)

so what do i do with this:

#include <GuiConstants.au3>

GuiCreate("Sample GUI", 150, 200)


$Left_mouseclick = GuiCtrlCreateButton("Left_mouseclick", 15, 80, 120, 30)



GUISetState ()   



While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Left_mouseclick
            MsgBox(0, "Left MouseClicks", "You have pushed the left MouseClick ... Times")
    EndSelect
Wend
Link to comment
Share on other sites

Hi,

Take a look at this.

Global $iMouseClicks = 0, $Label

$GUI = GUICreate("Sample GUI", 200, 100, -1, -1)
$Button = GUICtrlCreateButton("Click Me", 10, 10, 180, 50)
$Label = GUICtrlCreateLabel("You clicked the button " & $iMouseClicks & " times.", 10, 73)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = -3 ; $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button
        $iMouseClicks += 1
        GUICtrlSetData($Label, "You clicked the button " & $iMouseClicks & " times.")
    EndSelect
WEnd

Hope it helps ^^,

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

ok, thnx :)

that saved me some work :o

But i still cant figure out how i can make the "$Button"-reference to register a "click" anyway where you click, (not only on the button)

use
_IsPressed("01", "user32.dll")
Edited by Tomb
Link to comment
Share on other sites

here is an example

#include <GuiConstants.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)

GuiCreate("Sample GUI", 150, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitScript")
$Left_mouseclick = GuiCtrlCreateButton("Left_mouseclick", 15, 80, 120, 30)
GUICtrlSetOnEvent(-1, "Left_MouseClicks")
GUISetState()    


$clicks = 0
While 1

    If _IsPressed("01", "user32.dll") Then $clicks = $clicks + 1
    sleep(100)
Wend


Func Left_MouseClicks()
    MsgBox(0, "Left MouseClicks", "You have pushed the left MouseClick " & $clicks & " Times")
EndFunc


Func ExitScript()
    Exit
EndFunc
Link to comment
Share on other sites

here is an example

#include <GuiConstants.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)

GuiCreate("Sample GUI", 150, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitScript")
$Left_mouseclick = GuiCtrlCreateButton("Left_mouseclick", 15, 80, 120, 30)
GUICtrlSetOnEvent(-1, "Left_MouseClicks")
GUISetState()    


$clicks = 0
While 1
    If _IsPressed("01", "user32.dll") Then $clicks = $clicks + 1
    sleep(100)
Wend


Func Left_MouseClicks()
    MsgBox(0, "Left MouseClicks", "You have pushed the left MouseClick " & $clicks & " Times")
EndFunc


Func ExitScript()
    Exit
EndFunc

Do not show the real number of clicks.

When the words fail... music speaks.

Link to comment
Share on other sites

quick mod

#include <GuiConstants.au3>
#include <Misc.au3>

Opt("GUIOnEventMode", 1)

GuiCreate("Sample GUI", 150, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "ExitScript")
$Left_mouseclick = GUICtrlCreateLabel("Left_mouseclick", 15, 80, 120, 30)
GUISetState()    


$clicks = 0
While 1
    If _IsPressed("01", "user32.dll") Then 
    while _IsPressed("01","user32.dll")
        sleep(50)
        WEnd
    $clicks = $clicks + 1
    GUICtrlSetData($Left_mouseclick,$clicks)
    EndIf
Wend




Func ExitScript()
    Exit
EndFunc
Link to comment
Share on other sites

the problem is if they hold down the click to long, it will keep adding every 100 ms.

but it should work fine for normal clicks.

Yes. It's need to check if the left click is released before to add the number of clicks.

When the words fail... music speaks.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

Take a look at this.

Global $iMouseClicks = 0, $Label

$GUI = GUICreate("Sample GUI", 200, 100, -1, -1)
$Button = GUICtrlCreateButton("Click Me", 10, 10, 180, 50)
$Label = GUICtrlCreateLabel("You clicked the button " & $iMouseClicks & " times.", 10, 73)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = -3 ; $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button
        $iMouseClicks += 1
        GUICtrlSetData($Label, "You clicked the button " & $iMouseClicks & " times.")
    EndSelect
WEnd

Hope it helps ^^,

AlmarM

how to make it count left click and right click between??
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...