Jump to content

Remove focus from a button


 Share

Recommended Posts

Greetings, when I create a GUI with AutoIt if I click on a button the focus is automatically created, is it possible to hide it? The focus should disappear both if I don't click the button and if I click it.

Edited by Skdp
Link to comment
Share on other sites

Just use ControlFocus() and focus another control or if you want to prevent dotted focus lines then check out this thread.

#include <WinAPISysWin.au3>

$hGUI = GUICreate('Test')
$cButton = GUICtrlCreateButton('Click Me', 100, 100, 100, 30)
$hButton = GUICtrlGetHandle($cButton)
$cDummy = GUICtrlCreateLabel('', 0, 0, 0, 0)
GUISetState(@SW_SHOW, $hGUI)

While True
    Switch GUIGetMsg()
        Case -3 ; GUI_EVENT_CLOSE
            Exit
        Case $cButton
            MsgBox(0, '', 'You clicked the button')
    EndSwitch
    If _WinAPI_GetFocus() = $hButton Then ControlFocus($hGUI, '', $cDummy)
WEnd
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...