Jump to content

Make mouse click for a specific amount of time.


Recommended Posts

Hi there,

I've got this:

Global $Paused=True , $counter = 34

HotKeySet("{F6}", "TogglePause")
HotKeySet("{F7}", "Terminate")

While 1
    If Not $Paused Then ;to see if paused or not
Sleep(150)
MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time
Sleep(150) ; wait
MouseClick("left",1024,574,1,15) ; Click on a button
Sleep(150) ; wait
MouseClick("left",617,536,1,15) ; Click on "ANOTHER" button
Sleep(50) ; wait
Send("^!+c") ; Send key combination
Sleep(150) ; wait
    EndIf
    Sleep(10)
WEnd

Func TogglePause()
    $Paused= Not $Paused;if true set to false and vice versa
EndFunc

Func Terminate() ;exit
    Exit
EndFunc

What i want do be able to do, is to make this part:

MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time
Sleep(150) ; wait

click for a specific amount of time with delay of clicks of 90 miliseconds.

 

Where is that help file where it says what i need?

Thank you.

Link to comment
Share on other sites

Look at Opt for :

MouseClickDelay Alters the length of the brief pause in between mouse clicks.
Time in milliseconds to pause (default=10). 


MouseClickDownDelay Alters the length a click is held down before release.
Time in milliseconds to pause (default=10). 

 

Link to comment
Share on other sites

2 hours ago, Nine said:

Look at Opt for :

MouseClickDelay Alters the length of the brief pause in between mouse clicks.
Time in milliseconds to pause (default=10). 


MouseClickDownDelay Alters the length a click is held down before release.
Time in milliseconds to pause (default=10). 

 

Wont help me. This i understand how to use time in between clicks, but i want to MULTI-click for a specific amount of time, let's say 15 minutes, then execute the rest of the code.

For example, i want the code to click multiple times in a specific area for 15 minute ... mor or less. I don't want to click and hold for a specific amount of time, but to click 1000 times with 90 milliseconds or 100 between clicks or for 15 minutes ... mor or less.

Thank you.

Link to comment
Share on other sites

25 minutes ago, JuanFelipe said:

According to what I understand, use a For

 

For $i = 0 To 15 Step 1
    MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time
    Sleep(1000) ; wait
Next

Modify the sleep to match the number of repetitions you want.

Couldn't i say somewhere something like: 

MouseClick("left",721,550,1,15) ; Multiple clicks for x amount of time
Timer: 15 min

or some sort of ...

And sleep is not a function (or what ever it is) that tells to wait/pause/halt/do nothing that amount of time?

Thank you.

Link to comment
Share on other sites

51 minutes ago, BogdanNicolescu said:

Wont help me. This i understand how to use time in between clicks, but i want to MULTI-click for a specific amount of time, let's say 15 minutes, then execute the rest of the code.

For example, i want the code to click multiple times in a specific area for 15 minute ... mor or less. I don't want to click and hold for a specific amount of time, but to click 1000 times with 90 milliseconds or 100 between clicks or for 15 minutes ... mor or less.

I think you do not understand my point (unless it is me that don't understand you).  This is what I was telling you :

Const $iClickDuration = 10 ; how long last a click --> use default of opt : MouseClickDownDelay
Const $iInterval = 90 ; interval between clicks
Const $iDuration = 1000 * 60 ; * 15 -- but for test lets says 1 minute

Opt ("MouseClickDelay", $iInterval)  ; this is what you want, right ?
Local $iNumberOfClicks = Int($iDuration/($iInterval+$iClickDuration))
Local $hTimer = TimerInit ()
MouseClick ("left", 200, 200, $iNumberOfClicks, 0) ; clicking every 90 ms for the duration
ConsoleWrite (TimerDiff ($hTimer) & @CRLF)

 

Link to comment
Share on other sites

30 minutes ago, Nine said:

I think you do not understand my point (unless it is me that don't understand you).  This is what I was telling you :

Const $iClickDuration = 10 ; how long last a click --> use default of opt : MouseClickDownDelay
Const $iInterval = 90 ; interval between clicks
Const $iDuration = 1000 * 60 ; * 15 -- but for test lets says 1 minute

Opt ("MouseClickDelay", $iInterval)  ; this is what you want, right ?
Local $iNumberOfClicks = Int($iDuration/($iInterval+$iClickDuration))
Local $hTimer = TimerInit ()
MouseClick ("left", 200, 200, $iNumberOfClicks, 0) ; clicking every 90 ms for the duration
ConsoleWrite (TimerDiff ($hTimer) & @CRLF)

 

 

And how exactly do i put this in my code? It will work with the rest of what i have?

Link to comment
Share on other sites

2 minutes ago, BogdanNicolescu said:

And how exactly do i put this in my code? It will work with the rest of what i have?

Sorry, you will need to figure out that by yourself.  Unless a good Samaritan will spew it for you. ;) 

Link to comment
Share on other sites

How do i use this: 

Local $hTimer = TimerInit ()

 

And how do i get rid of:
Const $iClickDuration = 10 ; how long last a click --> use default of opt : MouseClickDownDelay

 

Because i already have this:
Const $iInterval = 90 ; interval between clicks

Edited by BogdanNicolescu
misspelling
Link to comment
Share on other sites

While 1
    If Not $Paused Then ;to see if paused or not
Const $iClickDuration = 90 ; how long last a click --> use default of opt : MouseClickDownDelay
Const $iInterval = 90 ; interval between clicks
Const $iDuration = 100 * 60 ; * 15 -- but for test lets says 1 minute
Opt ("MouseClickDelay", $iInterval)  ; this is what you want, right ?
Local $iNumberOfClicks = Int($iDuration/($iInterval+$iClickDuration))
Local $hTimer = TimerInit ()
MouseClick ("left", 721, 550, $iNumberOfClicks, 0) ; clicking every 90 ms for the duration
ConsoleWrite (TimerDiff ($hTimer) & @CRLF)
MouseClick("left",1024,574,1,15) ; Click on a button
Sleep(150) ; wait
    EndIf
    Sleep(10)
WEnd

 

And why do i get this error?

>"X:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "X:\Users\User\Documents\!Automation\testclick.au3"    
3315.37433271884
"X:\Users\User\Documents\!Automation\testclick.au3" (9) : ==> Can not redeclare a constant.:
Const $iClickDuration = 90
Const ^ ERROR
>Exit code: 1    Time: 10.6

Edited by BogdanNicolescu
Link to comment
Share on other sites

  • Developers
6 minutes ago, BogdanNicolescu said:

And why do i get this error?

The error does exactly tell you what is wrong,,,,right? ;) 

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

1 minute ago, Jos said:

The error does exactly tell you what is wrong,,,,right? ;) 

Jos

Any hint would be much appreciated as i'm looking at something resembling like klingonian (i don't want to offend Chinese/Japanese people that would be here ^_^ ) and for now i can't understand why i'm getting this. Tried to change from 90 to 10, but no avail ...

Link to comment
Share on other sites

On 2/8/2020 at 7:00 PM, Jos said:

The error does exactly tell you what is wrong,,,,right? ;) 

Jos

Thank you Master Yoda ... aaahmm sorry Jos, for sending me telepathically the response :D :))

 

Btw ... what are these "lines"?

>"x:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "x:\Users\User\Documents\!Automation\testclick.au3"    
3324.26151305731
3317.95812692394
3321.5178334804
3320.48891723529
3315.3012339423
3323.39248218399
3318.81172259742
>Exit code: 0    Time: 47.12

 

Edited by BogdanNicolescu
misspelling
Link to comment
Share on other sites

After a full day's worth of brain squeezing (not really, I've been doing other stuff in between :)) ) all i have right now is this:

 

Global $Paused=True , $counter = 34

HotKeySet("{F6}", "TogglePause")
HotKeySet("{F7}", "Terminate")


Const $iClickDuration = 90 ; how long last a click --> use default of opt : MouseClickDownDelay
Const $iInterval = 90 ; interval between clicks
Const $iDuration = 100 * 60 ; * 15 -- but for test lets says 1 minute


While 1
    If Not $Paused Then ;to see if paused or not

Opt ("MouseClickDelay", $iInterval)  ; this is what you want, right ?
Local $iNumberOfClicks = Int($iDuration/($iInterval+$iClickDuration))
Local $hTimer = TimerInit ()
MouseClick ("left", 721, 550, $iNumberOfClicks, 0) ; clicking every 90 ms for the duration
ConsoleWrite (TimerDiff ($hTimer) & @CRLF)
MouseClick("left",1024,574,1,15) ; Click on a button
Sleep(150) ; wait
    EndIf
    Sleep(10)
WEnd

Func TogglePause()
    $Paused= Not $Paused;if true set to false and vice versa
EndFunc

Func Terminate() ;exit
    Exit
EndFunc

 

LE

P.S.: How do i force pause or force stop? Because even if i press F7, it takes some time to stop.

Edited by BogdanNicolescu
Link to comment
Share on other sites

Your request seems a bit odd... maybe you can tell us what you're using the script for so we can better assist you? I've never needed to click for a specific amount of time like this and there could be a better way.

To force pause your script, you're going to need to write a wrapper for MouseClick since it will block exiting for the remainder of your duration... basically a function that is a single MouseClick wrapped in a for loop

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

On 2/8/2020 at 8:42 PM, seadoggie01 said:

Your request seems a bit odd... maybe you can tell us what you're using the script for so we can better assist you? I've never needed to click for a specific amount of time like this and there could be a better way.

To force pause your script, you're going to need to write a wrapper for MouseClick since it will block exiting for the remainder of your duration... basically a function that is a single MouseClick wrapped in a for loop

Hi, and helo there, welcome to our little party :)

I will not go into details because already the amount of the code that i have is already heavy on my brain and my brain is struggling to understand what is what and where is where and why the baloneys is everything where it is.

For instance, i didn't know that i've had to put this: 

Const $iClickDuration = 90 ; how long last a click --> use default of opt : MouseClickDownDelay
Const $iInterval = 90 ; interval between clicks
Const $iDuration = 100 * 60 ; * 15 -- but for test lets says 1 minute

where it is. It was only after Master Yoda JOS sent me telepathically the answer i could understand and get rid of  this error:

"X:\Users\User\Documents\!Automation\testclick.au3" (9) : ==> Can not redeclare a constant.:
Const $iClickDuration = 90
Const ^ ERROR

So any other complicated codes will be redundant as what i have is kind of working. Needs more tweaking tho ...

As per what you said: "you're going to need to write a wrapper for MouseClick"

How do i do that? Can you provide some "eg.:"

P.S.: For those who knows better this program, would be nice for you if you came up with some examples or something of some sort, not just "figure out" "read this nothing non-sense" "ask the Univers". Otherwise ... why this site exists :))))) :))))) :D

Edited by BogdanNicolescu
Link to comment
Share on other sites

Basically, when you call an internal function, it might take time to execute. You cannot interrupt these functions whenever you want with another event (pressing F7 to stop, for example).

More specifically: When you say MouseClick("left", 721, 550, $iNumberOfClicks, 0), AutoIt starts clicking in that spot $iNumberOfClicks times. Each of these clicks takes time (yours take longer because you've changed some options), and AutoIt will execute ALL of these clicks before doing anything else. If you write a function like the one below, AutoIt clicks once inside of the loop and returns to checking events. This will reduce the amount of time it takes after you press F7 to a length of one click

; This function will be able to be interrupted better because it clicks one at a time
Func _MouseClickWrapper($sButton, $iX, $iY, $iClicks, $iSpeed = 10)
    ; For each click
    For $i = 0 To $iClicks
        ; Click once with the requested parameters
        MouseClick($sButton, $iX, $iY, 1, $iSpeed)
    Next
EndFunc

I find it interesting that you still haven't mentioned what this is for 😐

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

11 minutes ago, seadoggie01 said:

Basically, when you call an internal function, it might take time to execute. You cannot interrupt these functions whenever you want with another event (pressing F7 to stop, for example).

More specifically: When you say MouseClick("left", 721, 550, $iNumberOfClicks, 0), AutoIt starts clicking in that spot $iNumberOfClicks times. Each of these clicks takes time (yours take longer because you've changed some options), and AutoIt will execute ALL of these clicks before doing anything else. If you write a function like the one below, AutoIt clicks once inside of the loop and returns to checking events. This will reduce the amount of time it takes after you press F7 to a length of one click

; This function will be able to be interrupted better because it clicks one at a time
Func _MouseClickWrapper($sButton, $iX, $iY, $iClicks, $iSpeed = 10)
    ; For each click
    For $i = 0 To $iClicks
        ; Click once with the requested parameters
        MouseClick($sButton, $iX, $iY, 1, $iSpeed)
    Next
EndFunc

I find it interesting that you still haven't mentioned what this is for 😐

Not working, i still need to press like crazy on stop button ...

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...