/* ShellRun by Lexikos requires: AutoHotkey v1.1 license: http://creativecommons.org/publicdomain/zero/1.0/ Credit for explaining this method goes to BrandonLive: http://brandonlive.com/2008/04/27/getting-the-shell-to-run-an-application-for-you-part-2-how/ Shell.ShellExecute(File [, Arguments, Directory, Operation, Show]) http://msdn.microsoft.com/en-us/library/windows/desktop/gg537745 */ ShellRun(prms*) { shellWindows := ComObjCreate("Shell.Application").Windows VarSetCapacity(_hwnd, 4, 0) desktop := shellWindows.FindWindowSW(0, "", 8, ComObj(0x4003, &_hwnd), 1) ; Retrieve top-level browser object. if ptlb := ComObjQuery(desktop , "{4C96BE40-915C-11CF-99D3-00AA004AE837}" ; SID_STopLevelBrowser , "{000214E2-0000-0000-C000-000000000046}") ; IID_IShellBrowser { ; IShellBrowser.QueryActiveShellView -> IShellView if DllCall(NumGet(NumGet(ptlb+0)+15*A_PtrSize), "ptr", ptlb, "ptr*", psv:=0) = 0 { ; Define IID_IDispatch. VarSetCapacity(IID_IDispatch, 16) NumPut(0x46000000000000C0, NumPut(0x20400, IID_IDispatch, "int64"), "int64") ; IShellView.GetItemObject -> IDispatch (object which implements IShellFolderViewDual) DllCall(NumGet(NumGet(psv+0)+15*A_PtrSize), "ptr", psv , "uint", 0, "ptr", &IID_IDispatch, "ptr*", pdisp:=0) ; Get Shell object. shell := ComObj(9,pdisp,1).Application ; IShellDispatch2.ShellExecute shell.ShellExecute(prms*) ObjRelease(psv) } ObjRelease(ptlb) } }