DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Use AutoHotkey to add button to existing window?  (Read 12,795 times)

rsteward

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 22
Use AutoHotkey to add button to existing window?
« on: June 09, 2012, 06:39 AM »
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

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • Coding Snacks
Re: Use AutoHotkey to add button to existing window?
« Reply #1 on: June 09, 2012, 07:49 PM »
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.

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

All his AHK apps come with source.

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,175
    • Coding Snacks
    • Participated in NANY Challenge Three Times
    • Plugin Coding Medal
Re: Use AutoHotkey to add button to existing window?
« Reply #2 on: June 11, 2012, 07:11 PM »
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.
Code
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
« Last Edit: June 11, 2012, 07:19 PM by Nod5 »

Original address: https://www.donationcoder.com/forum/index.php?topic=31265.0