Цитата Dreadfulangel:
Как можно вызвать определенный пукт контекстного меню в любой программе »
|
Что не устраивает в этом примере?
Код:

#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <GuiMenu.au3>
;
Run("TaskMgr.exe")
WinWait("[CLASS:#32770;REGEXPTITLE:.*Windows.*]", "", 5)
$hTskMgr = WinGetHandle("[CLASS:#32770;REGEXPTITLE:.*Windows.*]")
If Not WinExists($hTskMgr) Then Exit 1
$nCurrentTab = ControlCommand($hTskMgr, "", "SysTabControl321", "CurrentTab")
$nSubMenu_Item = 4 ;Change to 3th submenu (zero-based), now it will only show the "About" window.
If $nCurrentTab = 1 Then $nSubMenu_Item += 1
$hMenu = _GUICtrlMenu_GetMenu($hTskMgr)
;Theese two is to activate the menu, strange bug, but GetItemSubMenu fails if the menu was not used (clicked)
ControlSend($hTskMgr, "", $hMenu, "!_")
ControlClick($hTskMgr, "", "SysTabControl321")
$hSubMenu = _GUICtrlMenu_GetItemSubMenu($hMenu, $nSubMenu_Item)
;2 = Shutdown, 3 = Restart (2 and 3 it's zero-based item from the top of menu)
$iItemID = _GUICtrlMenu_GetItemID($hSubMenu, 2)
$sItemText = _GUICtrlMenu_GetItemText($hSubMenu, $iItemID, 0)
If MsgBox(262144+36, "GetItemText", StringFormat("Item text: %s\nExecute?", $sItemText)) = 6 Then _
_SendMessage($hTskMgr, $WM_COMMAND, $iItemID, 0)
И темы нужно называть более конкретно.