How to SendInput the following string: {\color{red} TO-DO} - autohotkey

I would like to have a hotstring in AutoHotkey such that, when I type the string ltodo
the following literal is printed: {\color{red} TO-DO}
I tried to do this in autohotkey:
:R*?:ltodo::
SendInput, {\color{red} TO-DO}
return
with no luck, as it prints the string TO-DO only.
How can I make it print the literal: {\color{red} TO-DO}

:R*?:ltodo::{\color{red} TO-DO}
But if you are genuinely wanting to know how to accomplish this with Sendinput:
:R*?:ltodo::
Sendinput, {raw}{\color{red} TO-DO}
Return
The functionality of these two examples is basically identical;
because SI is the default mode for hotstrings.

Solution:
::ltodo::
SendRaw {\color{red} TO-DO}
return

Put the brackets between brackets like this.
*:R*?:ltodo::send, {{}\color{{}red{}} TO-DO{}}*
Sorry, in combining the 3 lines to 1, I left the send command...It had to be:
:R*?:ltodo::{{}\color{{}red{}} TO-DO{}}
Personally, I would probably use one of the following shortcodes:
td/ or td\ or even just a double \\

Related

How do I escape the '+' characters in an AutoHotKey, with the date script?

I use AutoHotKey to display actual date.
here is the code :
:*C:]d:: ; This hotstring replaces "]d" with the current date and time via the commands below.
FormatTime, CurrentDateTime,, yyyy‑MM‑dd ‒ HH'H'mm '(UTC+1)' ; It will look like 2005-01-09 15H53 (UTC+1)
SendInput %CurrentDateTime%
return
But the result miss the '+', I used "`" or "",
both not vrog.
Thank pro help.
Good day and long and happy life.
Use the text send mode.
:*C:]d:: ; This hotstring replaces "]d" with the current date and time via the commands below.
FormatTime, CurrentDateTime,, yyyy‑MM‑dd ‒ HH'H'mm '(UTC+1)' ; It will look like 2005-01-09 15H53 (UTC+1)
SendInput, {Text}%CurrentDateTime%
return
Also, if you'd want to ditch the legacy AHK syntax, you'd do this:
:*C:]d::
FormatTime, CurrentDateTime, , % "yyyy‑MM‑dd ‒ HH'H'mm '(UTC+1)'"
SendInput, % "{Text}" CurrentDateTime
return

How to map semi-colon then Esc to something other in AutoHotkey?

How to set up AutoHotkey so that when I press semi-colon then Esc ;esc in order, it will instead do something other?
:?*:;Esc::
msgbox, hello world
;; do something
;; Send, {BACKSPACE} ;; remove the ; at last
return
I think you might not be able to do it with hotstrings, but instead with a regular hotkey. Also, I think you'll need to change the comment flag to something else that isn't a semicolon. Here's my attempt:
#CommentFlag //
~;::
KeyWait , Esc , DT2
If !ErrorLevel
{
Send , {backspace}
msgbox
}
Return

How to input English-Character in non-English keyboard

I'm a Chinese guy.This question trapped me very long time.This is my current method to input English-Charater ()in my Chinese-input-method:
^b::
ClipSaved := ClipboardAll
Clipboard=()
Send ^v
Clipboard := ClipSaved
Return
But,I really don't want to call the clipboard to do this thing,and the clipboard method is inconvenient to input multi-line text.Any better suggestion can give?
Note it is () but not ()
How about sending the ASCII values for left/right parentheses?
F3::
SendInput, {ASC 40}{ASC 41}
return
Output:
()
Edit for the comments:
Say we want to use other ASCII characters, such as curly braces: {}
Their decimal representations are 123 and 125 respectively.
So
F3::
SendInput, {ASC 123}{ASC 125}
return
Gets you:
{}

Can I list several keys to perform the same action? [AHK]

AHK allows to bind keys, that is us a::z t fire 'z' whenever 'a' is pressed.
What if I want to fire 'z' whenever 'a', 'b', or 'c' is pressed?
I can obviously repeat my code:
a::z
b::z
c::z
I can probably use a Gosub like
a::Gosub, abc
b::Gosub, abc
c::Gosub, abc
abc:
send z
return
Is there a better way to say "if a,b, or c are pressed - fire z"?
You can just use
a::
b::
c::z
i am not sure what is the exact synthax, but this works.
We're at codegolf.stackexchange.com, right?
JFF, here's assigning A-Y to Z with just 61 characters, using the Hotkey command:
loop,25
hotkey,% chr(a_index+64),z
return
z(){
send z
}
Another solution using Hotkey to define hotkeys on the fly, and parse so that the user can directly specify a list of keys:
; Thanks engunneer: autohotkey.com/board/topic/45636-script-to-prevent-double-typing/?p=284048
; Thanks throwaway_ye: https://www.reddit.com/r/AutoHotkey/comments/54g40q/how_can_i_bind_several_keys_to_the_same_command/d81j0we
; The following part must be located in the auto-execute section,
; i.e. the top part of the AHK script.
keylist = 1234567890qwertzuiopasdfghjklyxcvbnm
Loop, parse, keylist
{
Hotkey, $%A_LoopField%, SendGivenKey
}
Return
; This can be located anywhere in the AHK file
SendGivenKey:
StringReplace, key, A_ThisHotkey, $, , All
send %key%
Return

Place text from inputbox in a string

I'm looking for a ahk script to do the following:
Show popup box
Enter text
Show standardtext + string in popup box.
So that when for example I press #r i get a popup box, i type in Marc and I get
"dear regards Marc".
So in Java it would be be something like
var1 = inputBox("whats your name")
var NameRegards = function(text){
"dear regards" + var1
}
show NameRegards
Anybody a clue how I can manage this in ahk?
How about doing it exactly as you described?
InputBox, varName, Name input, What's your name?
MsgBox , , Output, Dear regards %varName%
Works fine for me.
Here is an untested start..
#SingleInstance Force
#Persistent
Return ; Stop the startup lines otherwise #r will run on startup...
#r:: ; [Win]+r to start this script
InputBox, MyName, This is your Windows Title, Type your name:
SendInput, Dear regards`, %MyName% ; Using `(On ~ key on US KB) to literally print a comma
; SendInput, % "Dear regards, " MyName ; Alternative way
Return