Jump to content

Simple mouse button click


King
 Share

Recommended Posts

Hey. For some reason I can't get this to work and it should be pretty simple. But I am new to this still.

What I want is a script that when I press F1 it turns on and off.

When it turns on every 5 seconds it presses the left mouse button.

All help would be greatly appreciated.

 

Link to comment
Share on other sites

HotKeySet("^!z","Movment");^!z is Ctrl+Alt+'z' to run the Movment 
HotKeySet("^!x","End");^!x is Ctrl+Alt+'x' to close the Movment 
While 1 
    Sleep(5000) 
WEnd 
Func Movment() 
    MouseClick ("Left")
    sleep(5000)  

    WEnd 
EndFunc 
Func End() 
    Exit 
EndFunc

I know this uses Ctrl+alt+z and X to start and stop. Which would be fine. 

It just doesn't repeat. And this may be way way off. Like I said I am trying to learn lol.

Edited by King
Link to comment
Share on other sites

#include <Misc.au3>

Global $State = 0
Global $MOUSE_CLICK_LEFT
Global $x = 0
Global $y = 0

While 1

    If _IsPressed("21") Then $State = 1 ; Page Up
    If _IsPressed("22") Then $State = 0 ; Page Down
    If _IsPressed("24") Then ExitLoop ; Home

    If $State = 1 Then
        MouseMove ( $x , $y )
        MouseClick($MOUSE_CLICK_LEFT)
    EndIf
WEnd

it's not a complete script but you get the idea

Edited by HankHell
Link to comment
Share on other sites

4 minutes ago, HankHell said:
#include <Misc.au3>

Global $State = 0
Global $MOUSE_CLICK_LEFT
Global $x = 0
Global $y = 0

While 1

    If _IsPressed("21") Then $State = 1 ; Page Up
    If _IsPressed("22") Then $State = 0 ; Page Down
    If _IsPressed("24") Then ExitLoop ; Home

    If $State = 1 Then
        MouseMove ( $x , $y )
        MouseClick($MOUSE_CLICK_LEFT)
    EndIf
WEnd

it's not a complete script but you get the idea

At this point I would be happy with a script that when I open it, it just starts pressing the left mouse button every 5 seconds.

I have this which works fine other than it moves my mouse. I just want it to press the left mouse button wherever my mouse is.

While 1
    Sleep(60000)
    MouseClick('Left', 100, 100, 2, 1)
WEnd

How would I change the above to stop moving the mouse?

thanks.

Link to comment
Share on other sites

That is my entire script.

This works perfectly accept it moves my mouse instead of left click where the mouse is.

If I could just get this to press the left mouse button where the mouse is instead of moving... That's all I need.

While 1
    Sleep(5000)
    MouseClick('Left', 100, 100, 2, 1)
WEnd

I believe the 100,100 needs to be changed to something else. I just don't know what.

Link to comment
Share on other sites

#include <Misc.au3>

Global $State = 0
Global $MOUSE_CLICK_LEFT

Clicky()

Func Clicky()
    While 1

        If _IsPressed("70") Then $State = 1 ; F1

        While $State = 1
            MouseClick($MOUSE_CLICK_LEFT)
            Sleep(5000)

                If _IsPressed("1b") Then $State = 0 ; ESC

        WEnd
    WEnd
Endfunc

is that what you're trying to do?
the script starts paused
press f1 to start the script, and hold ESC for 5 seconds to pause it again

Edited by HankHell
Link to comment
Share on other sites

53 minutes ago, King said:

That is my entire script.

This works perfectly accept it moves my mouse instead of left click where the mouse is.

If I could just get this to press the left mouse button where the mouse is instead of moving... That's all I need.

While 1
    Sleep(5000)
    MouseClick('Left', 100, 100, 2, 1)
WEnd

I believe the 100,100 needs to be changed to something else. I just don't know what.

Hey,

Use "default" for the current x,y positions.

MouseClick("left",Default,Default,2,0)

from https://www.autoitscript.com/autoit3/docs/functions/MouseClick.htm

Quote

Parameters:

x, y [optional] The x/y coordinates to move the mouse to. If no x and y coords are given, the current position is used (default).
   
Link to comment
Share on other sites

oh you want to doubleclick? my bad...this also works

#include <Misc.au3>

Global $State = 0
Global $MOUSE_CLICK_LEFT

Clicky()

Func Clicky()
    While 1

        If _IsPressed("70") Then $State = 1 ; F1

        While $State = 1
            MouseClick($MOUSE_CLICK_LEFT)
            MouseClick($MOUSE_CLICK_LEFT)
            Sleep(5000)

                If _IsPressed("1b") Then $State = 0 ; ESC

        WEnd
    WEnd
Endfunc

 

Link to comment
Share on other sites

Can you please tell us which program you try to automate?
Working with screen coordinates istn't very reliable as i depends on window position, screen resolution etc.
Most of the time there are more reliable ways to do what you want to do.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 4 years later...

@juxwillx  As previously mentioned by Water, mouse clicks is very unreliable and frequently used for game automation, which is against forum rules.  In order for us to reply to such request, it would be a good idea to dispel doubts by supplying the application name and a print screen of the running application so we can see what you are trying to achieve.

Link to comment
Share on other sites

  • Moderators
On 4/27/2022 at 8:11 PM, juxwillx said:

I’m working on a similar script but am confused how to make the mouse click with a fixed interval and also with varying intervals. I’m using this tool for auto clicking and want to replicate some of its functionalities. 

Which functionalities (what are you trying to click on), and in which application (as has been asked twice)? Please help us out with a detailed description, crystal ball is in the shop :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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