skip to Main Content

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?

2

Answers


  1. 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
    
    Login or Signup to reply.
  2. last_active_win:=winexist("A") ;get the previous windows process before launching your gui
    
    Gui +AlwaysOnTop 
    
    Gui Add, Button, x10 w100 h30 , % 1
     
    Gui Show,, My GUI ;launch the gui which gets the focus 
    
    sleep 500
    
    WinActivate ahk_id %last_active_win% ;reactivate previous windows to unfocus controls from gui
    
    return
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search