如何在AHK V1.1+中更改特定窗口的类?

问题描述 投票:0回答:1
  • 我有一个特定的窗口(“x”),我想在它上面执行一些命令(如下所示),并且这个窗口(“x”)与其他一些窗口具有相同的类。问题是当我从另一个程序运行另一个窗口(“y”)时,这个窗口(“y”)与我希望在其上执行命令的窗口(“x”)具有相同的类。这个窗口(“y”)也适用于命令,但我不希望命令应用于窗口(“y”)我只希望命令应用于窗口(“x”)
  • 我尝试使用它的标题或(exe)或其(ID)或其(PID)而不是类将命令应用于窗口(“x”),但它不起作用(命令仅适用于我使用课程)

我试过这个,但没有用: ; ..................................................... .......... 1个例子:

    If not WinExist("QTranslate")  ; "QTranslate" this is the title of 
    the window "y" that has the same class of "x"
    {
    Loop {
    WinWaitActive, ahk_class #32770  ; this is the class of the 
    window("x")
    WinSet,AlwaysOnTop,On, ahk_class #32770
    WinWaitClose, ahk_class #32770
    }
    }
    Return

; ..................................................... .......... 示例 2:

    #If not WinActive("QTranslate") and WinExist("ahk_class #32770") ; close error win
    RButton::
    AppsKey::
    Loop, 3{
    Winclose,ahk_class #32770 ; this is the class of the window("x")
    }
    #If
  • 当我打开窗口(“y”)并按下 RButton 或 AppsKey 时,该命令适用于该窗口 ; ..................................................... ...................
  • 有没有办法使用 AHK 或其他方式更改窗口的类?
autohotkey
1个回答
0
投票

在 WinTitle 参数中,您可以指定多个标准 用于缩小特定窗口的搜索范围。参见多重标准

例如

If !WinExist("QTranslate ahk_exe QTranslate.exe") ; "!" means "NOT"

If !WinExist("QTranslate ahk_exe QTranslate.exe", "WinText")

If !WinExist("QTranslate ahk_exe QTranslate.exe", "WinText", "ExcludeTitlePart")

使用 AHK 附带的 Window Spy 工具来获取您需要的正确信息。

© www.soinside.com 2019 - 2024. All rights reserved.