Code: Select all
; ------------------------------------------------------------------------------
#SingleInstance, Force ; Directly load without prompt of previous instance.
; ------------------------------------------------------------------------------
Gui, Main: Destroy
Gui, Main: +AlwaysOnTop
Gui, Main: Add, Text, x10, Test
Gui, Main: Show, x1000 y200
Return
GuiClose:
ExitApp
ESC::ExitApp
; ------------------------------------------------------------------------------
; App : Start / Show
1::
IfWinExist, ahk_exe AnyDesk.exe
{
WinActivate, ahk_exe AnyDesk.exe
WinGet, o_hWnd, ID, ahk_exe AnyDesk.exe
; o_hWnd := WinExist("Trade-Ideas Pro AI")
; MsgBox, 48, , hWnd: %o_hWnd%, 1
WinSet, AlwaysOnTop, Off, ahk_id %o_hWnd%
WinSet, AlwaysOnTop, Off, ahk_exe AnyDesk.exe
}
else
{
; Process do not exist, Start the App
RunWait, C:\Program Files (x86)\AnyDesk\AnyDesk.exe
WinActivate, ahk_exe AnyDesk.exe
WinGet, o_hWnd, ID, ahk_exe AnyDesk.exe
WinSet, AlwaysOnTop, Off, ahk_id %o_hWnd%
WinSet, AlwaysOnTop, Off, ahk_exe AnyDesk.exe
}
return
; ------------------------------------------------------------------------------
; App : Hide
2::
IfWinExist, ahk_exe AnyDesk.exe
{
WinActivate, ahk_exe AnyDesk.exe
WinSet, AlwaysOnTop, Off, ahk_id %o_hWnd%
WinMinimize, ahk_id %o_hWnd%
WinMinimize, ahk_exe AnyDesk.exe
}
else
{
; Process do not exist, do nothing.
}
return
; ------------------------------------------------------------------------------
; App : End
3::
IfWinExist, ahk_exe AnyDesk.exe
{
Process, Close, AnyDesk.exe
}
else
{
; Process do not exist, do nothing.
}
return
; ------------------------------------------------------------------------------
The background requirement is that:
(1) My Windows will auto-reboot with AHK at every night
(2) I want to use AHK to start the AnyDesk.exe after Windows is booted up (without me to intervene and click the UAC button.
Is there anyway I can do the above?
Thank you so much!