; Save this file somewhere (I keep it on my desktop) as min_teamviewer.ahk and run it once
; It will create a shortcut in the Startup folder, so it will be loaded automatically on system reboot


#SingleInstance Force

;LWin::
;RWin::

DetectHiddenText, on

; the line below adds a shortcut to the script in the Startup folder, so it starts automatically when the computer restarts
FileCreateShortcut, %A_ScriptFullPath%, %A_Startup%\My AHK Script.lnk, %A_ScriptDir%

Loop
{

; Wait for the side panel to appear (it has ahk_class of TV_ControlWin, can check with Window Spy tool).
WinWait, ahk_class TV_ControlWin,, 1
if ErrorLevel
{

} else {

	; Get width of the side panel
	WinGetPos, , , Width, , ahk_class TV_ControlWin
	
	; If width is more than 200 pixels, it means that the side panel is shown
	IfGreater, Width, 200 
	{
		; Click on the button (Window Spy says that it has ClassNN of Button9) to minimize the panel (makes it slide to the right)
		ControlClick, Button9, ahk_class TV_ControlWin
	}

}

; Sleep 3 seconds
Sleep, 3000
}