Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- the non-compiled script can run itself w/ UIA (aka UI Access, the EXE should not use UIA b/c the personal UIA certificate of the EXE that it requires, expires after a period of time)
- and the if statement to detect it being a compiled script can check if it's running as admin, then if it's not it can just attempt to run itself as admin via predetermined tasks that should have been added to task scheduler, which it then triggers via code and terminates the non-admin instance.. generating an error if the task is not added to task scheduler yet. task scheduler can run the EXE as admin w/o the elevation prompt, so when startup task already runs it as admin then the script itself won't have to request task scheduler to take care of that
- the EXE running as admin would need to prevent running other software as admin, because it runs other software as admin by default, which usually isn't good
- Time Saver.ahk:
- /*
- This is a productivity enhancer plus some quality-of-life features that takes care of tedious tasks for you, saving time for what matters. Click on the tray icon to view hotkey info.
- The compiled script can be found at: https://github.com/Lorenzo501/Lorenzo501/blob/main/My%20Projects%20(Extra)/Compiled/Time%20Saver.exe
- You won't have to dl the libraries nor have AHK installed if you use the compiled script, it will automatically create an INI file in AppData\Local.
- This non-compiled script has an embedded INI at the bottom, but you have to follow these two steps before you can run this script:
- Download and unzip archive in "Lib" folder: https://github.com/thqby/winrt.ahk
- Download raw file into "Lib" folder: https://github.com/Descolada/UIA-v2/blob/main/Lib/UIA.ahk
- ; To make hotkeys work when an admin window is active
- if (!A_IsCompiled && !InStr(A_AhkPath, "_UIA.exe"))
- {
- Run("*UIAccess " A_ScriptFullPath)
- ExitApp()
- }
- ; Determine whether to use the embedded INI or an INI file within AppData\Local
- if (A_IsCompiled)
- {
- global iniPath := EnvGet("LocalAppData") "Time Saver Config.ini"
- ; Creates an INI file in AppData\Local
- if (!FileExist(iniPath))
- {
- iniFileObj := FileOpen(iniPath, 0x101)
- iniFileObj.Write("/* EXAMPLE`n"
- "[_ActiveContextWindows]`n"
- "ahk_exe Taskmgr.exe=services.msc`n"
- "[_ExistingContextWindows]`n"
- "[_ExistingContextWindowPriority1]`n"
- "ahk_exe Unity.exe=C:\Users\loren\Documents\Unity projects\VOXEL WAR\Assets`n"
- "[_ExistingContextWindowPriority2]`n"
- "ahk_exe devenv.exe=C:\Users\loren\Documents\Unity projects\VOXEL WAR\Assets\Scripts`n"
- "[_ExistingContextWindowPriority3]`n"
- "ahk_exe notepad.exe=chrome.exe https://www.autohotkey.com/docs/alpha/ChangeLog.htm --start-maximized --disable-features=GlobalMediaControls`n"
- "[_ExistingContextWindowPriority4]`n"
- "Workspace - Visual Studio Code ahk_exe chrome.exe=chrome.exe https://www.autohotkey.com/docs/alpha/ChangeLog.htm --start-maximized --disable-features=GlobalMediaControls`n"
- "[_PreferredSmartRunInput]`n"
- "%LocalAppData%`n"
- "[_FullscreenVideosContextFolder]`n"
- "C:/Users/loren/Downloads/Movies and series`n"
- "[_FullscreenWindowsUnhideTaskbar]`n"
- "Sourcetree ahk_exe SourceTree.exe`n"
- "Software Ideas Modeler ahk_exe SoftwareIdeasModeler.exe`n"
- "*/`n`n"
- "/* Edit these variables yourself if necessary (e.g. to make it more specific you can add the ahk_class, and for the opposite effect you can replace the ahk_exe with an "
- "ahk_class or title)`n"
- "[ActiveContextWindows]`n"
- "[ExistingContextWindows]`n"
- "[PreferredSmartRunInput]`n"
- "[FullscreenVideosContextFolder]`n"
- "[FullscreenWindowsUnhideTaskbar]`n"
- "*/")
- iniFileObj.Close()
- }
- }
- else
- global iniPath := A_ScriptFullPath
- ; Makes tray icon merely show hotkey info on click
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement