【发布时间】:2014-04-10 23:17:49
【问题描述】:
我最近升级到 Windows 8.1 x64,现在我使用的脚本不再工作了。该脚本将右键单击某个程序的托盘图标,而不是导航到其中一个选项,然后单击该选项。
这是脚本:::
;#NoTrayIcon
DetectHiddenWindows, On
;Outlook on the Desktop--------------------------------------------------------------------------------------------------------------------------------
^1:: ;25,000$ Fine Tuned
Info := TrayIcons("OutlookDesktop.exe") ; OutlookDesktop.exe is the prog i tested with
StringSplit, TrayInfo, Info,|
PostMessage, TrayInfo1, TrayInfo2, 0x0205,, ahk_id %TrayInfo3% ; this is the right-click
Sleep 500
Send {Down 3}{Right}{Down 7}{Right}{Down 4}{Enter}
return
^2:: ;Projects
Info := TrayIcons("OutlookDesktop.exe") ; OutlookDesktop.exe is the prog i tested with
StringSplit, TrayInfo, Info,|
PostMessage, TrayInfo1, TrayInfo2, 0x0205,, ahk_id %TrayInfo3% ; this is the right-click
Sleep 500
Send {Down 3}{Right}{Down 7}{Right}{Down 1 4}{Enter}
return
^3:: ;Due This Week - unfinished
Info := TrayIcons("OutlookDesktop.exe") ; OutlookDesktop.exe is the prog i tested with
StringSplit, TrayInfo, Info,|
PostMessage, TrayInfo1, TrayInfo2, 0x0205,, ahk_id %TrayInfo3% ; this is the right-click
Sleep 500
Send {Down 3}{Right}{Down 7}{Right}{Down 2 4}{Enter}
return
^4:: ;To-do Bar Calendar View
Info := TrayIcons("OutlookDesktop.exe") ; OutlookDesktop.exe is the prog i tested with
StringSplit, TrayInfo, Info,|
PostMessage, TrayInfo1, TrayInfo2, 0x0205,, ahk_id %TrayInfo3% ; this is the right-click
Sleep 500
Send {Down 3}{Right}{Down 7}{Right}{Down 7 4}{Enter}
return
; Found and abused from
; http://www.autohotkey.com/forum/topic17314.html
; thx, Sean ... GREAT WORK!
TrayIcons(sExeName = "OutlookDesktop.exe")
{
WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0
, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)
VarSetCapacity(btn, 20)
VarSetCapacity(nfo, 24)
VarSetCapacity(sTooltip, 128)
VarSetCapacity(wTooltip, 128 * 2)
SendMessage, 0x418, 0, 0, ToolbarWindow32, ahk_class Shell_TrayWnd
Loop, %ErrorLevel%
{
SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow32, ahk_class Shell_TrayWnd
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)
iBitmap := NumGet(btn, 0), idn := NumGet(btn, 4), Statyle := NumGet(btn, 8)
dwData := NumGet(btn,12), iString := NumGet(btn,16)
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 24, "Uint", 0)
hWnd := NumGet(nfo, 0), uID := NumGet(nfo, 4)
nMsg := NumGet(nfo, 8)
WinGet, pid, PID, ahk_id %hWnd%
WinGet, sProcess, ProcessName, ahk_id %hWnd%
WinGetClass, sClass, ahk_id %hWnd%
If !sExeName || (sExeName = sProcess) || (sExeName = pid)
{
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString
, "Uint", &wTooltip, "Uint", 128 * 2, "Uint", 0)
DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip
, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
sTrayIcons .= nMsg "|" uID "|" hWnd
}
}
DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
DllCall("CloseHandle", "Uint", hProc)
Return sTrayIcons
}
;Outlook on the Desktop-----------------------END OF SCRIPT------------------------------------------------------------------------------
现在我搜索了更多内容并找到了这个脚本:::
BlockInput, on
pos := Tray_Define("CCC.exe", "i")
Tray_Click(pos, "R")
WinWait, ahk_class #32768
; WinHide, ahk_class #32768 ;this and next line are to hide the menu.
; WinKill, ahk_class SysShadow
ControlSend,,{Down}{Down}{Down}{Down}{Down}{ENTER},ahk_class #32768
BlockInput, off
ExitApp
有趣的是,脚本在 Catalyst Control Centar (CCC.exe) 上运行良好,但在我希望它运行的程序上运行良好,它成功右键单击但发送控制命令不起作用。 (也尝试过使用 Send 而不是 ControlSend)
你们认为这里的问题是什么,为什么 ControlSend 和 Send 命令不起作用?你建议我尝试什么?
【问题讨论】:
-
只是为了排除一个问题,您可以尝试运行提升到管理员权限的脚本吗?
-
刚刚尝试了您的建议,当设置为以管理员身份运行时它冻结(无法移动鼠标但键盘工作)必须 ctrl_alt_del 然后运行任务管理器,突然鼠标工作!你认为这里发生了什么?这很奇怪……
-
哇,在可预见的未来,我还有一个理由坚持使用 Windows 7(带有经典 Shell)......我有时不得不将 AHK 提升为管理员,但从未遇到过这些(鼠标冻结) 问题,所以很遗憾,我无法为您提供更多帮助。
-
只是简单地看了一下你的脚本。您是否意识到在第二个脚本中,您要做的第一件事是阻止所有用户输入。所以我很困惑为什么键盘仍然可以工作,但这可以解释你的鼠标行为。同样在控制发送中,您只指定窗口 AHK_Class,而不是窗口对象。您是否将 AHK_class 更改为您要控制的应用程序(使用 AHK Spy 查找 AHK_Class)。
-
感谢您的提示!我已经改变了ahk_class,这是整个故事的问题,我太短视了,再次感谢!
标签: autohotkey