Jump to content

Recommended Posts

Posted

I am looking for a simple way to detect if the left mouse button has just been released.

Currently _IsPressed("01") is too simple for my needs. I trying to detect a situation where it is possible to click and drag - but I dont want to trigger my code yet.

I only want to trigger the rest of my code when the left mouse button has been released.

Does anyone have any thoughts?

Thanks! :)

Posted

Is this for your GUI, or a third party software? You could look for the Windows message for WM_LBUTTONUP if it's a GUI you created in AutoIt.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted
#include <Misc.au3>
#include <WinAPI.au3>
#include <TrayConstants.au3>
#include <MsgBoxConstants.au3>

 ; Press Esc to terminate script, Pause/Break to "pause"
Opt("TrayAutoPause", 0)
Global $Paused ; Declares a variable to be "Global"
HotKeySet("{PAUSE}", "TogglePause"); Sets the Pause/Break key to the "TogglePause" Function
HotKeySet("{ESC}", "Terminate") ; Binds the ESC key to the "Terminate" function

Local $hDLL = DllOpen("user32.dll")
Local $WinTitle, $WinClass

TogglePause()
While 1
   If NOT $paused then
      $hWnd = WinGetHandle("[ACTIVE]")
      $WinTitle = WinGetTitle($hWnd)
      $WinClass = _WinAPI_GetClassName($hWnd)
      If _IsPressed("01") Then ;; <------  MOUSE UP NOT IS PRESSED
        ;$pos = MouseGetPos()
        ;MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
         If $WinClass = "triuiScreen" then
            Send("{v down}")
            Send("{v up}")
            Sleep(Random(1500, 2000, 1))
         EndIf
      EndIf
   EndIf
 WEnd

Func TogglePause() ; Declares the function called "TogglePause" which would be called every time the Pause/Break key is pushed
   $Paused = NOT $Paused ; Switches the paused variable between "true" and "false" each time it is called (allows for toggling)
   If $Paused then; Initiates a loop that will only work if Pause variable is "true"
      TrayTip("Auto D-SCAN", "PAUSED", 0,1)
      TraySetToolTip("D-Scan Script is Paused..."); Displays a tooltip so the user knows what going on
   ElseIf NOT $Paused then ; Ends that last loop
      TrayTip("Auto D-SCAN", "ACTIVE", 0,1)
      TraySetToolTip("D-Scan Script is Active..."); Clears the tooltip
   EndIf
EndFunc; Finishes declaring the "TogglePause" Function

Func Terminate() ;Declares the function called "Terminate" which would be called every time the ESC key is pushed
   If _IsPressed("13", $hDLL) Then
      Exit 0 ; Exits the program when called (Thus "terminates")
   Else
      Send("{ESC}")
   EndIf
EndFunc; Finishes the "Terminate" function

 

Posted (edited)

The goal is to send a keypress of the letter "v" to a specific window only when a window of that type is active and only on left mouse button up.

The rest is just frosting the pause/exit/etc..

Edited by EchoBinary

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
×
×
  • Create New...