; Ctrl + b
^b::
; The %ComSpec% command starts a new instance of the command interpreter (CMD.exe)
; /k means: keep (do not close) this session after execution. The console window will remain open, even if the task has been finished already.
Run, %ComSpec% /k powercfg batteryreport
; ahk_exe is used to identify a window belonging to the process with the given name
WinWait, ahk_exe cmd.exe ; wait until the specified window exists
Sleep, 4000 ; wait 4 seconds
; ControlSend sends simulated keystrokes to a window or control
ControlSend,, exit{Enter}, ahk_exe cmd.exe ; close cmd window
; open the output file (Win7):
Run %A_WinDir%\system32\battery-report.html
return
Подробнее см. Выполнить , ahk_exe , WinWait , ControlSend в документации.