【问题标题】:AutoHotkey background clicking and typingAutoHotkey 背景点击和输入
【发布时间】:2012-01-16 01:19:12
【问题描述】:

我正在尝试使用 AutoHotkey 来做一些背景点击和打字,而我正在前台做其他事情。

我已经习惯了Send,但我还没有弄清楚ControlSend 的工作原理。谁能给我一个例子,在背景中使用像 MSPaint 这样简单的东西并改变油漆的颜色。

这甚至可能吗?我目前有一个脚本,它从每日 Excel 报告中提取,为每一行分配一个变量并将其打入另一个程序,但我还需要它来单击并键入一些罐头消息。

【问题讨论】:

    标签: background autohotkey minimized


    【解决方案1】:

    第一个问题大概应该是为什么要使用鼠标控制?键盘控制非常容易,而且通常更可靠。您尝试使用无法通过键盘命令完成的鼠标单击来做什么?

    鼠标点击通常也会激活隐藏的应用程序。

    好的,你想要一个例子......

    +Home:: ;Shift + Home = stop/start radio
    SetControlDelay -1
    ControlClick, x384 y143, Radioplayer
    Return
    

    在这里,我单击了流式广播播放器的播放/暂停按钮。鼠标坐标是通过前面提到的 Windows Spy 和浏览器的标题找到的(您可能必须使用 SetTitleMatchMode)。为什么不查看 AutoHotKey 命令列表并查看其中的示例....

    【讨论】:

      【解决方案2】:

      让我知道这是否(大致)您正在寻找的东西......

      SendMode Input  ; Recommended for new scripts
      SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
      SetTitleMatchMode, 2 ; A window's title can contain the text anywhere
      !F1:: ; Press Alt F1 to execute
      IfWinExist, Microsoft Excel
      {
          ControlSend ,, 1000{Enter}{Down}, Microsoft Excel
      }
      return
      

      【讨论】:

      • 现在你说1000{Enter}{Down}坐标呢?
      • 如 [Ctrl]+g 然后例如K9[Enter],跳转到单元格K9?
      • 明白了,ControlClick 呢?我似乎找不到使用坐标的好例子。
      • 你玩过Window Spy模式吗(右击图标),这里可以看到鼠标坐标,点击使用。
      【解决方案3】:

      这是我用来首先记录鼠标位置的一些代码(相对鼠标位置不起作用,因为窗口是平铺的,并且可以通过移动平铺来更改点击位置)。之后,我立即在记录的位置单击鼠标(稍后在代码中也重做此操作)。

      SplashTextOn, 200, 100, Script Preparations, Please Click on the Person `"Search Term`" link (1) in SAP. ; Show new instructions to the user
      WinMove, Script Preparations,, (A_ScreenWidth/2)-150, (A_ScreenHeight/2)-200      ; Move the text instructions window with the name "Script Preparations" 150 pixels right of the center of the screen and 200 pixels up SoundBeep 600, 300 ; Wake up user
      ; From here on the left mouse button will temporarily be disabled
      Hotkey, LButton, on ; Turn Left Mouse Button OFF, to capture the Mouse click
      KeyWait, LButton, D ; Wait for LeftMouseButton click Down
      MouseGetPos, xposS ,yposS ; Store the position where the mouse was clicked (Search Box)
      MouseClick, left, %xposS% ,%yposS% ; Perform the mouse click on the captured mouse location
      

      希望这会有所帮助。

      在您的情况下,我假设您只需要使用 Window Spy 确定鼠标位置。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-08-30
        • 2013-07-13
        • 2011-01-07
        • 2015-07-24
        • 2014-10-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多