I think it would be easier, when you define another Hotkey e.g. ^d::msgbox %A_CaretX%
So you had to press Ctrl and d.
...otherwise you had define all Classnames for the controls where you don`t want to use this hotkey:
Here an example:
Code: Select all
#If Not ActiveControlClassMatch("(.*Edit.*|_WwG|.*Excel.*|XLDESK1|MozillaWindowClass)") ;_WwG => MS Word, .*Excel.*|XLDESK1 => MS Excel etc.
d::msgbox %A_CaretX%
#If
ActiveControlClassMatch(Class) {
ControlGetFocus, FocusControl, A
ControlGet, FocusControlHwnd, Hwnd,, %FocusControl%, A
WinGetClass, FocusControlClass, ahk_id %FocusControlHwnd%
;msgbox |%FocusControlClass%|
Return RegExMatch(FocusControlClass, Class)
}
As alternative you also could use the Windowstitles, which makes it a bit easier:
Code: Select all
SetTitleMatchMode, RegEx
return
#IfWinNotActive (PSPad|Word|Excel|Firefox)
d::msgbox %A_CaretX%
#IfWinNotActive