Hold down ALT, press few keys, release the ALT key. Script completes an action. How do I do this?

Get help with using AutoHotkey and its commands and hotkeys
AverageBrick
Posts: 2
Joined: 21 May 2016, 10:58

Hold down ALT, press few keys, release the ALT key. Script completes an action. How do I do this?

26 Jul 2016, 11:16

Basically I want a script that will allow me to open programs. How? I want to press and hold down ALT key, while holding ALT I would enter 1, 2, 1 and then release the ALT key. That's it

Simplified:

{Alt down}
{1}
{2}
{1}
{Alt up}
*script opens a program (for example: "C:\Dropbox\text.txt")*
User avatar
megnatar
Posts: 83
Joined: 27 Oct 2014, 20:49
GitHub: Megnatar
Location: The Netherlands

Re: Hold down ALT, press few keys, release the ALT key. Script completes an action. How do I do this?

26 Jul 2016, 14:18

This is explained at the very beginning of the help file. It's actually the first topic. You should read it for it will be you're guide in understanding AHK and programing in general.
Read topic Basic Usage and Syntax -> Hotkeys.

The most basic way to do what you want is:

Code: Select all

#NoEnv
#Persistent

!1::Run "C:\WINDOWS\hh.exe" C:\Program Files\AutoHotkey\AutoHotkey.chm
!2::Run Iexplore.exe
!3::Run cmd /k Ipconfig /all
!4::Run explorer shell:::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\::{00000000-0000-0000-0000-123456749822}
!5::Send {Rwin down}{d down}{Rwin up}{d up}
!6::ExitApp
or

Code: Select all

#NoEnv
#Persistent
SetWorkingDir %A_ScriptDir%


LAlt::
Keywait, 1, D			;Wait forever for key 1 to be pressed down.
If errorlevel = 0		;Errorlevel is set to zero the moment key 1 is down.
Keywait, 2, D
If errorlevel = 0
Keywait, LAlt			;Wait forever for the alt key to be released.
If errorlevel = 0		;On release errorlevel = 0
FileAppend, Many ways to achieve the same goals`, Consult the help file!, %A_ScriptDir%\SomeFile.txt
Run Notepad  %A_ScriptDir%\SomeFile.txt
exitapp
ps: code is not tested

Return to “Ask For Help”

Who is online

Users browsing this forum: ArkuS, Bing [Bot], CapoPM, Google [Bot], rakesha002, vieska and 210 guests