Very weird minimization behavior with certain browsers.

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
onandoffwhat
Posts: 1
Joined: 22 May 2024, 19:32

Very weird minimization behavior with certain browsers.

22 May 2024, 19:41

Hey, I was writing a script for my macropod that launches an app if it is not open, minimizes that app if it is open and viewable, un minimizes it (not maximizes) if it is open and minimized and on double button press, opens a new window.
It works perfectly on some apps i.e. Notepad, explorer, but causes some wired behavior on others. (Opera, Chrome, VS Code)
Sometimes it does not work, but then when I move the window around and play with it (I have no idea what I did), it suddenly works. I have linked a GIF demonstration below. There was one thing I was not able to capture:
sometimes, it spawns two weird white boxes at the bottom left of my screen that I can move around. I have never seen this before.
Demonstration: https://imgur.com/a/ngH9gdU
My code:

Code: Select all

^F10::
{
    {
        if (A_PriorHotkey = A_ThisHotkey && A_TimeSincePriorHotkey < 300) { 
            SetTimer(SingleClick,0)  ; Cancel the single click action
            Run("C:\Users\username\AppData\Local\Programs\Opera GX\opera.exe")
        } else {
            SetTimer(SingleClick,-300)  ; Set a timer for the single click
        }
        return
    }
    SingleClick()
    {
        ErrorLevel := ProcessExist("opera.exe")
        if (!ErrorLevel) {
            Run("C:\Users\username\AppData\Local\Programs\Opera GX\opera.exe")
        } else {
            state := WinGetMinMax("ahk_class Chrome_WidgetWin_1 ahk_exe opera.exe")
            if (state = -1) {
                WinRestore("ahk_class Chrome_WidgetWin_1 ahk_exe opera.exe")
                WinActivate("ahk_class Chrome_WidgetWin_1 ahk_exe opera.exe")
            } else {
                WinMinimize("ahk_class Chrome_WidgetWin_1 ahk_exe opera.exe")
            }
        }
    return
    }

}
niCode
Posts: 319
Joined: 17 Oct 2022, 22:09

Re: Very weird minimization behavior with certain browsers.

23 May 2024, 01:54

I don't find the demonstration all that useful. We have no idea when you're pressing the hotkey so it's unclear when it's doing something it's not supposed to. I'm still not sure what the "weird" behavior is.

When I used VSCode (I don't have Opera), I didn't notice any issues.

Perhaps try putting the window into a certain position (minimized, maximized, neither) and trying the hotkey in different combinations to see if you can determine a pattern when the issue arises.

And just for parity, here's the altered code I tested:

Code: Select all

^F10::
{
    static program := 'C:\Users\' A_UserName '\AppData\Local\Programs\Microsoft VS Code\Code.exe'

    if (A_PriorHotkey = A_ThisHotkey && A_TimeSincePriorHotkey < 300) {
        SetTimer(SingleClick,0)  ; Cancel the single click action
        Run(program)
    } else {
        SetTimer(SingleClick, -300)  ; Set a timer for the single click
    }
    SingleClick()
    {
        if !ProcessExist('Code.exe') {
            Run(program)
        } else {
            state := WinGetMinMax("ahk_exe Code.exe")
            if (state = -1) {
                WinRestore("ahk_exe Code.exe")
                WinActivate("ahk_exe Code.exe")
            } else {
                WinMinimize("ahk_exe Code.exe")
            }
        }
    }
}

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: big-jg, Vanda_a and 33 guests