AutoHotKey: go through a List of Text wirh Key - autohotkey

I am realy new on ahk.
Is it possible to have a list of text and go trough that list with F12?
A
B
C
If i press F12 show msg Box with A and when i press again F12 it shows B
Is that possible?
Thanks
Skadie

This maybe can give you some ideas..
#Persistent
text = A B C
array := StrSplit( text, " " )
Return
F12::
i++
if i > array.Count()
i = 1
MsgBox % array[i]
Return

Related

How to have "input" (or is it context?) dependent hotstrings/hotkeys ?

I want a hotkey or hotstring (whatever is easier), so I can easily convert e.g.
1:5 into [1,2,3,4,5] or
3:7 into [3,4,5,6,7] etc..
I want this to work for all integers...
So I want "multiple variants of the same hotstring" (or, if easier: a hotkey that works somewhat similar: e.g. pressing strg + h and typing 1:3 should produces [1,2,3] )
It should recognize that I typed a number followed by colon followed by another number, and then expand correspondingly..
I looked into the Input function, but it does not seem to be exactly what I want..
I don't need a working solution. Hints & links or keywords for further googling are already helpful..
After typing +h or pressing strg+h, type two numbers to produce the desired outcome:
:*:+h::
^h::
nr := "" ; empty variable's content
end_nr := ""
Input, var, L2 ; Length limit=2
; Input, var, L2 V ; V: Visible
If var is not integer
{
MsgBox, "%var%" is not integer
return
}
first_nr := SubStr(var, 1, 1)
second_nr := SubStr(var, 0)
if (first_nr >= second_nr)
{
MsgBox, "%first_nr%" is greater or equal "%second_nr%"
return
}
Loop
{
nr++ ; increase the number in the variable "nr" by 1 in each iteration
if (nr < first_nr)
continue
If (nr = second_nr)
break
end_nr .= nr . "," ; concatenate the outputs by adding a comma to each one
}
If (first_nr = 0)
MsgBox, "0,%end_nr%%second_nr%"
else
MsgBox, "%end_nr%%second_nr%"
return

AutoHotkey's for the arrow keys

I would like to hold
alt + spacebar + U for the up key
alt + spacebar + H for the left arrow key
alt + spacebar + J for the right arrow key
alt +spacebar + N for the down arrow
is this possible to do with AutoHotkey?
Hello and welcome to AutoHotkey,
you might want to have a look at the basic introduction to the heart of AHK, Hotkeys:
https://www.autohotkey.com/docs/Hotkeys.htm
Configuring hotkeys which do nothing but send another key is fairly simple. For example, alt + spacebar for the up key could be translated into
!Space::
send {up}
return
(note that alt is a modifier and can be written as !)
or short form:
!Space::send {up}
spacebar + U for the up key would be Space & U::send {up}.
But you are seeking for 2 keys PLUS a modifier (alt). For a hotkeylabel triggered by more than just two keys (alt + space + u), you'll need a workaround:
!Space:: ; once alt + space was pressed, ...
while(getKeyState("alt") || getKeyState("space") || getKeyState("u")) { ; ... while either of these is being pressed down, ...
hotKey, *u, altSpaceU, ON ; u should now send {up}
}
hotKey, *u, altSpaceU, OFF
return
altSpaceU: ; note: this is a label, no hotkey
send {up}
return
Please, don't be undeterred by this. AutoHotkey is actually quite powerful and easy to learn. Sadly, (afaik) this is the only working way to solve more-than-two-key-hotkeys.
EDIT
jesus why didnt anybody tell me..
#if getkeystate("alt")
!space::send {up}
#if
is obviously a way better solution
this was the solution
!Space::
send {up}
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

AutoHotKey KeyWait statements

I'm using AutoHotKey and I want to achieve something particular.
I have an hotkey that should perform a certain action, inside this hotkey, I would like to code something to detect if I only press the "C" key, or if I press "C" then "L" keys.
If there is only the "C" key pressed, then it should perform an action, otherwise , if "C" then "L" keys are pressed it should do another action.
But I can't do this as I don't really understand KeyWait, I mean how can I do something like that :
if(KeyWait, C){
firstAction
else {
if(KeyWait, C){
if(KeyWait, L){
anotherAction
}
}
Solved using the input function.
; Get one character and store it in the Character variable
Input, Character, L1
If Character = C
{
; Give up to half of one second to type L
Input, Character, L1 T0.5
If Character = L
MsgBox % "We have C and L"
else
MsgBox % "Just C here, give an L next time"
}

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.