【问题标题】:autohotkey not working for CarbonPoker application自动热键不适用于 CarbonPoker 应用程序
【发布时间】:2014-09-08 11:37:37
【问题描述】:

我已经在其他窗口上测试了我的脚本,例如计算器(所以这不仅仅是我的脚本的问题),但是当我运行 CarbonPoker 应用程序时,表格窗口不会移动。我可以激活窗口,我可以得到标题并用MsgBox 显示它,但我不能让它移动。

我试过了

WinMove,0,0

我试过了

WinGetTitle, Title, A
WinMove,ahk_id %Title%,, %xval%,%yval%,%width%,%height%

我试过了

WinMove,%Title%,, %xval%,%yval%,%width%,%height%

是否有一些应用程序无法移动其窗口?或者有没有办法仍然为此类应用程序做到这一点?谢谢。

【问题讨论】:

  • WinGet OutputVar 也为空,或者如果我使用其他方法:UniqueID := WinActive(%Title%) 那么 UniqueID 为 0x0
  • 试试UniqueID := WinExist(Title)
  • 你检查过任何答案吗?他们对你有用吗?

标签: automation autohotkey


【解决方案1】:

代码已更新。现在您可以移动窗口,如果它被其他窗口重叠。还为 WinTitle 添加了变量。

您也可以尝试其他方式移动窗口:

CoordMode, Mouse, Screen ;sets coordinate mode relative to screen.

DestX:=200 ; the x coordinate of the point where you want to see left upper point of window.
DestY:=10 ; the y coordinate of the point where you want to see left upper point of window.
WinTitleVar:="Notepad" ; The part of WinTitle of window that we need to move.

;Here are shift variables. What they meen? You cant just drug by left upper corner of window. You need to shift slightly right and down to be able to drag window. That variables are giving that shift to your coordinates.
ShiftX:= 30 ; shift for x coordinate.
ShiftY:= 10 ; shift for y coordinate.

DestX:= DestX + ShiftX ; apply shift to DestX .
DestY:= DestY + ShiftY ; apply shift to DestY .

SetTitleMatchMode, 2 ; Whith that command a window's title can contain WinTitle anywhere inside it to be a match. It is for WinGetPos command. You can remove this command, but then you need to use exact title in WinGetPos command.
WinGetPos, InitX, InitY,,, %WinTitleVar% ; get current upper left position of notepad window.
InitX:= InitX + ShiftX ; apply shift to InitX .
InitY:= InitY + ShiftY ; apply shift to InitY .

WinActivate, %WinTitleVar% ; Activates Window. This command is here in cases if other window overlaps the window that we need to move.
Click, Left, Down, %InitX%, %InitY% ; Click the left button but dont release it at the shifted coordinates of current window location. 
MouseMove, %DestX%, %DestY% ; Move mouse to the shifted destination coordinates.
Click, Left, Up ; Release Left mouse button.

我尽可能多地对代码进行了注释,但如果您有任何问题,请随时提出。

【讨论】:

    【解决方案2】:

    首先,如果您的其他应用程序以管理员身份运行,那么您的脚本也需要以相同的管理员权限运行。我会先检查一下。

    接下来,您可以尝试使用 hwnd 代替标题:

    ; hover mouse over the window, and press f3 to move window
    
    f3::
       MouseGetPos,,, hwnd
       WinMove, ahk_id %hwnd%,, 0, 0
    return
    

    【讨论】:

      猜你喜欢
      • 2015-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      • 2023-02-24
      • 1970-01-01
      • 2023-02-22
      相关资源
      最近更新 更多