AnyDesk - How to start it with Admin/UAC requirement Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rc76
Posts: 144
Joined: 07 Nov 2020, 01:45

AnyDesk - How to start it with Admin/UAC requirement

Post by rc76 » 16 Oct 2021, 03:51

I have wrote a script to try to start/minimize/stop the AnyDesk.exe.

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

; ------------------------------------------------------------------------------


However I have encountered the UAC thing, that I cannot bypass.
00.png
00.png (45.7 KiB) Viewed 860 times
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!
rc76
Posts: 144
Joined: 07 Nov 2020, 01:45

Re: AnyDesk - How to start it with Admin/UAC requirement

Post by rc76 » 16 Oct 2021, 07:45

Thank you @mikeyww
Post Reply

Return to “Ask for Help (v1)”