Skip to content

Commit c2e22ad

Browse files
committed
prevent the gui from taking focus, ever
fixes #3
1 parent 8d5e6f3 commit c2e22ad

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

vimium-everywhere.ahk

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ app_name = Vimium Everywhere Gui
1616
; Can be any color, but this value prevents a flickering until TransColor comes into effect (Linux):
1717
win_trans_color = rgba(0`,0`,0`,0)
1818

19+
DetectHiddenWindows, On
1920
; Figure out the offset which an invisible, caption-less Gui window still always has.
2021
; Expected is 0/0, but can be a few pixels.
21-
Gui, -Caption +ToolWindow
22-
Gui, Show, x0 y0, %app_name%
22+
Gui, -Caption +ToolWindow +0x80000000 +E0x8000000
23+
Gui, Show, x0 y0, %app_name% ; TODO also match pid somehow
2324
; TODO: Use WinWaitExist *command* instead (AHK_X11 does not yet offer it)
2425
GoSub, WinWaitExist
2526
; TODO: For all matches by app_name use compare by Gui WID instead (AHK_X11 does not yet offer it)
@@ -282,8 +283,8 @@ Show:
282283
}
283284
; TODO: Use WinWaitExist *command* instead (AHK_X11 does not yet offer it)
284285
GoSub, WinWaitExist
286+
; Because of 0x80000000, our gui never takes focus unless we force it with WinActivate.
285287
WinGet, gui_win_id, ID, %app_name%
286-
WinActivate, ahk_id %gui_win_id%
287288
WinSet, TransColor, %win_trans_color%, ahk_id %gui_win_id%
288289
WinSet, Transparent, 230, ahk_id %gui_win_id%
289290
WinSet, AlwaysOnTop, ON, ahk_id %gui_win_id%
@@ -310,10 +311,6 @@ Show:
310311
If control <>
311312
ControlClick, %control%, ahk_id %show_active_win_id%
312313
Gui, Hide
313-
; To prevent Gui from being the active window in the next `Build` call, we need to wait
314-
; for `Hide` to finish. Both WinSet, Bottom and WinMinimize did not help here.
315-
; TODO: Use WinWaitNotActive *command* instead (AHK_X11 does not yet offer it)
316-
GoSub, WinWaitNotActive
317314
is_showing = 0
318315
If simple_mode <> 1
319316
{
@@ -336,15 +333,6 @@ Scroll_Up:
336333
Send, {Up}
337334
Return
338335

339-
WinWaitNotActive:
340-
Loop
341-
{
342-
WinGetTitle, active_win_title, A
343-
If active_win_title <> %app_name%
344-
Break
345-
Sleep, 50
346-
}
347-
Return
348336
WinWaitExist:
349337
Loop
350338
{

0 commit comments

Comments
 (0)