Jump to content
Macro Express Forums

Mouse Double Click for Macro Activation


Recommended Posts

I don't think MEP is designed to do such a thing. My first thought would be to watch the Windows messages for an event. I've never tried it. I think this might be the message you woudl want to look for.

Or maybe have a macro with a single click activation that has a short delay, that being the period between the two clicks, and when it's run the next time, see if it's running or not. If the macro sees that the macro is running, then do what you want. But I can't remember if one can run a macro concurrently like that. But maybe some kind of trick like that. 

Maybe the first time it runs it puts a time stamp in the registry and on the second time it runs if less than a specified time has elapsed, then consider it a double-click and run the rest of the macro. I'm not sure it woudl be quick enough though. Depends on the period. A fast double click might not work. Something weird like that. 

Link to comment
Share on other sites

Slight variation on one of Cory's suggestions:

Activate the macro on a single mouse click, and the first thing the macro does is WAIT FOR LEFT MOUSE CLICK for the minimum time allowable.  Then (if the second click has not occurred) ME should take the error option of halting the macro.  I have not tested this but it's worth a try.  Windows' click logic might get in the way. 

Link to comment
Share on other sites

OK, I tested it.  
Single mouse click at the specified screen location starts the macro.
Double mouse click starts the macro and the Text Box appears.
Single mouse click without the second click results in Macro Express terminating the macro with an error message.  I'm not sure what you can do about the error message, as I doubt that you want it to appear on the screen. 

 

//  
Wait for Left Mouse Click
//  
Text Box Display: ztest
//  
Macro Return

 

Link to comment
Share on other sites

Macro Express log of testing the above macro:

 

SINGLE CLICK
7/24/2022 4:51:38 PM: Macro Started (ztest)
7/24/2022 4:51:38 PM: Line 1: Comment
7/24/2022 4:51:38 PM: Line 2: Wait for Left Mouse Click
7/24/2022 4:51:39 PM: Condition was not met within the specified amount of time
7/24/2022 4:51:46 PM: Macro Completed (ztest)

 

DOUBLE CLICK
7/24/2022 4:51:47 PM: Macro Started (ztest)
7/24/2022 4:51:47 PM: Line 1: Comment
7/24/2022 4:51:47 PM: Line 2: Wait for Left Mouse Click
7/24/2022 4:51:47 PM: Line 4: Text Box Display
7/24/2022 4:51:50 PM: Line 5: Comment
7/24/2022 4:51:50 PM: Line 6: Macro Return
7/24/2022 4:51:50 PM: Macro Completed (ztest)

Link to comment
Share on other sites

Thanks, rberq. The error message makes it a non-starter, but I do appreciate your help.

I decided to go with a hot key activation. Speed is important for executing this macro, so the double click would have been best, but the hot key will be fine.

 

What a great forum--so many people trying to be helpful and responding so quickly.

 

Very nice.

 

Stephen

Link to comment
Share on other sites

I believe if you look at "Handle Error" in the ME Help screens, you will find "On Error", "Catch Error", etc. that would avoid the error message popping up.  Probably you could just exit the macro on a single click rather than double click.  However, if speed is critical, the minimum one-second wait time, waiting for the second click, might be a problem. 

ScreenCapture_7_24_2022_18_07_14.jpg

Link to comment
Share on other sites

Although you resolved the problem by choosing hotkey activation, I was curious what could be done using rberq's idea of catching an error to distinguish between a single and double click.

 

The task appears to be doable in Macro Express, but only if you recruit the middle button instead of the left or the right button. Furthermore, the click must be directed to either specific screen coordinates, or to one of eight parts of a window, including vertical scroll bar, system tray, minimize icon, and maximize icon.

 

This script, triggered by clicking the middle mouse button on a Maximize icon, performs one action if you click once, and a different action if you click twice.

 

Wait for Middle Mouse Click // Catch error if second click does not happen within 1 second
On Error
  Catch Error: Condition was not met within the specified amount of time
    Text Box Display: Middle button clicked ONCE on Maximize icon
  End Catch Error
End Error
Text Box Display: Middle button clicked TWICE on Maximize icon

<WAIT FOR MIDDLE MOUSE CLICK Indefinite="FALSE" Hours="0" Minutes="0" Seconds="1" _HANDLE="0x0014" _COMMENT="Catch error if second click does not happen within 1 second"/>
<ON ERROR/>
<CATCH ERROR Code="20"/>
<TEXT BOX DISPLAY Title="Middle button clicked ONCE on Maximize icon" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs14 \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 CATCH ERROR/>
<END ERROR/>
<TEXT BOX DISPLAY Title="Middle button clicked TWICE on Maximize icon" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs14 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

Link to comment
Share on other sites

It seems like the "System Event" activation with the WM_LBUTTONDBLCLK message should work, but I've never been able to figure out how to use the feature. Paul knew how to do them. I even see an old post of his here with mention of one. It's one of the least mentioned activations in the forum and the least documented. I'd like to get one of these to work someday. I think I'll look into it more this afternoon.

Link to comment
Share on other sites

6 hours ago, acantor said:

but only if you recruit the middle button instead of the left or the right button.

 

acantor, thanks for testing this.  I hadn't figured out how to use the Catch Error command.  But following your example, the macro below works well.  

 

However, I'm not sure what you mean about needing to use the middle or right mouse button.  This macro is started by single-clicking the left button in a designated are of the screen.  If the user single-clicks, Catch Error ends the macro (Macro Return) without doing anything further, and the user never knows it has run.  If the user double-clicks, then the macro continues and can do its business.  

 

(However, if the double-click location is a desktop icon that starts some other program, the other program doesn't start, at least on my PC.  It is as if ME steals the second click, and Windows highlights the icon but doesn't start the program.)    

 

//  
Wait for Left Mouse Click
On Error
  Catch Error: Condition was not met within the specified amount of time
    Macro Return
  End Catch Error
End Error
//  
Text Box Display: ztest
//  
Macro Return


<COMMENT Value=" "/>
<WAIT FOR LEFT MOUSE CLICK Indefinite="FALSE" Hours="0" Minutes="0" Seconds="1" _HANDLE="0x0014"/>
<ON ERROR/>
<CATCH ERROR Code="20"/>
<MACRO RETURN/>
<END CATCH ERROR/>
<END ERROR/>
<COMMENT Value=" "/>
<TEXT BOX DISPLAY Title="ztest" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 ztest running\\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"/>
<COMMENT Value=" "/>
<MACRO RETURN/>

 

Link to comment
Share on other sites

32 minutes ago, rberq said:

However, I'm not sure what you mean about needing to use the middle or right mouse button.  This macro is started by single-clicking the left button in a designated are of the screen.

 

 

Oops, I didn't test by specifying an area of the screen. I tested by clicking on toolbars, maximize buttons, etc. In those cases, you can't use the left or right mouse buttons.

 

Thanks for pointing this out!

Link to comment
Share on other sites

I have moved on; I am happy with my HotKey solution. I use many of my Macro Express macros from Stream Deck and have entered my macro there. I also use a Logitech G609, which has lots of programmable buttons; unfortunately, I use all of them. I was glad when I found this left double click solution for screen grabs. 

 

It surprises me that Macro Express doesn't have double clicking a mouse button as a standard macro because other programs seem able to incorporate it:

 

1.  I use a wonderful, free program, Dexpot (www.dexpot.de), for switching screens. Many of its actions can be set from within the program by user-determined macros. One of those macros can be from left button clicks over an icon. I've set one click over the icon to initiate a screen saver, and a double click over the icon to open a window listing of all open desktops from which I can move windows. None of the macros involve any user programming--they can be set from menus..

2.  I'm a commodities trader. I graph each commodity I'm watching in a separate window. My actions have to be quick because I trade using one-minute charts. The trading program I use is called NinjaTrader. They have an app-sharing forum. A fellow trader posted a program which does a screen grab of the active window by double clicking the left mouse button. I do a screen grab of the active window after each trade for later study, and this seemed like a better solution than the screen grab programs I had tried. NinjaTrader is written in C as is his. His program isn't very complex; I can see that built-in procedures provide most of the logic behind the scenes. His left mouse double click works flawlessly. Unfortunately, it throws an error during the file-saving phase. It creates the file path perfectly, but doesn't actually save the file; however, the double mouse click for instituting the macro seems to work fine.  His program text is very short, so the double click macro had to just need some hooks to built-in C routines. I just discovered the program, but it was written several years ago. I tried messaging the programmer, but he hasn't responded, possible he isn't in the forum any longer. NinjaTrader is always being upgraded, so possibly an upgrade is causing the path issue.
 

My Solution

NinjaTrader has a macro (I've set it to Alt-F9) for saving a screen shot of the active window. When the hot key is pressed, NinjaTrader opens a standard "file save as" "window" which defaults to the last directory used and generates a file name consisting of the commodity name and the time. One just hits enter to use the directory and file name defaults. Because of my lack of programming knowledge, my  solution is rather inelegant: I created a MacroExpress macro which left mouse clicks once over the window I'm hovering over, so that the window is selected. It then enters Alt-F9 to raise the window save screen. I then have a 10 ms pause to make certain that the Save As screen is raised, and then an "Enter" which hits the  "OK" to save the image. This works fine. It's fast and unobtrusive except for a momentary white flash during my pause.

 

Didn't mean to bore anyone, but since several people expressed an interest in this issue, I thought that I'd explain my usage a little more 

fully. 

 

Thanks,

Stephen

 

Link to comment
Share on other sites

3 hours ago, Sgordet said:

I have moved on; I am happy with my HotKey solution

You don't think that will shut us up, do you?😋 😋😋  Us OCD guys (speaking for myself, others may be normal) are like a dog with an old sock, we'll keep shaking around your original question until we get all the goodness out of it. 

 

Seriously, is sounds like you are using a variety of tools to really make the computer work for you.  Good move.  I always told people Macro Express was worth half a person in time savings.  Pretty easy to justify the $35 investment I made to buy the software, way back when.  Macro Express plus the other tools probably multiply your productivity several times over, not just half a person's worth. 

Link to comment
Share on other sites

3 hours ago, rberq said:

Pretty easy to justify the $35 investment I made to buy the software, way back when. 

 

I remember the a-ha! moment shortly after I received a trial version of Macro Express. After about 30 minutes of messing around with the program, I realized Macro Express was going to save me at least an hour that day. Maybe two.

 

I immediately placed an order. My recollection is that I printed out a form, filled it in by hand, and sent it, with payment, via snail mail. This was a very long time ago!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...