我有一个字典应用程序,在该应用程序中Ctrl + C不起作用,因此复制的唯一方法是从菜单中选择“编辑”>“复制”。我尝试使用下面的代码及其变体,但是没有用。
!l::
WinActivate, MAGENTA - Dictionaries Explorer II
WinMenuSelectItem, ahk_class TMainForm,, Edit, Copy
return
WinSpy数据:
MAGENTA - Dictionaries Explorer II
ahk_class TMainForm
ahk_exe MgDE2.EXE
ahk_pid 2580
答案 0 :(得分:0)
尝试这样的事情:
!l::
Loop, 3
{
WinActivate, MAGENTA - Dictionaries Explorer II
WinWaitActive, MAGENTA - Dictionaries Explorer II, 1 ; wait max. 1 sec for the window to get active
If !(ErrorLevel) ; If NOT ErrorLevel the window gets active within 1 sec
break ; terminate the loop
}
; If after 3 efforts the window isn't active:
If !WinActive("MAGENTA - Dictionaries Explorer II")
{
MsgBox, MAGENTA could not be activated
return ; stop, don't go furthermore
}
; otherwise:
clipboard := "" ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
Loop, 3
{
WinMenuSelectItem, ahk_class TMainForm,, Edit, Copy
; try also
; Send, {AppsKey}c{Enter}
ClipWait 1 ; wait max. 1 sec for the clipboard to contain data
If !(ErrorLevel) ; If NOT ErrorLevel, ClipWait found data on the clipboard
break ; terminate the loop
}
; If after 3 efforts the clipboard doesn't contain any data:
If (clipboard = "")
MsgBox, Text could not be copied
return
编辑:
也尝试
WinMenuSelectItem, MAGENTA - Dictionaries Explorer II ahk_class TMainForm,, Edit, Copy
该程序可能具有多个TMainForm类窗口。
要使用此脚本进行检查
WinGet, id, list, ahk_class TMainForm
Loop, %id%
numberOfwindows := A_Index
MsgBox, number of ahk_class TMainForm windows = %numberOfwindows%
如果Window Spy在“可见文本”行中显示文本元素,则可以使用
WinMenuSelectItem, MAGENTA - Dictionaries Explorer II ahk_class TMainForm, WinText, Edit, Copy
答案 1 :(得分:0)
忘记AHK一分钟,如果仅按下并释放Alt键(全部),会发生什么?
如果“文件”菜单被激活(蓝色框),则只需发送ALT击键,然后根据需要定向移动,最后发送ENTER激活该项目
赞
SendInput {Alt}{Right}{Down}{Enter}
如果您需要右移4个元素,然后向下移2个条目,则可以使用以下方式:
SendInput {Alt}{Right 4}{Down 2}{Enter}