[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Re: Two handy AutoHotKey scripts
- Subject: Re: Two handy AutoHotKey scripts
- From: Harry Binswanger hb@xxxxxxxx
- Date: Tue, 14 Apr 2015 01:05:45 -0400
Carl,
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:
SetTimer, WatchActiveWindow, 100 ; put near top of AHK script
.
.
.
If WinActive("EDITOR.EXE") or WinActive("ahk_class ThunderMDIForm") or
WinActive("ahk_class TameConsoleClass") or WinActive("ahk_class
ThunderRT6MDIForm")
{
Suspend On
SetNumlockState, Off
}
else if not GlobalSuspension
{
SetNumLockState, AlwaysOff ; change this
Suspend Off
}
Return
It's also handy, independent of Xy usage to have a button assigned to
toggle AHK into and out of pause. I use the Pause button, natch:
Pause:: ; Pause button to do the suspend
Suspend Toggle
GlobalSuspension:=not GlobalSuspension
Return
From sunny Florida,
Harry
>ot 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@acedsl.com