Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для Creat0R

Must AutoIt


Сообщения: 3054
Благодарности: 1009

Профиль | Сайт | Отправить PM | Цитировать


Цитата 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)
И темы нужно называть более конкретно.

-------
“Сделай так просто, как возможно, но не проще этого.”... “Ты никогда не решишь проблему, если будешь думать так же, как те, кто её создал.”

Альберт Эйнштейн

P.S «Не оказываю техподдержку через ПМ/ICQ, и по email - для этого есть форум. ©»

http://creator-lab.ucoz.ru/Images/Icons/autoit_icon.png Русское сообщество AutoIt | http://creator-lab.ucoz.ru/Images/Ic...eator_icon.png CreatoR's Lab | http://creator-lab.ucoz.ru/Images/Icons/oac_icon.png Opera AC Community


Отправлено: 18:04, 18-09-2009 | #2