Vegar Posted January 1, 2009 Posted January 1, 2009 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
AlmarM Posted January 1, 2009 Posted January 1, 2009 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.
Vegar Posted January 1, 2009 Author Posted January 1, 2009 ok, thnx that saved me some work 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)
Tomb Posted January 1, 2009 Posted January 1, 2009 (edited) Vegar said: ok, thnx that saved me some work 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 January 1, 2009 by Tomb
Andreik Posted January 1, 2009 Posted January 1, 2009 Tomb said: use _IsPressed("01", "user32.dll")_IsPressed() function is very sensitive, some adjustments must be made to work properly.
Tomb Posted January 1, 2009 Posted January 1, 2009 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
Andreik Posted January 1, 2009 Posted January 1, 2009 Tomb said: 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.
Tomb Posted January 1, 2009 Posted January 1, 2009 Andreik said: Do not show the real number of clicks.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.
Aceguy Posted January 1, 2009 Posted January 1, 2009 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 [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock
Andreik Posted January 1, 2009 Posted January 1, 2009 Tomb said: 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.
knightthgink Posted January 16, 2009 Posted January 16, 2009 AlmarM said: 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 ^^, AlmarMhow to make it count left click and right click between??
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now