Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Help with left click mouse script


  • Please log in to reply
16 replies to this topic
febreeze
  • Members
  • 5 posts
  • Last active: May 22 2010 02:27 PM
  • Joined: 20 May 2010
Alright I have this script which clicks the mouse pretty fast

~LButton::
Loop
{
Sleep 1
GetKeyState, LButtonState, LButton, P
if LButtonState = U

MouseClick, Left

}
return
Space::Pause, toggle

It works fine, but are there any ways I can make it faster?
I'm really new to this software.

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
I don't think so.
Try this, but it should give you the same results:
~$LButton::
  While ( GetKeyState("LButton") )
    Click
Return
Space:: Pause, Toggle

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


febreeze
  • Members
  • 5 posts
  • Last active: May 22 2010 02:27 PM
  • Joined: 20 May 2010
Wow I actually made it faster by just deleting the
sleep 1
. Well it clicks about 29 times per second, but I've seen some that click around 50 times per second. Is it my computer not being able to pick up the clicks that fast or is it just people with more complex scripts than me?

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
Try it with this script
Count=0 
Gui,Font,S25 CDefault Bold,Arial 
Gui,Add,Text,VText x0 y5 w250 h40 +Center,%Count% 
Gui,Font,S14 W550,Arial 
Gui,Add,Button,GClick x12 y40 w225 h40,Click me! 
Gui,Add,Button,GReset X12 y85 w225 h40,Reset 
Gui,Add,Button,GExit x12 y130 w225 h40,Exit 
Gui,Show,w250 h190,Tester 
Return 

Exit: 
GuiClose: 
ExitApp 

Click: 
Count++ 
GuiControl,Text,Text,%Count% 
Return 

Reset: 
Count=0 
GuiControl,Text,Text,%Count% 
Return
Credit goes to Ace Coder

febreeze
  • Members
  • 5 posts
  • Last active: May 22 2010 02:27 PM
  • Joined: 20 May 2010

Try it with this script

Count=0 
Gui,Font,S25 CDefault Bold,Arial 
Gui,Add,Text,VText x0 y5 w250 h40 +Center,%Count% 
Gui,Font,S14 W550,Arial 
Gui,Add,Button,GClick x12 y40 w225 h40,Click me! 
Gui,Add,Button,GReset X12 y85 w225 h40,Reset 
Gui,Add,Button,GExit x12 y130 w225 h40,Exit 
Gui,Show,w250 h190,Tester 
Return 

Exit: 
GuiClose: 
ExitApp 

Click: 
Count++ 
GuiControl,Text,Text,%Count% 
Return 

Reset: 
Count=0 
GuiControl,Text,Text,%Count% 
Return
Credit goes to Ace Coder

Have no idea what to do with that..

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009

Alright I have this script which clicks the mouse pretty fast

You said that earlier, did you?
Ah, nevermind =)


febreeze
  • Members
  • 5 posts
  • Last active: May 22 2010 02:27 PM
  • Joined: 20 May 2010

Alright I have this script which clicks the mouse pretty fast

You said that earlier, did you?
Ah, nevermind =)

Yeah it works fine and all just seeing if somebody knows any ways to make it faster

wolf_II
  • Members
  • 343 posts
  • Last active: Jul 23 2010 05:19 PM
  • Joined: 18 Oct 2007
I'm just wondering, is there a method to detect how often a click occurs? (I might have a workaround, but I need a measurement tools of some description)
Wolf

Schön wär's, wenn's schön wär!

sn0wblind
  • Members
  • 4 posts
  • Last active: Jun 20 2010 08:20 AM
  • Joined: 20 May 2010
go 2 <!-- m -->http://www.urban75.com/Mag/java7.html<!-- m -->
or use the one above from tomoe_uehara instead :D

wolf_II
  • Members
  • 343 posts
  • Last active: Jul 23 2010 05:19 PM
  • Joined: 18 Oct 2007
OK, the score gets to about 270-275 per 10 seconds with the "standard approach". I guess that is an acceptable measurement tool for the purpose. Now all I have left to do is to work on the workaround.
Wolf

Schön wär's, wenn's schön wär!

wolf_II
  • Members
  • 343 posts
  • Last active: Jul 23 2010 05:19 PM
  • Joined: 18 Oct 2007
SendMouseLClick() {
    DllCall("mouse_event", "UInt", 2) ; left button down
    DllCall("mouse_event", "UInt", 4) ; left button up
}

F12::
    Loop, 1000
        SendMouseLClick()
Return
How is that for a start? I get a score of 1000, with 8 second to go.
Wolf

Schön wär's, wenn's schön wär!

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
Go wolf_II go!!
ΠΠΠΠΠΠΠ
ΠΠΠΠΠΠΠ
ΠΠΠΠΠΠΠ

wolf_II
  • Members
  • 343 posts
  • Last active: Jul 23 2010 05:19 PM
  • Joined: 18 Oct 2007
@tomoe_uehara: Here I go:
;---------------------------------------------------------------------------
SendMouse_LeftClick() { ; send fast left mouse clicks
;---------------------------------------------------------------------------
    DllCall("mouse_event", "UInt", 0x02) ; left button down
    DllCall("mouse_event", "UInt", 0x04) ; left button up
}


;---------------------------------------------------------------------------
SendMouse_RightClick() { ; send fast right mouse clicks
;---------------------------------------------------------------------------
    DllCall("mouse_event", "UInt", 0x08) ; right button down
    DllCall("mouse_event", "UInt", 0x10) ; right button up
}


;---------------------------------------------------------------------------
SendMouse_MiddleClick() { ; send fast middle mouse clicks
;---------------------------------------------------------------------------
    DllCall("mouse_event", "UInt", 0x20) ; middle button down
    DllCall("mouse_event", "UInt", 0x40) ; middle button up
}


;---------------------------------------------------------------------------
SendMouse_RelativeMove(x, y) { ; send fast relative mouse moves
;---------------------------------------------------------------------------
    DllCall("mouse_event", "UInt", 0x01, "UInt", x, "UInt", y) ; move
}


;---------------------------------------------------------------------------
SendMouse_AbsoluteMove(x, y) { ; send fast absolute mouse moves
;---------------------------------------------------------------------------
    ; Absolute coords go from 0..65535 so we have to change to pixel coords
    ;-----------------------------------------------------------------------
    static SysX, SysY
    If (SysX = "") 
        SysX := 65535//A_ScreenWidth, SysY := 65535//A_ScreenHeight
    DllCall("mouse_event", "UInt", 0x8001, "UInt", x*SysX, "UInt", y*SysY)
}


;---------------------------------------------------------------------------
SendMouse_Wheel(w) { ; send mouse wheel movement, pos=forwards neg=backwards
;---------------------------------------------------------------------------
    DllCall("mouse_event", "UInt", 0x800, "UInt", 0, "UInt", 0, "UInt", w)
}

Not fully tested, yet!

See <!-- m -->http://www.autohotke... ... 786#356786<!-- m -->
Wolf

Schön wär's, wenn's schön wär!

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
We all almost forgot: <!-- m -->http://www.autohotke... ... eDelay.htm<!-- m --> :!: :!:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


wolf_II
  • Members
  • 343 posts
  • Last active: Jul 23 2010 05:19 PM
  • Joined: 18 Oct 2007
SetMouseDelay, 0
F12::
    Loop, 1000
        Click
Return

Performs even better, score=1000 with 9 seconds to go!! :D
Thanks to MasterFocus, I knew about it, but have never bothered to use it.
Like so many other features in AHK.
Wolf

Schön wär's, wenn's schön wär!