Jump to content
Macro Express Forums

What's your "best" macro of 2022?

Recommended Posts

This simple macro that I developed last summer hasn't made my life any easier, but it's simplifying someone else's. It's a way to drag the mouse using the absolute minimum amount of physical effort: no clicks, no holding down mouse buttons. All he has to do is point to the starting location, point to the end location, and the macro does the heavy lifting.


Due to a congenital condition, this guy has limited hand strength. Holding down mouse buttons becomes very tiring very fast. But some tasks he performs MUST be done by dragging. There's no keyboard equivalent.


Here's how the macro works:


1. He hovers the mouse pointer over the location the drag will start. (No need to click.)


2. He triggers the macro.


3. The macro waits five seconds while he moves the pointer to the target location. (Again, no need to click.) We started with a two second wait, but found it wasn't always enough time.


If he's selecting text: the words between the start and target location get selected.


If he's dragging an object: the object moves from the start location to the target location.


Here's the script:


Mouse Left Button Down
  Delay: 5000 milliseconds
Mouse Left Button Up	


  • Like 1
Link to comment
Share on other sites

acantor, this isn’t as socially useful as your three-liner, but it was fun and helpful:


A simple macro I wrote long ago, with one keystroke (Keypad minus) closes the current application, usually by
    Text Type (Simulate Keystrokes): <ALTD><SPACE>c<ALTU>
In browsers and in the Adobe Reader it will close only the current browser tab or PDF if more than one is open, otherwise closes the whole thing.


But a very useful change added recently involves closing without saving changes.  For example, I plug some trial numbers into a spreadsheet to see their effect, but don’t want to save the changes.  Or maybe I edit a Word document but decide to scrap the changes because they are not up to my usual Shakespearean standards.  So when I trigger the “close” macro the application doesn’t close, but instead pops up a box asking if I want to save my changes.  Then I have to move from keyboard to mouse to click “No”, or reposition my hands on the keyboard to type “n”.  


Seems trivial, but it’s a pain and I’m impatient.  So I changed my “Close” macro so if it runs twice within 1/2 second, the second execution types “n” instead of <ALTD><SPACE>c<ALTU>.  If I tap the hot key once, it is a normal close.  If I tap it twice rapidly, it closes and types "n" to scrap the changes.  


Link to comment
Share on other sites

Very nice, rberq! I'd be curious to learn how your macro detects the second key press.

Once upon a time, I wrote a macro activated by Esc. If I pressed Esc once, the macro outputted Esc. If I pressed it twice, the macro outputted Esc twice. But if I was impatient and quickly pressed Esc three times, the macro closed the current window.

I eventually gave up on this macro. Initially it was fun to watch a window close by being persistent with Esc. But after a few days, I tired of the delay when pressing Esc once, as the macro doesn't send keystrokes until the last line of the script.


(I press Esc dozens or hundreds of times a day, so I found the delay too noticeable.)


But your idea of only waiting for a second key press might be the solution that eluded me. Simplicity trumps cleverness!

Link to comment
Share on other sites

11 hours ago, acantor said:

Very nice, rberq! I'd be curious to learn how your macro detects the second key press.


I could not get "wait for keystroke" to work consistently, so I gave up that method of detecting the second key press.


(1) The first thing the macro does is find the previous date/time that it ran, which should have been stored in a text file.  If the file doesn't exist, a dummy (very old) date/time is used instead.  (Could have stored date/time in an environment variable, registry key, or whatever, but text files are easy.)

(2) Current date/time of this execution is obtained, and stored in the text file (for next time).

(3) If current date/time is more than 1/2 second after previous run time, macro types the close application sequence.  If within 1/2 second, type "n" so changes won't be changed. 


// Get previous execution time of this macro from file if file exists
// If file does not exist, make up a very old time for previous execution
If File Exists: "C:\Temp\Date_Time_Macro_String.txt"
  Variable Set String set %PREVIOUS_STRING_DATETIME% to the contents of C:\Temp\Date_Time_Macro_String.txt
  Variable Modify String %PREVIOUS_STRING_DATETIME%: Convert to Decimal (%PREVIOUS_DECIMAL_DATETIME%)
  Variable Set String %PREVIOUS_STRING_DATETIME% to "111.111"
  Variable Modify String %PREVIOUS_STRING_DATETIME%: Convert to Decimal (%PREVIOUS_DECIMAL_DATETIME%)
End If


// Current date/time into file
Date/Time: Set %DATETIME% to the current date/time
Convert Date/Time to Decimal: %DATETIME% => %DECIMAL_DATETIME%
Variable Modify Decimal %DECIMAL_DATETIME%: Convert to Text String (%STRING_DATETIME%)
Variable Modify String: Save %STRING_DATETIME% to "C:\Temp\Date_Time_Macro_String.txt"


// How long since previous execution of this macro


If Variable %TIME_DIFFERENCE% Is Less Than "0.000005787" // one-half second as a fraction of a day


  • Thanks 1
Link to comment
Share on other sites

  • 4 weeks later...

A client of mine is a slow typer and looks at the keyboard as he types. He gets really frustrated when he finds he's typed lots with caps lock on so I wrote this macro on ALT+CTRL+SHIFT+C to copy the selected text and invert the casing:


Clipboard Copy
Variable Set String %T[1]% from the clipboard contents
Variable Set String %T[2]% to ""
Variable Set Integer %N[1]% to the length of variable %T[1]%
Repeat Start (Repeat %N[1]% times)
  Variable Modify String: Copy a substring in %T[1]%, starting at %N[2]% and 1 characters long to %T[3]%
  Variable Set to ASCII Value %T[3]% to %N[3]%
  If Variable %N[3]% Is Greater Than "64"
  If Variable %N[3]% Is Less Than "91"
    Variable Modify Integer: %N[3]% = %N[3]% + 32
    If Variable %N[3]% Is Greater Than "96"
    If Variable %N[3]% Is Less Than "123"
      Variable Modify Integer: %N[3]% = %N[3]% - 32
    End If
  End If
  Variable Set to ASCII Char %N[3]% to %T[3]%
  Variable Modify String %T[2]%: Append Text (%T[3]%)
End Repeat
Text Type (Simulate Keystrokes): %T[2]%

Link to comment
Share on other sites

Earlier in this thread, I shared my "best" macro of 2022, which holds down the mouse button for five seconds and then releases it. 


This afternoon I've been experimenting with ChatGPT. It's surprisingly good. Much better than I expected.


In a moment of levity, or perhaps of optimism, I asked ChatGPT a question about Macro Express:


Write a Macro Express script to temporarily hold down the left mouse button


The AI-generated response is fascinating, although I think ChatGPT may have been hallucinating about how Macro Express works!


Here's a simple macro script in Macro Express that will temporarily hold down the left mouse button:

  1. Open Macro Express and create a new macro.

  2. In the "Keyboard/Mouse Action" section, select "Press and Hold Mouse Button."

  3. In the "Button" section, select "Left."

  4. In the "Duration" section, specify how long you want the left mouse button to be held down.

  5. Add another action, "Release Mouse Button."

  6. In the "Button" section, select "Left."

  7. Save the macro and assign a keyboard shortcut or set it to activate on a schedule or specific window.

This script will cause the left mouse button to be held down for the specified duration and then released. You can adjust the duration as needed



ChatGPT's database mostly contains information gleaned from the web prior to 2021, so this inaccurate but plausible-sounding answer wasn't pulled from this thread.
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.

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.

  • Create New...