[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Two handy AutoHotKey scripts



Not for XyWrite per se, but here are two AutoHotKey scripts that you
may find globally useful. I assign them to F1 and F2, keys that I
generally don't use in XyWrite or anywhere else; you can adjust the key
assignments to taste by editing the script files in XyWrite or another
text editor.

Routine 1), SWITCH, allows you to switch focus to any open window by
typing a fragment of the window title ("fire" for Firefox, etc.); if
the program isn't already open, SWITCH opens it (assuming that you've
entered a valid program name). I find this easier than mousing around
to find a particular window when the desktop is littered with them.

Routine 2), RUN, opens a Run dialog, like the Windows Run box but
easily accessible from anywhere via your chosen hotkey. It works as
you'd expect, with the added feature that entering "c" (no quotes)
opens a CMD.EXE command-prompt window. (Entering "cmd", of course, does
the same.)

These scripts are best loaded at startup. Save them to disk and put
shortcuts to them in your Startup folder. (Needless to say, AutoHotKey
must be installed or, at a minimum, AutoHotKey.exe must be in the path.
It's freeware.)

If you're running the latest U2, you already have AutoHotKey; copy the
script files to the directory with EDITOR.EXE and add the following
lines to STARTUP.INT, somewhere after the line that loads U2 (the
actual XPL is attached to this message):

>JM 2.GetPathQ2 >;*;
+"\SWITCH.AHK">JM 2.ahkQ2 ;*;
+"\RUN.AHK">JM 2.ahkQ2 ;*;

Here are the routines (also attached):

1): "Switch to"

; ---------------------------------------------------------
; SWITCH.AHK -- AutoHotKey [CLD rev.4/12/15]
; Switch to running program by entering window title, or unique
;  fragment thereof; if program is not already running, Open it
;
; ***********************************
; Key assignment (change as desired):
F1::
; ***********************************
;
#Persistent
#SingleInstance force
#WinActivateForce
DetectHiddenText, On
DetectHiddenWindows, On
SetTitleMatchMode, RegEx
Prompt = Enter window title or fragment
InputBox, WinTitle, Switch to, %Prompt%,,315,175,,,,10
IfWinExist, i).*%WinTitle%.*
{
 WinActivate, i).*%WinTitle%.*
 Exit
}
Run, %WinTitle%
;
; end SWITCH.AHK
; ---------------------------------------------------------


2): Run dialog

; ---------------------------------------------------------
; RUN.AHK -- AutoHotKey [CLD rev.4/12/15]
; Open a Run dialog
; Entering "C" opens a CoMmanD-prompt window
;
; ***********************************
; Key assignment (change as desired):
F2::
; ***********************************
;
#Persistent
#SingleInstance force
StringCaseSense Off
Prompt = Enter program name or command ('c'=Command prompt)
InputBox, WhatToRun, Run, %Prompt%,,475,180,,,,60
if (WhatToRun = "c")
 {
  WhatToRun = %systemroot%\system32\cmd.exe
 }
Run, %WhatToRun%
; end RUN.AHK
; ---------------------------------------------------------


--
Carl Distefano
cld@xxxxxxxx

Attachment: SWITCH.AHK
Description: Binary data

Attachment: RUN.AHK
Description: Binary data

Attachment: SW-RUN.INT
Description: Binary data