Controlling where the cursor will end up - autohotkey

I want to write a macro that will leave cursor in the middle of the two senteneces. But so far i have failed to do so. Either nothing is happening or SendInput is displayed on the screen.
What i want it to look like;
Greetings,
Cursor here
With regards.
What i have tried so far,
::/gre::
(
Greetings,
With regards.
)
SendInput {Up 3}
return
or
::/gre::
(
Greetings,
With regards.
)
SendInput {Up 3}
return
I couldn't find any examples on combining these two.

Try the Text mode
::/gre::
Send {text}
(
Greetings,
With regards.
)
SendInput {Up 3}
return

Related

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

AutoHotKey: Remap Alt, Ctrl, and Alt+Ctrl

I'd like to use AutoHotKey to remap:
RAlt::Volume_Down
RCtrl::Volume_Up
RAlt & RCtrl::SendInput {Volume_Mute}
While Vol up works fine with the script as above, vol down is non-repeating & mute only works if the buttons are pressed as Alt,Ctrl (not Ctrl,Alt). I understand why, I just haven't been able to come up with a solution. I can map either volume up/down or mute - but if I try to do both, the behavior is always finicky. I think what I need is something to the effect of:
if GetKeyState("RAlt") and GetKeyState("RCtrl")
{
SendInput {Volume_Mute}
}
else if GetKeyState("RAlt")
{
SendInput {Volume_Down}
}
else if GetKeyState("RCtrl")
{
SendInput {Volume_Up}
}
But this just runs & terminates. Is there a way to achieve what I'm after?
The problem with your solution is that RAlt & RCtrl::SendInput {Volume_Mute} turns RAlt into a "prefix key" and according to the Hotkeys section of Autohotkey help "The prefix key loses its native function".
Try this instead:
RAlt::Volume_Down
RCtrl::Volume_Up
#if GetKeyState("RAlt", "P")
RCtrl::Volume_Mute
#if GetKeyState("RCtrl", "P")
RAlt::Volume_Mute

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

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

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

Konami Code on autohotkey

up up down down left right left right b a enter :: Msgbox, konami code.
is there a way to do this?
yes its actually pretty simple...
comb := "up|down|down|left|right|left|right|b|a|enter"
~up::
Loop, parse, comb, |
{
input, var,T.900,{%a_loopfield%}
if inStr(ErrorLevel, "Timeout")
return
}
msgbox Konami Code!!!
return
The first "up" is the one that will trigger the sequence hence only one "up" in the combination variable.
you can change the combination to whatever you want, but then you would have to change the hotkey to the first "key" that you want to press.