#Requires AutoHotkey v2.0 #SingleInstance Force SetTitleMatchMode 2 ;========================================== ; CONFIGURATION ;========================================== emulatorPath := "C:\Users\username\AppData\Local\Android\Sdk\emulator\emulator.exe" avdName := "TV_Name" windowTitle := "Android Emulator - TV_Name" ; Adjust these values until the emulator perfectly covers your screen targetX := -85 targetY := -63 targetW := 2090 targetH := 2000 ;========================================== ; START EMULATOR ;========================================== if !WinExist(windowTitle) { Run Format('"{1}" -avd {2}', emulatorPath, avdName) } hwnd := WinWait(windowTitle,,180) if !hwnd { MsgBox "Android TV Emulator was not found." ExitApp } win := "ahk_id " hwnd WinActivate(win) WinWaitActive(win) ; Give Android TV time to finish loading Sleep 5000 ;========================================== ; HIDE TASKBAR ;========================================== WinHide("ahk_class Shell_TrayWnd") for tb in WinGetList("ahk_class Shell_SecondaryTrayWnd") WinHide("ahk_id " tb) ;========================================== ; REMOVE WINDOW BORDER ;========================================== WinSetStyle("-0xC00000", win) ; Remove title bar WinSetStyle("-0x40000", win) ; Remove thick border WinRedraw(win) ;========================================== ; RESIZE WINDOW ;========================================== WinMove(targetX, targetY, targetW, targetH, win) ; Keep on top WinSetAlwaysOnTop(1, win) ;========================================== ; OPTIONAL: ; Try to maximize the emulator rendering ;========================================== Send("{F11}") ;========================================== ; BLOCK SHORTCUTS ;========================================== !Tab::Return !Esc::Return !F4::Return #Tab::Return #d::Return #e::Return #r::Return #x::Return #i::Return #l::Return ^Esc::Return LWin::Return RWin::Return ;========================================== ; EXIT HOTKEY ; Ctrl + Shift + End ;========================================== ^+End:: { RestoreDesktop() ExitApp } ;========================================== ; WATCH FOR EMULATOR CLOSING ;========================================== SetTimer(CheckEmulator, 2000) CheckEmulator() { global win if !WinExist(win) { RestoreDesktop() ExitApp } } RestoreDesktop() { WinShow("ahk_class Shell_TrayWnd") for tb in WinGetList("ahk_class Shell_SecondaryTrayWnd") WinShow("ahk_id " tb) }