(AHK) Enable Any Window/Button You Click On

By raccoon on Aug 31, 2010

This is a simple little script. I'm posting it here because it gets a LOT of daily use and I can't imagine using Windows without it.

Never allow a disabled window or button to annoy you again. Prohibit applications from disabling windows or controls, by simply clicking on them. This is especially useful when you wish to access a parent window while a settings or dialog window is visible, ie; a Save/Open dialog.

Examples:

  • Winamp's main window becomes disabled when selecting an Equalizer setting from the list of presets. This script makes Winamp always accessable, so you can always keep the preset list open if you desire.

  • You want to save a document, but forgot to copy a selection of text you want to use for the file name. This script allows you access to your document text, even when the Save dialog is visible.

  • A shareware author added buttons to their application, but disabled the buttons until you pay $19.95 to register the application. This script will most likely allow you access to those buttons.

  • An OK or Close button is disabled for some bizarre reason. Now you can just click on it.

-- Raccoon 2010

Note: This snippet utilizes the AutoHotkey scripting language. You can download the AutoHotkey interpreter from www.autohotkey.com (Windows)

#SingleInstance, Force
#NoEnv
RETURN ; end of auto-execute section.

; Prohibit applications from disabling windows or controls, by simply clicking
; on them.  This is especially useful when you wish to access a parent window
; while a settings or dialog window is visible, ie; a Save/Open dialog.
; 
; Example:  Winamp's main window becomes disabled when selecting an Equalizer
; setting from the list of presets.  This script makes Winamp always accessible,
; so you can always keep the preset list open if you desire. -- Raccoon 2010

#If Enable_Window_Under_Cursor() || True
~LButton::Return
#If ; End If

;~LButton::
;  Enable_Window_Under_Cursor()
;  Return

Enable_Window_Under_Cursor() ; By Raccoon 31-Aug-2010
{
  MouseGetPos,,, WinHndl, CtlHndl, 2
  WinGet, Style, Style, ahk_id %WinHndl%
  if (Style & 0x8000000) { ; WS_DISABLED.
    WinSet, Enable,, ahk_id %WinHndl%
  }
  WinGet, Style, Style, ahk_id %CtlHndl%
  if (Style & 0x8000000) { ; WS_DISABLED.
    WinSet, Enable,, ahk_id %CtlHndl%
  }
}
; End of Snippet

Comments

Sign in to comment.
raccoon   -  May 26, 2013

Updated: Used a conditional #If directive to effect change upon the window or control before the 'click' hits that window or control. This ensures the element is enabled and your click goes through the first time. Thanks Uberi!

 Respond  
SReject   -  Jul 07, 2012

Well, Started looking through posts just to see what I could find, and a gem in a big pile of shit is what this is. I do a bit of AHK coding myself and have something similar to this. Though your's is quite a bit cleaner than mine.

10/10 great work :)

 Respond  
raccoon   -  Jul 06, 2012

I have never tested this script or any version of AutoHotkey on Windows 7. You may have to run it as Administrator for it to poke at other processes' window properties.

 Respond  
BigSteve   -  May 18, 2012

script isnt working now :-/ some reason it wont work on my windows 7 laptop is this because its for an earlier version of windows ? I mean I just got my windows 7 laptop up and running again after having to reinstall the OS, it used to work on there but now it doesnt :-/

raccoon  -  May 26, 2013

I just use this script for the first time on Windows 7 and it works fine.

Sign in to comment

raccoon   -  Sep 11, 2010

You can add it manually, or script it to add it for you. Do you need help locating the various places Windows launches applications on startup?

For the average user, I'd recommend creating a Shortcut in your Start Menu > Startup folder.

 Respond  
wade2462   -  Sep 10, 2010

does this run on startup automatically or do I need to add it?

 Respond  
raccoon   -  Sep 04, 2010

Step 1). Install AutoHotkey. It's a script interpreter. It will allow you to execute .ahk script files.
Step 2). Copy my script into notepad, and save as EnableWin.ahk
Step 3). Double-click (run) the file EnableWin.ahk

If you don't want to see the green "H" tray icon in your systray, you can add the following line to the top of the script.

#NoTrayIcon
 Respond  
afp_romania   -  Sep 03, 2010

and how can i use it? :)

 Respond  
raccoon   -  Sep 01, 2010

Thanks for the props, jaytea!

Yes, AutoHotkey should be in every hobby-scripter's toolkit. The power and flexibility is like that of mIRC Script, but for the entire Windows environment.

Plus, you can compile scripts to .exe!

 Respond  
jaytea   -  Sep 01, 2010

if you're like me and only visit this site for code and discussion related to mIRC, you could quite easily glance over this snippet with the preconceived idea that it would offer you no utility. this couldn't be further from the truth! if you take a moment to skim over the description you will realize that this small snippet is the solution to a problem that plagues all of us Windows users.

download and install AutoHotKey if you haven't already (www.autohotkey.com/download) - it's 2MB. throw this snippet into NotePad and save it with a .ahk extension, open it, and watch as it runs quietly in the background. takes 2 minutes

thanks Raccoon!

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.