Jump to content

Make mouse click for a specific amount of time.


Recommended Posts

You replaced MouseClick with _MouseClickWrapper? I forgot to mention that, sorry :)

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

7 minutes ago, seadoggie01 said:

You replaced MouseClick with _MouseClickWrapper? I forgot to mention that, sorry :)

Thank you very much :huggles:works like a charm :D 

What is not working now, is pause button, how come that is not working?

This is what i got now:
 

Global $Paused=True , $counter = 34

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


Const $iClickDuration = 10 ; 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 ()
_MouseClickWrapper ("left", 721, 550, $iNumberOfClicks, 1) ; clicking every 90 ms for the duration
ConsoleWrite (TimerDiff ($hTimer) & @CRLF)
MouseClick("left",1024,574,1,15) ; Click click
Sleep(150) ; wait
MouseClick("left",617,536,1,15) ; Click "CLICK"
Sleep(50) ; wait
Send("^!+c") ; keysstroke
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

 ; 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

 

Edited by BogdanNicolescu
Link to comment
Share on other sites

Glad to hear it works better!

There's no check in the _MouseClickWrapper for paused. Do you think you can add a check for that? Think about what should happen when paused is set

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

8 minutes ago, seadoggie01 said:

Glad to hear it works better!

There's no check in the _MouseClickWrapper for paused. Do you think you can add a check for that? Think about what should happen when paused is set

You know what? I do really do want to know where should i look for that info. Really ... I do.
Most part of my life i have learned how to use a pc by myself in an era when google and google chrome where just an infant .... Whitout! Books :))
Probably you will come to me and ask: When was taht happening? And i will reply to you: Somewhere in the year 2004~2006, in an era when internet was still on dialup and or TV Cable ... Now i have fiber directly to my door. Maybe you will come and say: Oooh ... 2004 you say ... whelp ... back in '83 i was coding for RFCNo.: 230230298 Which is for something-something. Whel ... good for you. Not everybody has a pc, not everybody owns a console and still much part of the world doesn't know how is on fiber :D

So ... that being said .. (sorry for my bad talent of writing novels) ... If i have had a source of inspiration .... Yes! i could have added that. :D 

Link to comment
Share on other sites

I understand that coding can be frustrating and difficult, I've been learning from people on the internet for the last 8 years. In those last 8 years I moved from literal copy-paste StackOverflow answers to actually writing a few of them and working on a degree in programming. I'm not looking for you to have all the answers, I just want you to think critically about the difference between what you're trying to do and what your code actually does. I really don't mind writing some code for you, but I don't want to just do it for you, I want to help you learn about the code that you have so you can get better at it.

Back in '83 I wasn't even thought of yet and in 2004 the only thing I cared about computers was that they let me play games :D

Now, about your program... let's walk through what actually happens...

1. All of the initial stuff happens: you setup functions to be executed on buttons pressed, you initialize some variables, etc.
2. It moves to the While loop and checks $Paused. It isn't paused yet, runs the calculations and calls _MouseClickWrapper.
3. Some time passes and it clicks 3 of the 6 times.
4. You press F6.
5. AutoIt interrupts _MouseClickWrapper and executes the code in TogglePause. $Paused is True now.
6. AutoIt continues back in _MouseClickWrapper. It continues clicking the other 3 of 6 times.
7. _MouseClickWrapper finishes and returns. The rest of the While loop finishes.
8. It moves back to the beginning of the While loop and realizes it is paused.

What you want to happen should happen in _MouseClickWrapper (at step 6). _MouseClickWrapper doesn't care if the program is $Pause-d, it just clicks. You're looking to do something like in your While loop where you say "If Not $Paused Then"

As for where to look, there is a more-in depth discussion of this topic here: https://www.autoitscript.com/wiki/Interrupting_a_running_function
However, I was asking you to think and try. Sometimes experimentation is the best way to learn. I also don't know what you want to do when the program is paused, you could have it sit idly while waiting for another key press before picking up where it left off, or it could exit the current action, or it could do something else entirely.

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

18 hours ago, seadoggie01 said:

[...]

As for where to look, there is a more-in depth discussion of this topic here: https://www.autoitscript.com/wiki/Interrupting_a_running_function
However, I was asking you to think and try. Sometimes experimentation is the best way to learn. I also don't know what you want to do when the program is paused, you could have it sit idly while waiting for another key press before picking up where it left off, or it could exit the current action, or it could do something else entirely.

You, Sir, ARE GOLD ❤️❤️❤️ 

 

Thank you. This is a good reading.

Whelp ... to answer to your question "don't know what you want to do when the program is paused", what i want, is to pause, then if pressed again to resume where it left. I will read more from that link and make some tests.

Thank you again :D 

Link to comment
Share on other sites

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

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.
 

Really? You can't simply tell us the name of the application? I've been here since 2005. I've seen just about EVERY type of automation there is. With the clues you are giving - Using the word "klingonian" and how your script works - This thread strongly suggest you are trying to automate a game. I can see NO reason as to why you need to spam a button like that. I've requested a moderator to take a closer look here for game automation is strictly forbidden here. 

Link to comment
Share on other sites

I wasn't intending to be assisting with illicit activities, I'm sorry. I saw Jos was here earlier and assumed everything was okay 😐 

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

  • Developers

Ok... we're done with this thread!

@BogdanNicolescu,
This is either your last warning or you send me prove in a PM that this is a legitimate thread!

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

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