ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Coding Snacks

Use AutoHotkey to add button to existing window?

(1/1)

rsteward:
Can you add a ahk control to a commercial app?  What I'm looking for is a little like Barnacle but not a toolbar.  Take CALC.exe for example.  Can you place a button over one of the existing buttons on the calculator?  Anybody have any examples?

MilesAhead:
I'm not sure about 3rd party programs. But I believe Skrommel had some where he added buttons to the Explorer window.  Maybe others. Check out Skrommel's ahk apps.

https://www.donationcoder.com/Software/Skrommel/

All his AHK apps come with source.

Nod5:
You could create a gui with buttons and then use timer commands to make it always float over the same part of the underlying application. For example, the button could always float to the right of the text "calculator" in the calc.exe titlebar. The button might lag behind a little if you drag the window though.

Another alternative: If the application has controls that AHK can operate on then you can likely also relabel and reuse buttons from the GUI. Start calc.exe and then run this test code. It hides the "sinh" button, relabels "cosh" to ":-)" and takes control over what action to do when you click ":-)", for example show the text "hello world" in a tooltip. edit: though this disables click+drag within the calc window. A better alternative might be to use middle mouse button ( Mbutton ) since click + drag is less commonly used. Then you can keep the native left click functionality of the button.

--- ---Control, Hide,,Button37, ahk_class CalcFrame
ControlSetText, Button38,:-), ahk_class CalcFrame

#IfWinActive, ahk_class CalcFrame
LButton::
WinGet, x, ID, ahk_class CalcFrame
MouseGetPos,,, xwin, xcontrol
if ( x == xwin AND xcontrol = "Button38")
ToolTip, hello world
else
 Click
return
#IfWinActive

Navigation

[0] Message Index

Go to full version