Monitor if button from app is pushed Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fuglen
Posts: 24
Joined: 05 Mar 2020, 09:44

Monitor if button from app is pushed

20 Apr 2021, 06:43

Hi

Using the ControlClick function, it is possible to click a button from an open application, if I can find the ClassNN or name/text of the button in Window Spy. But is it possible to do it the way around? I would like to activate a script when a specific button is activated in another program.

Other ideas would be to create a transparent button on top of the other button that ControlClicks and activates my scirpt, or, as the button briefly changes color, when clicked I could use PixelGetColor. Any other ideas?

best regards Thomas
Rohwedder
Posts: 7610
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Monitor if button from app is pushed

20 Apr 2021, 09:42

Hallo,
try:

Code: Select all

Run, Notepad.exe
WinWait, ahk_exe Notepad.exe
NotepadEdit := WinActive("ahk_exe Notepad.exe") "Edit1"
Return
~*LButton::
MouseGetPos ,,, OutputVarWin, OutputVarControl ;, Flag
IF (NotepadEdit = OutputVarWin OutputVarControl)
	SoundBeep, 4000, 20
Return
Beep when you click the edit1 control of the editor.
fuglen
Posts: 24
Joined: 05 Mar 2020, 09:44

Re: Monitor if button from app is pushed

21 Apr 2021, 02:58

Rohwedder wrote:
20 Apr 2021, 09:42
Hallo,
try:

Code: Select all

Run, Notepad.exe
WinWait, ahk_exe Notepad.exe
NotepadEdit := WinActive("ahk_exe Notepad.exe") "Edit1"
Return
~*LButton::
MouseGetPos ,,, OutputVarWin, OutputVarControl ;, Flag
IF (NotepadEdit = OutputVarWin OutputVarControl)
	SoundBeep, 4000, 20
Return
Beep when you click the edit1 control of the editor.
I think you are sending a beep everytime you activate the window? Unfortunately it doesnt seem to work when it´s a button in an application. I will try to explain further:
image.png
image.png (1.3 MiB) Viewed 235 times
From WindowSpy, in visible Text, I can see "Indstillinger" which is a button in the program in lower right corner (translates to settings in danish). I can send do a "ControlClick, Indstillinger, KEYPOINT.NET 2.32" and "Indstillinger" is clicked. Can you manipulate your code so you send a SoundBeep when I manually click the "Indstillinger" button?
Rohwedder
Posts: 7610
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Monitor if button from app is pushed  Topic is solved

21 Apr 2021, 05:17

Try:

Code: Select all

Control = WindowsForm10.Windows.8.app.0.33c0d9d13 ;target
Return
~*LButton::
MouseGetPos,,,, OutputVarControl ;actual
ToolTip,% Control "`n" OutputVarControl
SetTimer, RemoveToolTip , -3000
IF (OutputVarControl = Control)
	SoundBeep, 4000, 20
Return
RemoveToolTip:
ToolTip
Return
For testing only, the Tooltip shows target and actual

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: TAC109 and 258 guests