Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to automatically get ride of a space char at the end of autotext



  • Please log in to reply
4 replies to this topic
OM2
  • Members
  • 190 posts
  • Last active: Nov 06 2015 10:32 AM
  • Joined: 26 May 2010

I have several autotext setup, like:

 

::]mytext::My ready made text shortcut

 

How do I automatically get rid of a space char after pressing the space bar?

I can't just add a backspace, since I might press the return key instead of space to execute

 

I would have to detect if the space bar was the last key pressed?

Seems a bit overkill?

 

Thanks

 

 

OM

 



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012
✓  Best Answer

I had to play around with this a bit, but this seems to work:

 

::]mytext::
SendInput % "My ready made text shortcut" ((A_EndChar=A_Space)?"":A_EndChar)
return

 

It uses Ternary and Expression syntax. I use the built-in variables A_EndChar and A_Space.

 

If you have any questions on this, fee free to ask.



OM2
  • Members
  • 190 posts
  • Last active: Nov 06 2015 10:32 AM
  • Joined: 26 May 2010

@Exaskryz... oooh... that is soo clever. :)

thank u. problem solved.



OM2
  • Members
  • 190 posts
  • Last active: Nov 06 2015 10:32 AM
  • Joined: 26 May 2010

@Exaskryz just wondering... how can i make into a one line entry?

like:

::]mytext::My ready made text

i will have 50 entries similar. its convenient to add more entries by copying the above...

 

else... have can i shorten what u have given by putting into a formula?

 

like maybe i can have loads of one line entries like:

myFunction(]mytextshortcut, "My ready made text") 

not sure where to start

 

thks



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

There isn't a way to do ::SendInput % "testing" ((A_EndChar=A_Space)?"":A_EndChar)::, as it doesn't recognize the "SendInput" as a command, but only as a string of text to send. You won't be able selectively modify the behavior of ::]mytext::My ready made text and how an ending character would behave differently, but as I mentioned in another thread of yours using :o:]mytext::My ready made text would omit the ending character, even if that is a return character. However, you might be intersted in doing the asterisk option :*:]mytext::My ready made text which activates even if you do not have an end key. In otherwords, as soon as you press the last "t", your autoreplacement takes effect. I do not know if this is acceptable for you. It would depend if your final product does use unusual characters such as ] to start the hotstring.

 

I want to say someone has shared a dynamic hotstring script before, but I'm not entirely sure how that worked or if that is applicable here.

 

It is a pain that it seems you'll have to use multiple lines to get many hotkeys to behave as you wish.