Background click and text input in AutoHotkey

I am trying to use AutoHotkey to do some background taps and typing while I do other things in the foreground.

I'm used to Send , but I still don't understand how ControlSend works. Can someone give me an example using something simple like MSPaint in the background and changing the color of the paint.

Can this be done? I have a script currently that extracts from a daily Excel report, assigns a variable to each row and deletes it into another program, but I need to click it and type some canned messages.

+4
source share
3 answers

Perhaps the first question should be, why use mouse control? Keyboard management is much simpler and often more reliable. What are you trying to do with mouseclick that cannot be executed using keyboard commands?

Also, mouse clicks usually activate a hidden application.

OK you need an example ...

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

Here I press the play / pause button of the streaming radio player. Mouse coordinates are found with the aforementioned Windows spy and browser name (you may need to use SetTitleMatchMode). Why not look at the list of AutoHotKey commands and check out the examples there ...

+2
source

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 title can contain the text anywhere !F1:: ; Press Alt F1 to execute IfWinExist, Microsoft Excel { ControlSend ,, 1000{Enter}{Down}, Microsoft Excel } return 
0
source

Here is some code that I used for the first record of the mouse position (the relative position of the mouse did not work, because the window was broken, and the click position could be changed by moving the tiles). Immediately after that, I click the mouse button at the recorded position (and repeat it later in the code).

 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 position of the mouse using Window Spy.

0
source

Source: https://habr.com/ru/post/1385364/


All Articles