Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Invoke hidden IE commands (in MS HTML Help)


  • Please log in to reply
5 replies to this topic
Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
For a while I've been annoyed by one particular "feature" of Microsoft HTML Help: Ctrl+F does not open the "Find" dialog if the Index/Search/etc. pane is active. (This may differ on different versions of Windows - I'm not sure.)

The first thing I tried was using ControlFocus to focus the IE control, then send ^f. Unfortunately, though the control seemed to be activating, Ctrl+F still wouldn't work until after I clicked the page.

Next, I googled around, and found this:
<!-- m -->http://www.codeproje... ... ommand.asp<!-- m -->

From that article, I built a script that will activate HTML Help (or run AHK help), then send whatever command. Some of the commands listed in the article were interesting, so I thought I'd post my script here.
; To initialize the HTMLHelpCommand constants (ID_IE_*):
;   call CommandHTMLHelp() with no parameters, OR
;   call HTMLHelpCommandInit()


HTMLHelpCommandInit()
{
global

if (HTMLHelpCommandInitialized)
    return
HTMLHelpCommandInitialized := true

WM_COMMAND = 0x111

; Found via Spy++, handled by "Internet Explorer_Server"
ID_IE_EDIT_FIND = 67

; The following command IDs were copied from:
; http://www.codeproject.com/shell/InvokeIEHiddenCommand.asp

; Command IDs handled by the "Internet Explorer_Server" window:
ID_IE_CONTEXTMENU_ADDFAV = 2261
ID_IE_CONTEXTMENU_VIEWSOURCE = 2139
ID_IE_CONTEXTMENU_REFRESH = 6042

; Command IDs handled by the "Shell DocObject View" window:
ID_IE_FILE_SAVEAS = 258
ID_IE_FILE_PAGESETUP = 259
ID_IE_FILE_PRINT = 260
ID_IE_FILE_NEWWINDOW = 275              ; open help section in a new IE window!
ID_IE_FILE_PRINTPREVIEW = 277
ID_IE_FILE_NEWMAIL = 279
ID_IE_FILE_SENDDESKTOPSHORTCUT = 284    ; send help section shortcut to desktop!
ID_IE_FILE_IMPORTEXPORT = 374
ID_IE_FILE_ADDTRUST = 376
ID_IE_FILE_ADDLOCAL = 377
ID_IE_FILE_NEWPUBLISHINFO = 387
ID_IE_FILE_NEWCORRESPONDENT = 390
ID_IE_FILE_NEWCALL = 395

ID_IE_HELP_ABOUTIE = 336
ID_IE_HELP_HELPINDEX = 337
ID_IE_HELP_WEBTUTORIAL = 338
ID_IE_HELP_FREESTUFF = 341
ID_IE_HELP_PRODUCTUPDATE = 342
ID_IE_HELP_FAQ = 343
ID_IE_HELP_ONLINESUPPORT = 344
ID_IE_HELP_FEEDBACK = 345
ID_IE_HELP_BESTPAGE = 346
ID_IE_HELP_SEARCHWEB = 347
ID_IE_HELP_MSHOME = 348
ID_IE_HELP_VISITINTERNET = 349
ID_IE_HELP_STARTPAGE = 350
ID_IE_HELP_NETSCAPEUSER = 351
ID_IE_HELP_ENHANCEDSECURITY = 375


; IE web control:
ID_IE_Server = Internet Explorer_Server1
; it's parent:
ID_IE_Parent = Shell DocObject View1
}

/*
^f:: ; testing command.  select a constant from the list above, and press Ctrl+F
    ControlGet, temp, Selected, , , A ; get selected text of "topmost" (focused?) control
    CommandHTMLHelp(temp)
    return

^q::ExitApp
*/

CommandHTMLHelp(cmd="")
{
    global
    local pid, ctl

    if (!HTMLHelpCommandInitialized)
        HTMLHelpCommandInit()

    if (!cmd)
        return

    ; ensure a Microsoft HTML Help window is active
    if (!WinActive("ahk_class HH Parent"))
    {
        ; if AutoHotkey Help is open, activate it
        if (WinExist("AutoHotkey Help ahk_class HH Parent"))
            WinActivate
        ; run AutoHotkey Help, if possible
        else if (FileExist(A_ProgramFiles "\AutoHotkey\AutoHotkey.chm")) ; why is there not an A_AhkDir variable?
        {
            Run, %A_ProgramFiles%\AutoHotkey\AutoHotkey.chm, , , pid
            WinWait, ahk_pid %pid%, , 1
        }

        ; if still no HTML Help window active, activate any that may exist
        if (!WinActive("ahk_class HH Parent"))
            WinActivate, ahk_class HH Parent

        ; show an error message if there still isn't a help window active
        if (!WinActive("ahk_class HH Parent"))
        {
            MsgBox, 48, Error, No HTML Help windows are open`, and AutoHotkey help file could not be found., 3
            return
        }
    }
    ; Last Found Window should now be set to a HTML Help window

    ; Some commands should be sent to the IE_Server, others to its parent control.
    ; I know of no sure way to determine which one a message should be sent to,
    ; (given that the user can specify IDs not known by this script), so I send the
    ; message to both.  The following if(..) prevents ID_IE_EDIT_FIND from working.
    ;if (cmd > 2000)
        SendMessage, WM_COMMAND, cmd, 0, %ID_IE_Server%
    ;else
        SendMessage, WM_COMMAND, cmd, 0, %ID_IE_Parent%
}
Example usage:
#IfWinActive ahk_class HH Parent
; show the Find dialog
^f::CommandHTMLHelp(ID_IE_EDIT_FIND)
; open the current page in a new (Internet Explorer) window
^n::CommandHTMLHelp(ID_IE_FILE_NEWWINDOW)
; create a shortcut on the desktop, pointing to the current help page
^d::CommandHTMLHelp(ID_IE_FILE_SENDDESKTOPSHORTCUT)
; view the HTML source of the current help page
^s::CommandHTMLHelp(ID_IE_CONTEXTMENU_VIEWSOURCE)
; note: the script must be initialized by calling:
;   CommandHTMLHelp(), OR
;   HTMLHelpCommandInit()
; before the ID_IE_* "constants" will work
Note that the script currently only looks in A_ProgramFiles\AutoHotkey for the help file.

I'm sure this could easily be adapted to work with other applications that use the IE web control, however, I'm lazy. :p Constructive criticism is welcome.

Additional command IDs can be discovered by spying on "Internet Explorer_Server" and its parent "Shell DocObject View" using Spy++. (If you don't have Spy++ - it comes with MS Visual Studio - I'm sure myself or one of the other forumers may find an ID for you.) On that subject, anyone know of any alternatives to Spy++?

(I admit, I didn't search the AHK forums very thoroughly, so if this has been done before, let me know.)

One last thing - the lite version of the Ctrl+F fix would be:
#IfWinActive ahk_class HH Parent
^f::
    ; send WM_COMMAND, Edit->Find to the IE control
    SendMessage, 0x111, 67, 0, Internet Explorer_Server1, A
    return


majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Can this be used to open, last say, RegExMatch from AHK CHM file , like my EditPlus is capable now on F1 ?
Posted Image

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

Can this be used to open, last say, RegExMatch from AHK CHM file , like my EditPlus is capable now on F1 ?

What part of "Invoke hidden IE commands (in MS HTML Help)" makes you think this has anything to do with "IntelliSense"? Look at the script, and it will be clear what it can or cannot do.

With that said, I hadn't seen your ISense script before. I might just give a try...

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
:roll:

I asked you a question. The "NO" was enough. I don't have to listen your bullsh*t.

Sorry, I misjudged you.
Posted Image

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

I asked you a question. The "NO" was enough. I don't have to listen your bullsh*t.

Sorry, I misjudged you.

Perhaps next time you could READ the post, before asking stupid questions. It quite obviously doesn't register an F1 hotkey, nor does it interact with any editors in any way.

I took offense, because it seemed like you were suggesting your script made mine obsolete somehow, when they have completely different purposes.

taratata
  • Guests
  • Last active:
  • Joined: --
Is it possible, does the heavy grumpy majkinetor had found (CTRL-F) his master in grumpystery ? Bravo lexikos, the challenge wasn't so easy to win...