PageRenderTime 10ms CodeModel.GetById 7ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/contextmenu.ahk

http://7plus.googlecode.com/
AutoHotKey | 33 lines | 19 code | 1 blank | 13 comment | 4 complexity | 7d1188d599f5de551b720a3f26caebac MD5 | raw file
 1;Checks if a context menu is active and has focus
 2;Need to check if other context menus are active (trillian, browsers,...)
 3IsContextMenuActive() 
 4{ 
 5	GuiThreadInfoSize := 24 + 6 * A_PtrSize 
 6	VarSetCapacity(GuiThreadInfo, GuiThreadInfoSize) 
 7	NumPut(GuiThreadInfoSize, GuiThreadInfo, 0) 
 8	if not DllCall("GetGUIThreadInfo", uint, 0, "Ptr", &GuiThreadInfo) 
 9	{ 
10	  ;MsgBox GetGUIThreadInfo() indicated a failure. 
11	  return 
12	} 
13	; GuiThreadInfo contains a DWORD flags at byte 4 
14	; Bit 4 of this flag is set if the thread is in menu mode. GUI_INMENUMODE = 0x4 
15	if (NumGet(GuiThreadInfo, 4) & 0x4) 
16		return true
17	return false
18}
19
20;This stuff doesn't properly use COM.ahk yet :(
21/*
22Executes context menu entries of shell items without showing their menus
23Usage:
24ShellContextMenu("Desktop",1)			;Calls "Next Desktop background" in Win7
251st parameter can be "Desktop" for empty selection desktop menu, a path, or an idl
26Leave 2nd parameter empty to show context menu and extract idn by clicking on an entry (shows up in debugview)
27*/ 
28ShellContextMenu(sPath,idn=0) 
29{ 
30	result := DllCall(Settings.DllPath "\Explorer.dll\ExecuteContextMenuCommand", "Str", sPath, "Int", idn, "PTR", A_ScriptHwnd)
31	if(Errorlevel != 0)
32		Notify("Couldn't execute context menu command!", "Error Calling ExecuteContextMenuCommand() in Explorer.dll!", 5, NotifyIcons.Error)
33}