Jump to content

Recommended Posts

Posted

Total AutoIt noob here ... I'm not looking for a fully automated script just yet. My intention is to write a script that will allow my mouse button to click initially and then repeat at a given interval until the mouse button is released. This way I can hold the mouse button down and the script will do the timing for me until I release the click. Any help is appreciated, even just pointing me in the right direction.

Posted

Just a quick question, why do you require such a script? What's its usage?

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Repetitive tasks that require multiple mouse-clicks. As much as I am working with my PC I'd like a way to not have to click...click...click any more. Just one click set to an interval if I hold the click, or just one click if I click.

Simplifying this small task would be a huge help in daily tasks.

Posted

  On 1/22/2013 at 2:21 AM, 'Trevor said:

Still looking for a simple way to simplify a delayed mouse click ... I didn't think it would be this difficult.

If you search in the help file, i trust youll find something, then, when you have doubts, come back and state them.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

Detecting the first mouse click is trickier than it sounds. The easiest approach is to make a loop, and use the _IsPressed function to see if the mouse button is pressed. Once that's done, then take a look at MouseClick and AdlibRegister. Here's something to get you started. The main loop requires a bit of thinking. If you can figure out what the loop is actually doing and when the variables will be set/unset then you can probably understand most of all programming logic.

#include <Misc.au3>

Local $fClicking = False ; This variable will store whether we are doing the auto-clicking
Local $fPressed = False ; Another variable, will store whether the mouse button was pressed last iteration of the loop
While 1
    If $fClicking Then
        If _IsPressed("01") Then
            $fPressed = True
        Elseif $fPressed Then
            $fPressed = False
            $fClicking = False
            AdlibUnRegister("ClickFunction")
        EndIf
    Else
        If _IsPressed("01") Then
            $fPressed = True
        ElseIf $fPressed Then ; The mouse was pressed, but is now released
            $fClicking = True
            $fPressed = False
            AdlibRegister("ClickFunction", 1000)
        EndIf
    EndIf

    Sleep(10) ; If you don't sleep in a tight loop like this, your cpu will be very high
WEnd

Func ClickFunction()
    MouseClick("left")
EndFunc   ;==>ClickFunction
Posted

  On 1/22/2013 at 3:52 AM, 'Mat said:

Detecting the first mouse click is trickier than it sounds. The easiest approach is to make a loop, and use the _IsPressed function to see if the mouse button is pressed. Once that's done, then take a look at MouseClick and AdlibRegister. Here's something to get you started. The main loop requires a bit of thinking. If you can figure out what the loop is actually doing and when the variables will be set/unset then you can probably understand most of all programming logic.

#include <Misc.au3>

Local $fClicking = False ; This variable will store whether we are doing the auto-clicking
Local $fPressed = False ; Another variable, will store whether the mouse button was pressed last iteration of the loop
While 1
    If $fClicking Then
        If _IsPressed("01") Then
            $fPressed = True
        Elseif $fPressed Then
            $fPressed = False
            $fClicking = False
            AdlibUnRegister("ClickFunction")
        EndIf
    Else
        If _IsPressed("01") Then
            $fPressed = True
        ElseIf $fPressed Then ; The mouse was pressed, but is now released
            $fClicking = True
            $fPressed = False
            AdlibRegister("ClickFunction", 1000)
        EndIf
    EndIf

    Sleep(10) ; If you don't sleep in a tight loop like this, your cpu will be very high
WEnd

Func ClickFunction()
    MouseClick("left")
EndFunc ;==>ClickFunction

I appreciate the heads up on this, I have been reading through the help file to no avail. This is all new to me and every time I write something it just takes off on its own until I end the script.

I didn't expect anyone to do all of the work, just give a little help and point me in the right direction.

This helped a lot!

Thanks a million!

Posted

  On 1/22/2013 at 7:46 AM, 'Trevor said:

I appreciate the heads up on this, I have been reading through the help file to no avail. This is all new to me and every time I write something it just takes off on its own until I end the script.

I didn't expect anyone to do all of the work, just give a little help and point me in the right direction.

This helped a lot!

Thanks a million!

I did the easy bit: writing it. It's up to you to understand it (which is not as easy as it sounds).

And also my pseudo code usually ends up as AutoIt code anyway. Unsure if that's a good or a bad thing yet.

Posted

  On 1/22/2013 at 8:19 AM, 'Mat said:

And also my pseudo code usually ends up as AutoIt code anyway. Unsure if that's a good or a bad thing yet.

Is it pseudo code anymore? hmm ... there's pause for thought.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
  • Recently Browsing   0 members

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