Thank you very much for this interesting input. The link provided speaks about a function "HideFocusBorder" which didn't work for me. But it gave clues to go deeper in understanding WM_UPDATEUISTATE
I found this interesting article :
https://devblogs.microsoft.com/oldnewthing/20130517-00/?p=4323 which made me realize that the dots reveal what was the last input : mouse or keyboard.
- If I (re)load my program, it's by mouse, so I don't have the dots
- If I run hotkey, it's by keyboard, so I have the dots.
To confirm, I ran the program by keyboard (hit enter on windows explorer) and I got the dots. And I reran the function by mouse (I said it is the action for OK button) and I lost dots.
Now I have to look how to be sure to have (or not) dots, whatever action built the Gui.
I shorten my message which initialy explained many discovery steps. I tried many things with
Code: Select all
MAKEWPARAM(l, h)
{
return (l & 0xffff) | (h & 0xffff) << 16
}
WM_UPDATEUISTATE := 0x0128
UIS_SET := 1
UIS_CLEAR := 2
UIS_INITIALIZE := 3
UISF_HIDEFOCUS := 0x1
UISF_HIDEACCEL := 0x2
UISF_ACTIVE := 0x4
PostMessage WM_UPDATEUISTATE, MAKEWPARAM(UIS...,UISF...), 0,, "ahk_id " MyGui.Hwnd
I changed "UIS..." and "UISF..." with values declared above and noticed different behaviours when loading the program (by mouse or keyboard, as explained above) and when doing action like mouseover, tab key, alt key, mouseover after those keys etc.
So I wanted to get rid of different behaviours. Two ways : to have or not to have dots every time, even with Tab or mouseover. I made many test/combinations (and got very helped with this great article :
https://devblogs.microsoft.com/oldnewthing/20171124-00/?p=97456 ). Finally :
- To have dots all the time, a simple way is to check "Underline keyboard shortcuts and access keys" in window's keyboard parameters. But it's not set by the program so it depends where the program will be ran. The various tests reavealed (something maybe obvious for experts) that the UIstate had to be 0. So I thought I just had to run (without the lines mentionned above) :
Code: Select all
PostMessage WM_UPDATEUISTATE, MAKEWPARAM(UIS_CLEAR,UISF_HIDEFOCUS&UISF_HIDEACCEL&UISF_ACTIVE), 0,, "ahk_id " MyGui.Hwnd ;UISF_HIDEFOCUS&UISF_HIDEACCEL&UISF_ACTIVE is 7
But no, it doesn't do the trick. However, If I do this two lines it's ok ("ok" just means it works, not that UIstate is 0) :
Code: Select all
PostMessage WM_UPDATEUISTATE, MAKEWPARAM(UIS_CLEAR,UISF_HIDEFOCUS), 0,, "ahk_id " MyGui.Hwnd ;see remark bellow
PostMessage WM_UPDATEUISTATE, MAKEWPARAM(UIS_CLEAR,UISF_HIDEACCEL), 0,, "ahk_id " MyGui.Hwnd
Remark : I also noticed that the first line above (with UISF_HIDEFOCUS) isn't needed if the button hasn't been defined with the "Default" option.
- To remove dots all the time, if the button isn't "Default", then this lines seems to be enough:
Code: Select all
PostMessage WM_UPDATEUISTATE, MAKEWPARAM(UIS_SET,UISF_HIDEFOCUS), 0,, "ahk_id " MyGui.Hwnd
PostMessage WM_UPDATEUISTATE, MAKEWPARAM(UIS_SET,UISF_HIDEACCEL), 0,, "ahk_id " MyGui.Hwnd
There is no dots until mouseover of tab or Alt. Ok I shouldn't say dots are removed "all the time", but the behaviour is the same with clicks and keyboard.
If you want the (first) mouseover not to make dots appear, add
Code: Select all
PostMessage WM_UPDATEUISTATE, MAKEWPARAM(UIS_SET,UISF_ACTIVE), 0,, "ahk_id " MyGui.Hwnd
But after Tab the mouseover will react and put dots.
If the button has the Default option, I've no solution to remove dots so far.
I hope I've been clear since I drowned myself in all my tests!
Thanks again,
off and
mikeyww for your precious help. I hope this post will help someone.