Jump to content
King

Simple mouse button click

Recommended Posts

King

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.

 

Share this post


Link to post
Share on other sites
King
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

Share this post


Link to post
Share on other sites
King
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)

MouseClick('left', $coord[0], $coord[1] - 0, 1, 0)

Sleep(5000)

WEnd

Just trying a different script while I wait on reply's

Edited by King
Doesn't work

Share this post


Link to post
Share on other sites
King

Nothing makes my anxiety spike like that stupid "Ding" that tells you something is wrong! lol 

Share this post


Link to post
Share on other sites
HankHell
#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

Share this post


Link to post
Share on other sites
King
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.

Share this post


Link to post
Share on other sites
HankHell

you can set the $State before WEnd to give it a different part of the program to cycle through after it completes the first task

Share this post


Link to post
Share on other sites
HankHell

Post your current script in its entirety real quick, I'll help you out

Share this post


Link to post
Share on other sites
King

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.

Share this post


Link to post
Share on other sites
HankHell
#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

Share this post


Link to post
Share on other sites
HankHell

oops doublepost <code edited>

Edited by HankHell

Share this post


Link to post
Share on other sites
Moonscarlet
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).
   

Share this post


Link to post
Share on other sites
HankHell

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

 

  • Like 1

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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

×