Sign in to follow this  
Followers 0
forumghost

Execute func while Mouse is held down

11 posts in this topic

#Include <Misc.au3>
$dll = DllOpen("user32.dll")

Dim $Enabled

HotKeySet("x", "Quit");

Func Quit()
    Exit
EndFunc

While 1
if _IsPressed(01, $dll) then
$Enabled = 1
tooltip ("Enabled!")
Else
$Enabled = 0
tooltip("Disabled!")
Endif

If $Enabled = 1 then
MouseClick ( "left")
Endif

 sleep(10)
Wend
DllClose($dll)
;quit

This code is for an autoclicker I tried making, while holding down the left mouse button it should simply continue autoclicking the LMB superfast, and when I release it, it should stop clicking.

But it doesn't work, ispressed only gets the event once and disables evrything right after.

I need help :/

Share this post


Link to post
Share on other sites



Hi,

Usually I use:

If  _IsPressed('01') then
    Tooltip("Active")
    While _IsPressed('01')
         Do ur script.....
    WEnd
    Tooltip("")
EndIf

Hope it helps.

Share this post


Link to post
Share on other sites

Hi,

Usually I use:

If  _IsPressed('01') then
    Tooltip("Active")
    While _IsPressed('01')
         Do ur script.....
    WEnd
    Tooltip("")
EndIf

Hope it helps.

#Include <Misc.au3>
$dll = DllOpen("user32.dll")

Dim $Enabled

HotKeySet("x", "Quit");

Func Quit()
    Exit
EndFunc


While 1
While _IsPressed(46, $dll)
tooltip ("Autoclicking...")
MouseClick("left")
    sleep(10)
Wend
    sleep(10)
Wend

DllClose($dll)
;quit

This one works fine for pressing F now.

But I want it to work with LMB....but when I put in "01"(thats LMB) then it will register only once and not send any clicks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

So, basically you want to press and hold the LMB, then the script would click repetitively?

Maybe this?

#Include <Misc.au3>

While _IsPressed('01')
    MouseClick("left")
    sleep(20)
WEnd

I never use mouseclick though, so I do not really know the result. But this should work fine.

And I suggest not to put tooltip in the while loop, because it would take unnecessary CPU time for creating the tooltip all the time while the button is pressed.

EDIT:

You might need to use MouseClickDelay also. Not sure though. Hope someone more expert on mouseclick could help you better.

Good luck.

Edited by MDCT

Share this post


Link to post
Share on other sites

So, basically you want to press and hold the LMB, then the script would click repetitively?

Maybe this?

#Include <Misc.au3>

While _IsPressed('01')
    MouseClick("left")
    sleep(20)
WEnd

I never use mouseclick though, so I do not really know the result. But this should work fine.

And I suggest not to put tooltip in the while loop, because it would take unnecessary CPU time for creating the tooltip all the time while the button is pressed.

EDIT:

You might need to use MouseClickDelay also. Not sure though. Hope someone more expert on mouseclick could help you better.

Good luck.

And exactly that doesn't work for some strange reason...

Share this post


Link to post
Share on other sites

When you are holding the physical mouse button, you'd just get conflicting values. Trying to simulate letting go of a button and holding the button will almost always cause a problem. Try a keyboard key instead.

Share this post


Link to post
Share on other sites

When you are holding the physical mouse button, you'd just get conflicting values. Trying to simulate letting go of a button and holding the button will almost always cause a problem. Try a keyboard key instead.

A keyboard key works fine, but its not what I really want, isnt there a workaround?

Share this post


Link to post
Share on other sites

A keyboard key works fine, but its not what I really want, isnt there a workaround?

I can't think of anything myself. Would it be good enough if it worked on pushing one of the other mousebuttons instead? that would be quite easy.

Share this post


Link to post
Share on other sites

Yeah, just use the middle button or one of the X buttons if you have them. The right button may cause problems if you use that one.

Share this post


Link to post
Share on other sites

Try ControlClick instead of MouseClick.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

He wants it at the mouse location.

Share this post


Link to post
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
Sign in to follow this  
Followers 0