Jump to content

Execute func while Mouse is held down


Recommended Posts

#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 :/

Link to comment
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

Link to comment
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.

Edited by MDCT
Link to comment
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...
Link to comment
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?
Link to comment
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.

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