Jump to content
Macro Express Forums

Ctrl + Backspace to delete a word left


Recommended Posts

I use Ctrl + Backspace constantly to delete back left at a time, but this hotkey does not work in every context. For example, it works in Word, Outlook, and WordPad, but not in Notebook, not on the desktop when renaming icons, and more.

 

The solution: If you are a macro developer, you think in terms of macros!

 

The basic MEP script is simple enough:

 

<CTRL><SHIFT><LEFT> (Select word to the left)

<BACKSPACE> (Delete the selection; and do nothing if no text is selected)

 

The question: How do you do it in Macro Express so that the it fires continually while holding down Ctrl + Backspace. I can't make it work; it stops working as soon as I check "Activate as soon as the keys are pressed."

 

Edit: The most likely reason the command won't work: Control (Ctrl) is part of the activation (Ctrl + Backspace). The command sends Ctrl + Shift + Left. So my guess is that Macro Express is having trouble handling the Ctrl key...

Link to comment
Share on other sites

The question: How do you do it in Macro Express so that the it fires continually while holding down Ctrl + Backspace. I can't make it work; it stops working as soon as I check "Activate as soon as the keys are pressed."

 

Edit: The most likely reason the command won't work: Control (Ctrl) is part of the activation (Ctrl + Backspace). The command sends Ctrl + Shift + Left. So my guess is that Macro Express is having trouble handling the Ctrl key...

 

Hi Alan,

If a Text Type command is used with a <CONTROL> to be typed out, the state of your physical CTRL key is set to UP (or FALSE if talking boolean). Even though you still have your finger down on the key! That's why you couldn't make your macro repeat.

 

What I did is: I saved the state of the physical CTRL key before the Text Type command, and then restored it right after. Therefore the Text Type command had no impact on the state of CTRL key. Sneaky huh?

However, that's not the end of the problems. When having the macro to [start, act, end] continuously, the only way to adjust the time interval between macro's run was to play with the Keyboard Repeat Speed Factor and Keyboard Repeat Delay Factor. I encountered some problems playing with those factors (the changes weren't applied at the right time... long story) and instead I came up with this macro:

 

<REPEAT START Start="1" Step="1" Count="100" Save="FALSE"/>
<GET KEY STATE Key="Control" Dest="%B[2]%"/>
<TEXT TYPE Action="0" Text="<CONTROL><SHIFT><ARROW LEFT>"/>
<TEXT TYPE Action="0" Text="<BACKSPACE>"/>
<IF VARIABLE Variable="%B[2]%" Condition="\x00" Value="TRUE" IgnoreCase="FALSE"/>
<TEXT TYPE Action="0" Text="<CTRLD>"/>
<END IF/>
<IF VARIABLE Variable="%B[2]%" Condition="\x00" Value="FALSE" IgnoreCase="FALSE"/>
<TEXT TYPE Action="0" Text="<CTRLU>"/>
<END IF/>
<GET KEY STATE Key="Control" Dest="%B[1]%"/>
<IF VARIABLE Variable="%B[1]%" Condition="\x00" Value="FALSE" IgnoreCase="FALSE"/>
<BREAK/>
<END IF/>
<DELAY Flags="\x02" Time="300"/>
<END REPEAT/>

The macro will start when CTRL+BACKSPACE combo is pressed (won't wait for release).

However you need to release BACKSPACE after activating the macro or it will stutter (check for yourself)

The macro will delete one word after another (up to 100 words) with 300 ms interval. To break the loop simply release CTRL.

 

I tested it with notepad. You might need to add some logic to the macro, because it will work different with programs supporting CTRL+BACKSPACE combo natively.

 

Why CTRL+BACKSPACE used in notepad types out "" (the empty square, I don't know the professional name for it)? If that could be disabled somehow it would eliminate the stuttering mentioned above. Or maybe it only occurs on XP?

Link to comment
Share on other sites

Nice work Arek! Thank you for taking on this project.

 

The symbol that appears when pressing Ctrl + Backspace in Notebook has nothing to do with XP. It's been a "feature" since (at least) Window 95. The version of Notebook in Windows 7 does exactly the same thing.

 

A lot of applications do the same thing, including Macro Express. For example, try it in the "Nickname" field, and when editing a comment.

 

It may that this script cannot be made to work without "stuttering," or without performing finger acrobatics (e.g., lift the Backspace key but keep pressing Ctrl.)

 

I will try to build on your work! Thank you!

Link to comment
Share on other sites

Aha! The following script is, so far, working as intended. I will continue testing. Thanks again, Arek, for pointing me in the right direction.

 

Text Type (Simulate Keystrokes): <CONTROL><SHIFT><ARROW LEFT>
Text Type (Simulate Keystrokes): <BACKSPACE>
Text Type (Simulate Keystrokes): <CTRLD>

Link to comment
Share on other sites

Aha! The following script is, so far, working as intended. I will continue testing. Thanks again, Arek, for pointing me in the right direction.

You're welcome!

 

 

You might also wanna play with this:

<LOCK KEYBOARD AND MOUSE/>
<GET KEY STATE Key="Control" Dest="%B[2]%"/>
<TEXT TYPE Action="0" Text="<CONTROL><SHIFT><ARROW LEFT>"/>
<TEXT TYPE Action="0" Text="<BACKSPACE>"/>
<IF VARIABLE Variable="%B[2]%" Condition="\x00" Value="TRUE" IgnoreCase="FALSE"/>
<TEXT TYPE Action="0" Text="<CTRLD>"/>
<END IF/>
<IF VARIABLE Variable="%B[2]%" Condition="\x00" Value="FALSE" IgnoreCase="FALSE"/>
<TEXT TYPE Action="0" Text="<CTRLU>"/>
<END IF/>
<DELAY Flags="\x02" Time="100"/>
<UNLOCK KEYBOARD AND MOUSE/>

No "stuttering" here. The locking and unlocking of the keyboard is introduced to eliminate multiple activations of the macro (unwanted if you need a specified time interval in between).

The problem here: The longer the delay is, the higher the chance of CTRL being left pressed down after the macro terminates and you take your finger off it. There might be a way to alter the code somehow to avoid it. Good luck!

Link to comment
Share on other sites

Please try this and let me know how it compares with a "pure" MEP solution. I'm using AutoIt to do the select and delete operation.

 

Create a macro, activated with Ctrl + Shift + Left Arrow, activated as soon as the keys are pressed.

<EXTERNAL SCRIPT Language="AutoIt" Dest="%tOutput%" Script="Send(\"^+{LEFT}{BACKSPACE}\")\r\n\r\n"/>

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...