-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathelevated_keymap.ahk2
42 lines (32 loc) · 1.09 KB
/
elevated_keymap.ahk2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#SingleInstance Force
#Requires AutoHotkey v2.0
#Include "utility.ahk2"
; any apps opened in an elevated script will run in administrator mode
if (not A_IsAdmin) {
try {
Run '*RunAs "' A_AhkPath '" /restart "' A_ScriptFullPath '"'
} catch Error as e {
MsgBox Format("{1}: {2}.`n`nFile:`t{3}`nLine:`t{4}`nWhat:`t{5}`nStack:`n{6}"
, type(e), e.Message, e.File, e.Line, e.What, e.Stack)
ExitApp(-1)
}
} else {
util_script_dir := EnvGet("UtilScriptDir")
; startup apps/scripts with elevated privilege
; So multiple UAC popups are merged into one!
Run(util_script_dir "\silent-bat-wrapper.vbs " util_script_dir "\injecter\WSL2-static-ip.bat")
RunIfNotExist("C:\Users\" A_UserName "\AppData\Local\Microsoft\WindowsApps\Snipaste.exe")
}
;
; Shortcuts
;
#^z::+!Backspace
#y::Invoker("ahk_exe Taskmgr.exe", "taskmgr")
#f::#v
#w::#1
#h::^+Right ; listary run
; pass hotkeys to non-SU script, this avoid programs being elevated
#e::#!e
#v::#!v
#c::#!c
;#+s::Invoker("Administrator: PowerShell 7", "wt")