Monday, August 1, 2011

AutoHotKey: script structure, tray menus

I like AutoHotKey.

But I find that AutoHotKey scripts often collide, with each other and with other applications. (A problem that GNU Emacs' key binding also has, although elisp's greater programmability provides ways of managing such collisions.)

Therefore, I have structured my AutoHotKey system as multiple scripts, which I only load as necessary. The top level script loads other scripts as desired. Normally I have minimal bindings enabled.

Actually, up until today I had only one binding enabled by default, Ctl-Win-G (G for Glew). As of today, I have removed even that - I now just use the tray menu.

My AHK main script, called "Startup Default Glew Minimal Main Entry Point AutoHotKey,ahk" (there's a story behind the long name) looks like:

AG_AutoHotKey_Folder = ...path...
SetWorkingDir,%AG_AutoHotKey_Folder%
...
#include Glew-Package-Menu.ahk
return


(Eliding details - I'll add some below.)

I use the level of indirection to get to the package menu to allow me to quickly switch stuff around.


The package menu currently looks like:



; This AutoHotkey package exists mainly to load other packages
; via a minimal, single key, keyboard binding.
; I do not want them always loaded, because AutoHotkey is suspect of interfering,
; causing Windows crashes and hangs.


Menu, Glew_AutoHotKey_Package_Menu, Add, Old AutoHotKey, Run_2
Menu, Glew_AutoHotKey_Package_Menu, Add, Glew-AutoHotKey-Bindings, Run_1
Menu, Glew_AutoHotKey_Package_Menu, Add, Display Window Warping, Run_3

Menu, GlewMenu, Add, Glew_AutoHotKey_Package_Menu, :Glew_AutoHotKey_Package_Menu

; Quick summary on Tray Menu
Menu, tray, add
Menu, tray, add, GlewMenu, :GlewMenu

return ; End of script's auto-execute section.

;===============================================================

; Load packages which I do not necessarily want always loaded
; because of key binding conflicts

Run_1:
Run "...Glew-AutoHotKey-Bindings.ahk"
return
Run_2:
Run ".../Old-AutoHotKey.ahk"
return
Run_3:
Run ".../Glew-Display-Window.ahk"
return


TBD: possibly display all packages in a directory.

The lines

; Quick summary on Tray Menu
Menu, tray, add
Menu, tray, add, GlewMenu, :GlewMenu

do what the comment says - they basically add the functionality as a submenu off the tree menu. Which means that the default AHK script requires no key bindings at all, greatly reducing the problems I have had - and also making it easy to recall how to use the AHK macros.

Finally, to the top level script, I have added:

First, stuff to visit my AHK folder and the scriupt called indirectly:


...
Menu,tray,add
Menu,tray,add,visit_AG_AutoHotKey_Folder
Menu,tray,add,edit_Default_Script
Menu,tray,add
...
visit_AG_AutoHotKey_Folder:
Run %AG_AutoHotKey_Folder%
return

edit_Default_Script:
Run Notepad Glew-Package-Menu.ahk
return



Second, stuff to make it easy to find all windows
- I have been plagued by windows getting opened up off any visible display, because I am frequently moving between multi-display configurations:

...
Menu,tray,add
Menu,tray,add,Locate_All_Windows
Menu,tray,add,Locate_and_Restore_All_Windows
Menu,tray,add,Locate_and_Maximize_All_Windows
Menu,tray,add
Menu,tray,add,Maximize_All_Windows
Menu,tray,add,Minimize_All_Windows
Menu,tray,add,Restore_All_Windows
Menu,tray,add
...
;=============================================================================

; "locate" - appears to place the windows at 0,0 of the primary display

Locate_All_Windows:
WinGet, id, list, , , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinGetTitle, this_title, ahk_id %this_id%
winMove,%this_title%,,0,0
}
Return

Locate_and_Restore_All_Windows:
WinGet, id, list, , , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinGetTitle, this_title, ahk_id %this_id%
WinRestore,%this_title%
winMove,%this_title%,,0,0
}
Return

Locate_and_Maximize_All_Windows:
WinGet, id, list, , , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinGetTitle, this_title, ahk_id %this_id%
WinRestore,%this_title%
winMove,%this_title%,,0,0
WinMaximize,%this_title%
winMove,%this_title%,,0,0
}
Return

; --------------------------------------------------------------
; Maximize/Minimize/restore all windows

Maximize_All_Windows:
WinGet, id, list, , , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinGetTitle, this_title, ahk_id %this_id%
winMaximize,%this_title%
}
Return

Minimize_All_Windows:
WinGet, id, list, , , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinGetTitle, this_title, ahk_id %this_id%
winMinimize,%this_title%
}
Return

Restore_All_Windows:
WinGet, id, list, , , Program Manager
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
WinGetTitle, this_title, ahk_id %this_id%
winRestore,%this_title%
}
Return

;-------------------------------------------------------------------
; TBD: close, kill, hide, unhide, show
; for all windows

Wednesday, June 22, 2011

Slow VOIP annoyance.

I am working from my beach house. Using DSL, slower than my usual broadband.

Interestingly, my voice connection is down (probably something to do with the outside phone line hanging by bare wires), but DSL is up.

Anyway, because voice is down I am using VOIP. Works okay, but...

This is a slower connection than I normally use VOIP on. The slowness is definitely felt when I start using Webex, or otherwise do something on my PC. E.g. if the guy I am meeting with starts scrolling his webex, voice drops out for a few seconds. I started falling into the habit of saying "OK, I am going to scroll the presentation now, you won't hear me for a few seconds."

We keep saying "Can you hear me now?" at each other.

Thursday, February 24, 2011

Kluges to OCR PDFs viewed with Google Chrome

I use Google Chrome, if possible.

I have to read a lot of PDFs. (Who doesn't?)

I often need to OCR the PDF - frigging bitmaps... - so that I can search them. I have Adoobe Acribbat installed to supporrt this.

Google Chrome's builtin PDFviewer doesn't OCR. :-(. I can disable it.

Adobe's PDF plugin for Google Chrome uses Adobe Reader. Which doesn't do OCR. So using it isn't all that nice.

If I disable both the Google and Adobe Reader PDF viewer, when I click on a PDF I get the fiole download window. Which is great, although slow, and although I often end up downloading the same PDF multiple times.

What I want is the ability to use Google Chrome's PDF viewer, and then fliip to Adobe Acrobat. Which is doable, through the hassle of savving to a file, etc., and then reopening with Acrobat.

Tuesday, June 29, 2010

Ahhhh....

Running SpinRite.

Meanwhile, I can do some work on my personal PC. Not real work, but at least i can browse webpages and read manuals. I.e. learn. Which was actually what i was doing when these reliability problems (3 hangs, and OneNote data lossages) happened.

I may already have noted this, but:

A few months ago I read an article in some CEO or Entrepreneur magazine. (No, I don't normally read such; it was the best choice while waiting for my shawarma).

Rough title: "habits and tricks of web CEOs".

Of special note: of circa 10 interviewees. 3 or 4 said that one of the best "tricks" was having extra PCs. So that when one Pc was hung or rebooting, you could work on the (or an) other PC.

Which is basically what I am doing now, and have been doing since this flurry happened: rebooting and/or doing preventive maintenance (SpinRite) on one PC, while continuing to work on another PC.

I'm using physical PCs.

I wonder if virtual PCs would be similar. E.gl. I wonder if I worked in virtual machines on top of my main PC, if a useful fraction of bugs would occur in one virtual machime - which I could reboot, while working on the others.

Versus, bugs that hit the VMM itself. On the host.

I suspect that it would be useful. There will always be bugs on the host. E.g. display driver bugs. But I suspect that most bugs are due to application or OS (guest) problems. (Although perhaps not today, if my fear about hard disk sectors going bad is conformed by SpinRite.)

Best if the guest VMs are isolated. But nobody wants full isolation. E.g. ultimately I want all of my work to be in one place. Especially if using cloud apps from either guest VM: the cloud apps could be a single common point of failure.

It might be nice is work was done into a replicated, distributed, version control system. Like git. Then work separately, and merge when (if) both mguest VMs are up.

OneNote bug

While I am ragging on OneNote, a bug reprt - NOT the lossages reported earlier:

When I hit alt-i r
to cut and paste a screenshot

sometimes it works
and sometimes (like now; actually, like 1 minute ago - NOW it works; anyway, the bug):

all screens/displays go blank, and can see nothuing to cut and paste.


--


Now let's figure out where to reporrt this bug to,

---


Everyone needs a personal bug tracking system.

E.g. I report bugs to my issue tracker, and then send it to the cpmpany selling the product.

A federation of issue trackers.

Tuesday, March 9, 2010

Tearing up the AAA Parking Lot

Workers were tearing up the AAA parking lot this morning.

No big significance. Just seemed like a bon mot. AAA = American Automobile Association. Building next to where I work. Lobbyists for many automotive related issues, often speaking out against using gas tax for anything other than highway construction.

Dell Docking Station Power (Non)Problem

This morning had trouble getting the docking station for my Dell Latitude 830 laptop (the docking station sports model number PR01X) to power up.

This was bad, because all of my USB monitors and keyboard and trackball and numeric keypad are driven through the docking station.

After thrashing - rebooting twice, etc. - realized there is a simply fix:

Unplug the docking station AT THE DOCKING STATION (not at the AC wall plug). And then replug. This causes the docking station lights to get all happy and green.

Why this should be, I do not know.