TsunamiZ Posted December 1, 2010 Report Share Posted December 1, 2010 How about add "double click" as a mouse activation? Quote Link to comment Share on other sites More sharing options...
acantor Posted December 1, 2010 Report Share Posted December 1, 2010 Get Mouse Position into (%XMouse1%, %YMouse1%) Relative to Current Window Wait for Left Mouse Click On Error Catch Error: The condition was not met within the specified amount of time Text Box Display: Single click detected Macro Stop End Catch Error End Error Get Mouse Position into (%XMouse2%, %YMouse2%) Relative to Current Window If Variable %XMouse1% Equals "%XMouse2%" And If Variable %YMouse1% Equals "%YMouse2%" Text Box Display: Double click detected! Else Text Box Display: Two clicks detected, but the mouse was moved between clicks End If The activation for this script is left click on the title bar. I set "Wait for Left Mouse Click" to wait up to one second (which appears to be the shortest time interval available.) If you click on the title bar once, the script does one thing. If you double-click the title bar without moving the mouse, the script does something else. If you double-click the title bar while moving the mouse, the script performs a third action. (The second click does not have to be on the title bar.) Quote Link to comment Share on other sites More sharing options...
terrypin Posted December 1, 2010 Report Share Posted December 1, 2010 Nice one Alan! -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
acantor Posted December 1, 2010 Report Share Posted December 1, 2010 Here is the code to differentiate single, double, and triple clicks. (Unlike my previous example, this version does not check for cursor movements.) Because the shortest available wait for left click is 1 second, there is a pause after a single or double click that some may find unacceptable. A triple click, on the other hand, is recognized almost instantaneously. I will submit a feature request for shorter wait times! Wait for Left Mouse Click On Error Catch Error: The condition was not met within the specified amount of time Text Box Display: Single click detected // Insert commands for a single click Macro Stop End Catch Error End Error Wait for Left Mouse Click On Error Catch Error: The condition was not met within the specified amount of time Text Box Display: Double click detected // Insert commands for a double click Macro Stop End Catch Error End Error Text Box Display: Triple click detected! // Insert commands for a triple click Quote Link to comment Share on other sites More sharing options...
arekowczarek Posted December 4, 2010 Report Share Posted December 4, 2010 Here is the code to differentiate single, double, and triple clicks. (Unlike my previous example, this version does not check for cursor movements.) Because the shortest available wait for left click is 1 second, there is a pause after a single or double click that some may find unacceptable. A triple click, on the other hand, is recognized almost instantaneously. I will submit a feature request for shorter wait times! I thought I would share my idea here as well. Two clicks will only be considered a double click if they occur one after another within certain adjustable time period (i.e. 200 ms) I detect double click using two macros: MAIN CLICK activated by: Mouse left click in top left screen area Var set integer %N[3]% to 200 // click interval [ms] Var modify integer: %N[3]%=%N[3]% / 10 Var set integer %N[1]%: Set to mouse X coordinate Var set integer %N[2]%: Set to mouse Y coordinate Var set string %T[1]% to: "START" Var mod string: Save %T[1]% to environmental var %STOPWATCH% Macro Run: STOPWATCH // don't wait Repeat Start 100 times //loop number stored in %COUNTER% Var set string %T[1]% to environmental var %STOPWATCH% If var %T[1]% equals "STOP" or If var %COUNTER% is greater than %N[3]% Break End If Delay 10 ms End Repeat Var set integer %N[11]%: Set to mouse X coordinate Var set integer %N[12]%: Set to mouse Y coordinate If var %COUNTER% is less than or equal to %N[3]% And If var %N[1]% equals %N[11]% And If var %N[2]% equals %N[12]% //EXECUTE COMMAND FOR DOUBLE CLICK Delay 100 ms // Disable this and next command if you don't want the double click sent to the target (window, icon etc) Left mouse double-click // Else //EXECUTE COMMAND FOR SINGLE CLICK End IF STOPWATCH activated by: Run command Wait for left mouse click //wait at most 1 second Variable Set string %T[1]% to "STOP" Var modify string: Save %T[1]% to environmental var %STOPWATCH% Main macro (MAIN CLICK) is activated by mouse left click Main macro runs macro STOPWATCH which awaits for the second click If main macro waits too long for the signal from STOPWATCH that the second click occured, it breaks loop and performs actions for single click (if any) If main macro receives signal from STOPWATCH, and the time interval between first and last click is less than 200 ms, main macro exectutes commands for double click. Main macro only consider two mouse clicks to be a double-click if both clicks take place at same location. Time interval that separates two single clicks from a double-click can be adjusted in line #1 of MAIN CLICK macro, 200 ms by defaul. MAIN CLIK + STOPWATCH.mex Quote Link to comment Share on other sites More sharing options...
terrypin Posted December 4, 2010 Report Share Posted December 4, 2010 Alan, Here a double click on the title bar of any non-maximised window always maximises it by default. And restores it if already maximised. (Standard Windows behaviour? Can't recall ever setting this.) So for testing I changed your (first) macro's activation to a left click on a small area of the screen. But I'm getting the 'Double click' message after a single click, so I reckon I've slipped up somewhere. Could you post your code please? Here's mine: <GET MOUSE POSITION Option="\x01" X="%XMouse1%" Y="%YMouse1%" _HANDLE="0x0003"/> <WAIT FOR LEFT MOUSE CLICK Indefinite="FALSE" Hours="0" Minutes="0" Seconds="1" _HANDLE="0x0014" _COMMENT="Wait LE 1 sec"/> <COMMENT Value="The following assume the previous command's On Error was set to 'Handle Error'."/> <ON ERROR/> <CATCH ERROR Code="20"/> <TEXT BOX DISPLAY Title="TBD 1" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Single click detected\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <MACRO STOP/> <END CATCH ERROR/> <END ERROR/> <GET MOUSE POSITION Option="\x01" X="%XMouse2%" Y="%YMouse2%" _HANDLE="0x0003"/> <IF VARIABLE Variable="%XMouse1%" Condition="\x00" Value="%XMouse2%" IgnoreCase="FALSE"/> <AND/> <IF VARIABLE Variable="%YMouse1%" Condition="\x00" Value="%YMouse2%" IgnoreCase="FALSE"/> <TEXT BOX DISPLAY Title="TBD2" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Double click detected.\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <ELSE/> <TEXT BOX DISPLAY Title="TBD - movement" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Two clicks detected but mouse moved between clicks.\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <END IF/> -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.