AutoHotkey 后台点击和打字

发布于 2024-12-20 00:48:09 字数 255 浏览 5 评论 0原文

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

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

这可能吗?我目前有一个脚本,可以从每日 Excel 报告中提取数据,为每一行分配一个变量并将其输入到另一个程序中,但我还需要它来单击并输入一些预设消息。

I'm trying to use AutoHotkey to do some background clicking and typing while I'm doing other stuff in the foreground.

I've gotten used to Send but I haven't figured out how ControlSend works yet. Can anyone give me an example using something simple like MSPaint in the background and changing the color of paint.

Is this even possible to do? I have a script currently that pulls from daily Excel report, assigns each row a variable and punches it into another program, but I need it to click and type some canned messages as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

天气好吗我好吗 2024-12-27 00:48:09

第一个问题可能应该是为什么要使用鼠标控制?键盘控制变得更加容易,而且通常更可靠。您尝试用无法通过键盘命令完成的鼠标单击执行什么操作?

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

好的,您想要一个示例...

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

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

The first question should probably be why use mouse control? Keyboard control is sooo much easier and often more reliable. What is it that you try to do with a mouseclick that can't be done through keyboard commands?

Also mouse clicks normally activate the hidden app.

OK you wanted an example...

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

Here i click on the play/pause button of a streaming radioplayer. The mouse coordinates are found with the aforementioned Windows Spy and the title of the browser (you might have to use SetTitleMatchMode). Why not look at the AutoHotKey Command list and check out the examples there....

鲜血染红嫁衣 2024-12-27 00:48:09

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

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

Let me know if this is (roughly) what you are looking for....

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
深海夜未眠 2024-12-27 00:48:09

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

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

Here is some code I used to first record the mouse position (relative mouse position did not work since the window was tiled and the click position could be changed by moving the tiles). Immediately after that I click the mouse at the recorded position (and redo this later on in the code as well).

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

Hope this helps.

In your situation, I assume that you only need to determine the mouse position with Window Spy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文