AHK Offline HELP (.chm) Keyboard Shortcuts

Post your working scripts, libraries and tools
Posts: 314
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

AHK Offline HELP (.chm) Keyboard Shortcuts

01 Apr 2018, 10:27

Well, it's about time I started sharing some code.... and, with all the problems lately with the OFFLINE HELP, I've written a set of Keyboard Shortcut HOTKEYS for AHK OFFLINE HELP (.chm file). They probably work with any .chm file.

I define 10 hotkeys, F1-8, F11 and F12. (Personally, I never use F1 for Help anywhere.)

Keys F1 - F8 are each associated with the HELP Navigator Bar buttons: Content, Index, Search, View/hide Sidebar, Back, Forward, Magnify and Print. In a nutshelll, each simply clicks that button. F11 and F12 set FOCUS on the SIDEBAR and INFO AREA (does it have a better name?) respectively. To focus the INDEX or SEARCH EDIT BOX, use F2 or F3.

Enjoy. All comments and critiques are welcome. And, yes, I know I've defined a couple variables (for the sake of consistency) that never get used. What's 20 cpu cycles when it comes to maintainablility and readability?

PERSONALIZATION: You probably have to change 1 value below: BUTTONWIDTH. Buttons 4-8 (View/hide Sidebar, Back, Forward, Magnify and Print) are of varying (although nearly equal) widths. BUTTONWIDTH just needs to be a good approximation of the width (in pixels) of each of those buttons. (Yes, I could do it using Pixelsearch, but really... for every use? waste of coding time and processor time).

The following was written on and tested on only Windows 7 Pro, using AHK .chm file.

Code: Select all

;=========                                    AutoHotkey Help                                         ===========
;    Author - J.S.Petree, 20180401                                          
#IfWinActive, AutoHotkey Help
F1::                             ; F1 - AHK Help - Content Button
F2::                             ; F2 - AHK Help - Index Button
F3::                             ; F3 - AHK Help - Search Button
   gosub, GetHelpMetrics         ; Get Sidebar width and Nav Bar width and height
   coordmode, mouse, client
   if sbw                        ; Press button 1 2 or 3
      mouseclick, L, (substr(a_thisHotkey,2,1) - .5) * sbw / 3, nbh / 2
F4::                             ; F4 - AHK Help - Show/Hide Sidebar (toggle)
F5::                             ; F5 - AHK Help - Back
F6::                             ; F6 - AHK Help - Forward
F7::                             ; F7 - AHK Help - Magnify
F8::                             ; F8 - AHK Help - Print
;      Note:  BUTTONWIDTH is a close approximation of the average button width of
;             navigation bar buttons 4-8.  They are not all the same width!  Ahhh...
;             change this to adjust for your Window dimensions.
   buttonWidth := 62             ; ***** CHANGE THIS TO SUIT YOUR MONITOR *****
   gosub, GetHelpMetrics         ; Get Sidebar width and Nav Bar width and height
   coordmode, mouse, client
;     Divider between buttons 3 and 4 is 3 pixels wide
   mouseclick, L, sbw + 3 + (substr(a_thisHotkey,2,1) - 3.5) * buttonWidth , nbh / 2

F11::                             ; F11 - AHK Help - Focus sidebar
   gosub, GetHelpMetrics
   if (sbw = 0)
   coordmode, mouse, client
   mouseclick, L, 2, nbh + 5

F12::                             ; F12- AHK Help - Focus info area
   gosub, GetHelpMetrics
   coordmode, mouse, client
   mouseclick, L, sbw + 5, nbh + 5

   ;     Find:   width of sidebar   - SBW    (0 if not showing)
   ;             height of Nav bar  - NBH
   ;             width of Nav bar   - NBW
   ;     3 pixel wide border between the sidebar and the other navigation tab items.
   ;     That border is color x'EEEEEE'.
   ;     From what I see, Nav Bar background color is always 0x3F627F
   ;     get metrics of control Internet Explorer_Server1, which is essentially
   ;     the client area:
   coordmode, pixel, client
   ControlGetPos, cax, cay, NBW, cah, Internet Explorer_Server1, AutoHotkey Help
   ;     find pixel color 0xEEEEEE - search only 1 row
   ;     This locates the divider bar between the sidebar buttons (content, index
   ;         and search) and the function buttons (view sidebar, back etc.)
   PixelSearch, EEx, EEy, 1, 1, %NBW%, 1, 0xEEEEEE,, RGB FAST
   sbw := EEx = "" ? 0 : EEx     ; Sidebar Width
   ;     Determine naviator bar height.
   ;     find pixel color 0xFFFFFF - search only 1 column & avoid possible scroll bar
   SysGet, ScrWidth, 21          ; scroll bar width (may not be visible)
   PixelSearch, NBx, NBy, % nbw - ScrWidth, 1, % nbw - ScrWidth, %cah%, 0xFFFFFF,, RGB
   NBH := NBy = "" ? 0 : NBy

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 80 guests