【问题标题】:Snap mouse cursor to center of screen将鼠标光标捕捉到屏幕中心
【发布时间】:2017-06-20 15:53:24
【问题描述】:

当按下 F4 时,我试图将光标捕捉到屏幕中心。这是我正在尝试的:

F4::
x := (A_ScreenWidth / 2)
y := (A_ScreenHeight / 2)
mousemove, x, y
return

但是当我运行这个脚本时,鼠标位置会在打开时移动,而当按下 F4 时,鼠标不会移动位置?

【问题讨论】:

  • 双重'/'是怎么回事?
  • @Mr. Polywhirl 问题已更新,但问题相同。我使用了另一个示例中的一些代码

标签: autohotkey


【解决方案1】:

试试这个:

#Persistent ;//keeps script running
CoordMode, Mouse, Screen
Return ;//stops auto execution

F4:: ;//your code
x := (A_ScreenWidth / 2)
y := (A_ScreenHeight / 2)
mousemove, x, y
return

如果没有#Persistent,脚本将在执行完所有代码行后关闭。

Autohotkey 会执行每一行代码,直到第一个“Return”。

CoordMode 行将确保鼠标移动是相对于屏幕而不是活动窗口(来源:@user3419297)

面条

【讨论】:

  • 代码块本身通常不是有用的答案。请编辑您的答案并解释您显示的代码的作用,以及该代码为何/如何回答问题。
  • 完成。我的修改有解释
【解决方案2】:
F4::
CoordMode, Mouse, Screen  ; If this command is not used, the coordinates are relative to the active window.
x := (A_ScreenWidth / 2)
y := (A_ScreenHeight / 2)
mousemove, x, y
return

http://ahkscript.org/docs/commands/CoordMode.htm#Remarks

【讨论】:

    【解决方案3】:

    Nircmd by Nir Sofer 有以下选项:

    nircmd setcursor x y 
    

    您可以创建此命令行的快捷方式并为其分配任何热键。 nircmd.chm 文件中详细介绍了鼠标光标的许多其他选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多