4

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

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

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

4

3 回答 3

2

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

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

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

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

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

于 2011-12-31T13:31:31.040 回答
0

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

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
于 2011-12-12T13:13:57.993 回答
0

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

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 确定鼠标位置。

于 2011-12-28T18:53:49.473 回答