Jump to content

Mouse Issue


Drew
 Share

Recommended Posts

Alright. What I'm doing, is writing a program that will repeatedly click the left mouse button continuously until I press the same hotkey to turn it off.

In the script, I press ` to begin clicking. When I press ` , I want it to keep clicking until I press it again. Here's what I have so far, but I can turn off the clicking without hitting TAB to close the program. I've run out of ideas on this.

HotKeySet('{tab}', '_Exit')
HotKeySet('`', '_HotKey')

While 1
    $mousepos = MouseGetPos()
    wend

If @error Then
    $Error = 1
Else
    $Error = 0
EndIf

$mousepos = MouseGetPos()

Func _HotKey()
While 1
    MouseClick( "left")
WEnd
EndFunc


Func _Exit()
    MsgBox( 0, "Thanks!", "This will close the program.")
    Exit
EndFunc
Link to comment
Share on other sites

HotKeySet('{esc}', '_Exit')
HotKeySet('`', '_HotKey')

$clicking = False

While 1
    Sleep(200); IMPORTANT <- without this line your script would use 100% cpu usage
    
    If $clicking then MouseClick( "left")
wend


Func _HotKey()
    $clicking = Not $clicking
EndFunc


Func _Exit()
    MsgBox( 0, "Thanks!", "This will close the program.")
    Exit
EndFunc
Why do I always decide to help people when I should be doing homework? Ask if you have any questions about the code...

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Link to comment
Share on other sites

Very interesting way of going about it. I understand how it works, but I don't fully understand WHY it works that way. ( If you get what I mean. )

What exactly does this part mean:

$clicking = NOT $clicking

and how does it link $clicking to MouseClick()

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