Trigger Script on HotString While Key is Pressed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cryosis
Posts: 2
Joined: 14 Jan 2018, 07:36

Trigger Script on HotString While Key is Pressed

16 Jan 2018, 17:31

I wan't to write a script that will trigger when you type a specific string, while the CTRL key is held.
I.E. trigger when you type '><' and the CTRL key is down.

Since the standard

Code: Select all

^><::
hotkey would trigger when all three are held down, and the hotstring

Code: Select all

::><::
doesn't take into account CTRL being held, I'm not quite sure how one would accomplish this.

I'm sure people have encountered this before; I just don't know where to look.
So either an answer or link to doc/old forum post would make me happy :D
GreatGazoo
Posts: 69
Joined: 28 Dec 2017, 02:53

Re: Trigger Script on HotString While Key is Pressed

16 Jan 2018, 18:52

a normal hotstring wont trigger until the ending key is pressed such as enter or space bar the asterisk gets rid of that requirement,

Code: Select all

;hotstring - pressing "a" twice runs calc.exe
:*:aa::
run, calc.exe
return
;tested
if you want to hold down control you just need to use hotkeys, also the keys your using ("><") require shift to be held down to access,

Code: Select all

;holding control, tapping L runs calc.exe
^l::  
run, calc.exe
return
;tested
taking out shift would look something like this, but it operates as a hotstring not a hotkey so control is NOT held down just tapped

Code: Select all

;tap control then tapping . , runs calc
:*:^.,::
run, calc.exe
return
;tested
though nearly anything is possible, it would take much more lines of code to do it, like get keystate control if down get keystate of . and if . is down getkeystate of , and if , is down run calc.exe

i don't know exactly how to do it, if at all possible you want to keep it simple, use other normal keys and study the tutorial

most people want to mirror keys theyre already using in games or other habits and never consider going outside the habitual hand placements, keep in mind you can use any keys, combination of keys, or string of keys to run macros, scripts, and loops

the ">" and "<" are used as hotkeys to identify the left or right side keyboard keys such as left alt key or right alt key, using the tilde (~) key might turn that off i don't know

Code: Select all

;hold control an press period
*^.::
run, calc.exe
return
;tested
ok i think i managed to figure it out, holding left control and left shift then tapping > then < will execute, holding > then holding < opens a bunch of calculators lol but it seems to work.

Code: Select all

;holding left control and left shift, then >< runs calc.exe
*<^<+><::
run, calc.exe
return
;tested
those are all different ways of running my calculator, pick one that fits you best, hope it was helpful

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Exies, Google [Bot], JoeWinograd, scriptor2016 and 109 guests