Activating Script When Button Clicked

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
zvzpm
Posts: 1
Joined: 18 Apr 2018, 20:59

Activating Script When Button Clicked

18 Apr 2018, 21:12

I am a new autohotkey user. I want to activate a script when a button is clicked (with the left mouse button). I found this script online which I modified for my purpose by changing the window names and the name of the button, but it does not work as intended in 2 ways:

1. The script identifies mouse coordinates and whenever something is clicked there, the script activates, but different buttons can appear there and I wish for the script only to run when a specific button is executed. Is there a way I can set up the trigger (not sure what the autohotkey terminology is) to be when the particular button is activated?

2. Only my code is executed, and not the result from clicking the button. I would like the original button to execute as well. I tried adding the line Controlclick and the name of the button using Window Spy under ClassNN, but it only variably works, and I am not sure it is the best approach.

Thanks for any help.

Code: Select all

#SingleInstance Force
#Persistent

#IfWinActive, ahk_class CalcFrame
    ~LButton::
    MouseGetPos, MouseX, MouseY
    ControlGetPos, ButtonX, ButtonY, ButtonW, ButtonH, button1, ahk_class CalcFrame
    ButtonX2:=ButtonX + ButtonW
    ButtonY2:=ButtonY + ButtonH
    if MouseX between %ButtonX% and %ButtonX2%
    {
        if MouseY between %ButtonY% and %ButtonY2%
        {
            Send !u
            Controlclick, classNN_button_name
        }
    }
    Return
#IfWinActive
https://stackoverflow.com/questions/151 ... n-a-window
Last edited by zvzpm on 19 Apr 2018, 00:42, edited 1 time in total.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 234 guests