Sign in to follow this  
Followers 0
sulfurious

_ispressed -- mouse events

2 posts in this topic

Hi. I had a need to repeat some functions based upon how long a mouse key would be held down. I started playing by using the _ispressed() function. What I found was that it seemed to detect the mouse click as a whole unit, as in _ispressed(01) would equal 1 (true) if the click happened, as in UP and DOWN. I could not get it to do a loop WHILE DOWN. So, I made a simple loop that when the button was pressed and released, did what I wanted X number of times.

In some debugging I happened to put a msgbox in the mouse area and found a peculilar thing happened. With a message box in place on a timer to exit, the _ispressed() function started looping. So, here is a small sample to play with. I have not been able to get some 'text' to send to notepad repeatedly UNLESS the msgbox() is active. Can anyone explain what is going on here? How come a msgbox() on a timeout causes the function to work one way, and not using it cannot reproduce it?

I should state, that I am talking about holding the mouse button down, and having text go to notepad continuously until mouse button is released.

Sul.

#include <Misc.au3>
HotKeySet("{esc}", "Quit")
$dll = DllOpen("user32.dll")

While 1
    If WinActive('Untitled - Notepad') Then
        If _IsPressed(01,$dll) Then
            MsgBox(0,'01','pressed  : ' & _IsPressed(01),2)
            Do
                Send('abc')
                Sleep(20)
            Until  _IsPressed('1',$dll) = 0
        EndIf
    EndIf
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi. I had a need to repeat some functions based upon how long a mouse key would be held down. I started playing by using the _ispressed() function. What I found was that it seemed to detect the mouse click as a whole unit, as in _ispressed(01) would equal 1 (true) if the click happened, as in UP and DOWN. I could not get it to do a loop WHILE DOWN. So, I made a simple loop that when the button was pressed and released, did what I wanted X number of times.

In some debugging I happened to put a msgbox in the mouse area and found a peculilar thing happened. With a message box in place on a timer to exit, the _ispressed() function started looping. So, here is a small sample to play with. I have not been able to get some 'text' to send to notepad repeatedly UNLESS the msgbox() is active. Can anyone explain what is going on here? How come a msgbox() on a timeout causes the function to work one way, and not using it cannot reproduce it?

I should state, that I am talking about holding the mouse button down, and having text go to notepad continuously until mouse button is released.

Sul.

#include <Misc.au3>
HotKeySet("{esc}", "Quit")
$dll = DllOpen("user32.dll")

While 1
    If WinActive('Untitled - Notepad') Then
        If _IsPressed(01,$dll) Then
            MsgBox(0,'01','pressed  : ' & _IsPressed(01),2)
            Do
                Send('abc')
                Sleep(20)
            Until  _IsPressed('1',$dll) = 0
        EndIf
    EndIf
WEnd
Notepad doesn't process keystrokes if the left mouse button is held down. For some reason the message box ending counteracts the mouse button being down if only for a short time.

Try typing into Notepad and while you're typing hold the left mouse button down, the same with edits created by AutoIt. This doesn't happen in Scite so maybe it's a question of finding the right editor.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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  
Followers 0