Jump to content
Sign in to follow this  
Guest Thermos2000

Mouse Down with _IsPressed

Recommended Posts

Guest Thermos2000

I've pasted the _IsPressed function into my script, and then i add the very simple code:

While 1

    If _IsPressed('01') Then
        Send("a")
        Sleep(100)
    EndIf
    
WEnd

to perform a task repeatedly as i hold down the mouse. of course, after i get it to work i will change the Send("a") to do what i want, this is just to test.

So i load the script with wordpad already loaded. i hold down my mouse in wordpad, and it continually types a a a a a, and then stops when i let go. this is exactly what i want. the only problem is that if i try to hold down my mouse a second time, it stops working. im not sure why; isn't the loop infinite? why does it stop working after the first time i hold down and then release my mouse button?

thanks guys.

EDIT:

i've now noticed some strange behavior. if i hold down my mouse in wordpad, it works the first time and then doesnt, as i stated before. but after it stops working in wordpad, i can hold it down on my desktop and it works (toggling between all the icons that start with the letter A). the same behavior occurs on my desktop, after the first time it stops working. but then i am able to perform the loop on wordpad once again.

another strange thing ive noticed is that it doesnt work in some windows, such as Notepad (rather than wordpad) or the address bar on MSIE. Strange.

Edited by Thermos2000

Share this post


Link to post
Share on other sites

Try something besides Send().

ToolTip works fine

#include <IsPressed.au3>

While 1
    If _IsPressed('LBUTTON') Then
        ToolTip('click')
    EndIf
WEnd

Edit: And actually, even your code works fine for me. Even in this textarea.

Edited by Saunders

Share this post


Link to post
Share on other sites

Hello,

Your code to repeat keypress "a" while "Left Mouse button" is clicked worked well for me as well.

However, how can you get the desired keypress "a" functionality WITHOUT passing the "Left Mouse button" through to the underlying program also?

In other words, how can you make _IsPressed intercept the mouse-click before it is processed by the underlying program? If it were a keystroke, I could use HotKeySet function, but that doesn't work with mouse-click buttons (does it?).

Right now I must instead use the AutoHotKey program to map my Middle Click button into a more complicated script action, but then I lose many of the AutoIt functions and syntax.

Share this post


Link to post
Share on other sites

Hello,

Your code to repeat keypress "a" while "Left Mouse button" is clicked worked well for me as well.

However, how can you get the desired keypress "a" functionality WITHOUT passing the "Left Mouse button" through to the underlying program also?

In other words, how can you make _IsPressed intercept the mouse-click before it is processed by the underlying program? If it were a keystroke, I could use HotKeySet function, but that doesn't work with mouse-click buttons (does it?).

Right now I must instead use the AutoHotKey program to map my Middle Click button into a more complicated script action, but then I lose many of the AutoIt functions and syntax.

Hi,

how do I catch a click and NOT send ist to the application?

Until now I use the code like postet above.

Greetings

tk

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...