[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Re: One (was two) handy AutoHotKey script
- Subject: Re: One (was two) handy AutoHotKey script
- From: Carl Distefano cld@xxxxxxxx
- Date: Tue, 14 Apr 2015 13:56:38 -0400
If you don't want your AHK scripts to interfere with XyWrite's kbd
assignments, here's a little script that pauses AHK whenever EDITOR.EXE
(or NotaBene or Tame-Xy) has the focus:
Thanks, Harry, I'll hold on to that for future reference. Here, though,
I want a key that will work the same both inside and outside of XyWrite.
I've now combined the two scripts into one, RUN.AHK, and added "alias"
capability. As Kari said yesterday, this allows you to control Windows
with short, XyWrite-like commands. Aliases are assigned in RUN.INI,
which should be located in the same directory as RUN.AHK.
The script handles the Run and Switch-to functions as follows: If the
command input contains ":" or ".", it Runs it; if the program is already
running, this may open a new instance, or it may simply switch to the
running instance. If the input contains neither ":" nor ".", the script
assumes that it's a window title (or title fragment) and attempts to
switch focus to it. Thus, entering "FIREFOX.EXE" (or an alias of it)
will open a new instance of Firefox (because of "."), whereas "FIREFOX"
(or its alias) will switch to Firefox if and only if it's already
running. Hint: entering "RUN.INI" will open RUN.INI for editing in your
default text editor.
Below are the script and my INI file (the latter by way of example).
; ****************************************
; RUN.AHK -- AutoHotKey [CLD rev.4/14/15]
; Open|Switch to program, folder, URL, etc., etc.
; Create aliases (abbreviatons) in RUN.INI under "[Run]"
;
; Key assignment (change as desired):
F1::
;
#Persistent
#SingleInstance force
#WinActivateForce
StringCaseSense, Off
DetectHiddenText, On
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
SplitPath, A_ScriptFullPath,,IniDir,,IniFile
IniFile = %IniDir%\%IniFile%.INI
Prompt = Enter program name, window title or alias
InputBox, WinTitle, Run, %Prompt%,,315,135,,,,10
IniRead, KeyValue, %IniFile%, Run, %WinTitle%, %A_Space%
If (StrLen(KeyValue) > 0)
{
WinTitle = %KeyValue%
}
colon = :
dot = .
If ( InStr(WinTitle, colon) > 0 or InStr(WinTitle, dot) > 0)
{
Run, %WinTitle%
Exit
}
IfWinExist, i).*%WinTitle%.*
{
WinActivate, i).*%WinTitle%.*
}
; end RUN.AHK
; ****************************************
; ****************************************
; RUN.INI
; Usage:
; Alias=command|window_title
[Run]
; Section name "[Run]" is *required*.
;
A="C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"
AHK=http://www.autohotkey.com/docs/commands.htm
B=
C=cmd.exe
D=http://dictionary.reference.com/wordoftheday/
E="C:\Program Files\Just Great Software\EditPad Pro 7\EditPadPro7.exe"
F=Firefox
FF="C:\Program Files (x86)\Mozilla Firefox\firefox.exe"
G=http://www.google.com/
K="C:\Program Files (x86)\Amazon\Kindle\Kindle.exe"
NEWS=http://news.google.com/
NYT=http://www.nytimes.com/
P="C:\Program Files (x86)\Google\Picasa3\Picasa3.exe"
PY=http://docs.python.org/3/library/
R="C:\Program Files (x86)\Blueberry Software\BB FlashBack Standard
4\FlashBack Recorder.exe"
S=C:\Users\CLD\Desktop\Startup
Stars=C:\Users\CLD\Desktop\Celestia.lnk
T="C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe"
W=winword.exe
WP=http://www.washingtonpost.com/
X=vDosXy
XX=F:\vDosXy\VDOSXY.BAT XYB
XG=F:\vDosXy\VDOSXY.BAT XYG
X3=F:\vDosXy\VDOSXY.BAT XY3
; end RUN.INI
; ****************************************
--
Carl Distefano
cld@xxxxxxxx