Hi. I have just moved from AHK (basic) to AHK_L (with integrated COM). Many thanks for all the hard work you guys do. I have an old script which acts on MS CHM help files to change the font size in the viewer. Pressing Ctrl and using the mousewheel changes the text font size (this doesn't work on all help files) and Pressing Ctrl and Win and mousewheel zooms the page (more reliable). The code still works in AHK_L after changing to COM_L (took me a while to figure that one out - searching the forums). I couldn't find anything similar to my code so I was wondering if anyone would care to suggest a way of converting it to run more natively (so to speak) under the new AHK_L? In particular getting a pointer to an already running CHM file and interface. Am on XPSP3, AHK_L 1.1.00.00.
Code:
mStr:= "Smallest Smaller Medium Large Largest"
Loop, Parse, mStr, %A_Space% ; sets txtsz0 = Smallest, txtsz1 = Smaller, txtsz2 = Medium etc
{ t := A_Index-1
txtsz%t% := A_LoopField
}
nZ := 2 ; Initial Zoom Factor
txtSize := 2 ; Initial Text Size Factor
optZoom := 150 ; Initial Optical Zoom Factor (IE 8) ? 150 because of DPI
<^WheelUp::mLCtrlWheel(1,4) ; Text Size in IE ; param1 determines wheelup or down ; param2 is the UPPER or LOWER limit
<^WheelDown::mLCtrlWheel(-1,0) ; consider using XButton1 & WheelUp/WheelDown. Don't use Alt as interferes with shortcut menu
dm_getPtrIESrv1()
{
ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, A ; Get handle of ACTIVE Help Window
If Not hIESvr
Return
DllCall("SendMessageTimeout", "uint", hIESvr, "uint", DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT"), "uint", 0, "uint", 0, "uint", 2, "uint", 1000, "UintP", lResult)
DllCall("oleacc\ObjectFromLresult", "uint", lResult, "uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "UintP", pdoc)
IID_IWebBrowserApp := "{0002DF05-0000-0000-C000-000000000046}"
pIESrv1 := COM_QueryService(pdoc,IID_IWebBrowserApp,IID_IWebBrowserApp)
COM_Release(pdoc)
; ToolTip, %hIESvr% %pIESrv1% %pdoc%
Return pIESrv1
}
mLCtrlWheel(d, TxtSizeLimit)
{
global
Critical
IfNotEqual,txtSize,%TxtSizeLimit% ; if current TEXT SIZE out of bounds then don't Run
{
If Not pIESrv1
{ ; only run this once each zoom session
COM_CoInitialize()
If Not pIESrv1 := dm_getPtrIESrv1() ; I think this tests the return value if any which is made = to a local variable
Exit
}
txtSize := txtSize + d
COM_Invoke(pIESrv1, "ExecWB", 19, 2, txtSize, 0) ; nCmdID, nCmdExecOpt, pvaIn, pvaOut
; nCmdID: OLECMDID_OPTICAL_ZOOM = 63 (Zoom as %); OLECMDID_ZOOM = 19 (Text Size = 0,1,2,3,4)
; nCmdExecOpt: OLECMDEXECOPT_DODEFAULT = 0, OLECMDEXECOPT_PROMPTUSER = 1, OLECMDEXECOPT_DONTPROMPTUSER = 2, OLECMDEXECOPT_SHOWHELP = 3
; textsize := txtsz%txtSize%
; Tooltip, Font size is %textsize% ; Smallest | Smaller | Medium | Larger | Largest
Tooltip % "Font size is " . txtsz%txtSize% ;%; Smallest | Smaller | Medium | Larger | Largest
If Not IsRun_mZoomKeyup
SetTimer, mZoomKeyup, -100 ; Turn off Tooltip & Release COM etc when key released.
}
}
<^#WheelUp::mRCtrlWheel(10) ; Page Zoom in IE; Parameter is change in zoom level; Win key interferes with VWD 2008 Shortcut menu
<^#WheelDown::mRCtrlWheel(-10) ; consider using XButton2 & WheelUp/WheelDown
mRCtrlWheel(d)
{
global
Critical
If Not pIESrv1
{ ; only run this once each zoom session
COM_CoInitialize()
If Not pIESrv1 := dm_getPtrIESrv1() ; I think this tests the return value if any which is made = to a local variable
Exit
}
optZoom := optZoom + d
COM_Invoke(pIESrv1, "ExecWB", 63, 2, optZoom, 0) ; nCmdID: OLECMDID_OPTICAL_ZOOM = 63 (Zoom as %)
Tooltip, Zoom factor %optZoom%`% ;%;
If Not IsRun_mZoomKeyup
SetTimer, mZoomKeyup, -100 ; Turn off Tooltip & Release COM etc when key released.
}
mZoomKeyup:
IsRun_mZoomKeyup := 1 ; need this flag otherwise runs twice - use MsgBox to test
KeyWait, Control ; waits till Hotkey modifier released before turning tooltip off
COM_Release(pIESrv1) ; only run this once each zoom session
pIESrv1 := 0
COM_CoUninitialize()
Gosub, mTipClose
IsRun_mZoomKeyup := 0
Return