jedivader February 2016

Autohotkey: How to unfocus a control without focusing another (unfocus all controls)?

I am writing an Autohotkey script that fiddles with some Photoshop windows and controls.

I need to be able to unfocus the currently focused control (say, Edit3), so that no control has focus after that (I could explain why exactly I need to do that if necessary, but it seems irrelevant, I just really need all controls unfocused).

AHK's ControlFocus command doesn't provide such an option.

I tried using a Windows Message like this:

SendMessage, 0x8, 0, 0, Edit3, A  ; WM_KILLFOCUS = 0x08

but it doesn't do anything. In comparison, the opposite one works as expected and focuses the control:

SendMessage, 0x7, 0, 0, Edit3, A  ; WM_SETFOCUS = 0x07

Perhaps I'm doing something wrong with the WM_KILLFOCUS message?

Just to clarify: I don't want to simulate clicks, switch windows, add new invisible controls which to focus etc. I just want to know how to unfocus a control.

So, any idea how to unfocus a control, without focusing another one?

Answers


ancalotoru February 2016

You can send #d and you will go to Desktop. Which is going to focus on the desktop but can work for you.

SendInput, #d


PGilm February 2016

If you are working with a browser or app that supports javascript, you may be able to implement the "blur" method:

document.getElementById("selector").blur();

See < http://javascript.info/tutorial/focus-blur > for more info and examples of elem.blurand input.onblur.

Hth,

Post Status

Asked in February 2016
Viewed 2,874 times
Voted 12
Answered 2 times

Search




Leave an answer