minimize window driver selenium excel vba

AFAIK there is no method for this in VBA implementation (there is in Python for example). There are a number of ways to manipulate size and position e.g.

bot.Window.SetSize 0, 0

Or you can run headless

bot.AddArgument "--headless"

You might also try to:

1) Emulate Windows Key + Down

2) Write a javscript function that performs window.minimize() and async execute off the parent window

3) Capture your target co-ordinates by generating a GetWindowPlacement call along with implementing your own WINDOWPLACEMENT struct. Looks like gets ugly fast.

See also:

Getting the size of a minimized window


Driver.Window.SetSize 0, 0 just made the window smaller, without minimizing the browser to the taskbar.

How to use GetWindowPlacement in selenium vba?

    'for vb6
Private Type POINTAPI
        x As Long
        y As Long
End Type
 
Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
 
 
Private Type WINDOWPLACEMENT
        Length As Long
        flags As Long
        showCmd As Long
        ptMinPosition As POINTAPI
        ptMaxPosition As POINTAPI
        rcNormalPosition As RECT
End Type
 
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
 
 
Private Sub Command1_Click()
    Dim wp As WINDOWPLACEMENT
    wp.Length = Len(wp)
    GetWindowPlacement targetHandle, wp
End Sub

Minimize window by windows API

This is a workaround for Selenium VBA not having a working minimize window option.

    #If VBA7 Then
        Public Declare PtrSafe Function FindWindow Lib "user32.dll" Alias "FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        Public Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hWnd As LongPtr, ByVal nCmdShow As Long) As Boolean
    #Else
        Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Boolean
    #End If

    Dim hwnd As Long
    Dim Botwindowtitle As String
    bot.Start    
    Botwindowtitle = bot.Window.Title
    hWnd = FindWindow(vbNullString, Botwindowtitle)
    Call ShowWindow(hWnd, 7) 'Show the window minimized (SW_SHOWMINNOACTIVE = 7) http://www.jasinskionline.com/windowsapi/ref/s/showwindow.html
     bot.Get https://www.google.com/