Advertisement
Lorenzo501

Time Saver (compilation info & -snippets)

Aug 6th, 2024 (edited)
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. 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)
  2.  
  3. 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
  4.  
  5. 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
  6.  
  7.  
  8. Time Saver.ahk:
  9.  
  10. /*
  11. 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.
  12. The compiled script can be found at: https://github.com/Lorenzo501/Lorenzo501/blob/main/My%20Projects%20(Extra)/Compiled/Time%20Saver.exe
  13. 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.
  14. 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:
  15. Download and unzip archive in "Lib" folder: https://github.com/thqby/winrt.ahk
  16. Download raw file into "Lib" folder: https://github.com/Descolada/UIA-v2/blob/main/Lib/UIA.ahk
  17.  
  18.  
  19. ; To make hotkeys work when an admin window is active
  20. if (!A_IsCompiled && !InStr(A_AhkPath, "_UIA.exe"))
  21. {
  22. Run("*UIAccess " A_ScriptFullPath)
  23. ExitApp()
  24. }
  25.  
  26.  
  27. ; Determine whether to use the embedded INI or an INI file within AppData\Local
  28. if (A_IsCompiled)
  29. {
  30. global iniPath := EnvGet("LocalAppData") "Time Saver Config.ini"
  31.  
  32. ; Creates an INI file in AppData\Local
  33. if (!FileExist(iniPath))
  34. {
  35. iniFileObj := FileOpen(iniPath, 0x101)
  36. iniFileObj.Write("/* EXAMPLE`n"
  37. "[_ActiveContextWindows]`n"
  38. "ahk_exe Taskmgr.exe=services.msc`n"
  39. "[_ExistingContextWindows]`n"
  40. "[_ExistingContextWindowPriority1]`n"
  41. "ahk_exe Unity.exe=C:\Users\loren\Documents\Unity projects\VOXEL WAR\Assets`n"
  42. "[_ExistingContextWindowPriority2]`n"
  43. "ahk_exe devenv.exe=C:\Users\loren\Documents\Unity projects\VOXEL WAR\Assets\Scripts`n"
  44. "[_ExistingContextWindowPriority3]`n"
  45. "ahk_exe notepad.exe=chrome.exe https://www.autohotkey.com/docs/alpha/ChangeLog.htm --start-maximized --disable-features=GlobalMediaControls`n"
  46. "[_ExistingContextWindowPriority4]`n"
  47. "Workspace - Visual Studio Code ahk_exe chrome.exe=chrome.exe https://www.autohotkey.com/docs/alpha/ChangeLog.htm --start-maximized --disable-features=GlobalMediaControls`n"
  48. "[_PreferredSmartRunInput]`n"
  49. "%LocalAppData%`n"
  50. "[_FullscreenVideosContextFolder]`n"
  51. "C:/Users/loren/Downloads/Movies and series`n"
  52. "[_FullscreenWindowsUnhideTaskbar]`n"
  53. "Sourcetree ahk_exe SourceTree.exe`n"
  54. "Software Ideas Modeler ahk_exe SoftwareIdeasModeler.exe`n"
  55. "*/`n`n"
  56. "/* 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 "
  57. "ahk_class or title)`n"
  58. "[ActiveContextWindows]`n"
  59. "[ExistingContextWindows]`n"
  60. "[PreferredSmartRunInput]`n"
  61. "[FullscreenVideosContextFolder]`n"
  62. "[FullscreenWindowsUnhideTaskbar]`n"
  63. "*/")
  64. iniFileObj.Close()
  65. }
  66. }
  67. else
  68. global iniPath := A_ScriptFullPath
  69.  
  70. ; Makes tray icon merely show hotkey info on click
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement