Have a "Recent .ahk" quick access menu...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
OrangeCat
Posts: 65
Joined: 14 Jun 2022, 00:47

Have a "Recent .ahk" quick access menu...

28 Aug 2023, 13:48

Hello...

I was wondering if one would know of a way on how I'd be able to have a «executed via shortcut-icon's "recent launched AHKs" quick access context-menu» (similar to shown in picture).

Or, even better, to know how I could create a .ahk filetype's new context-menu "custom sub-menu entry" that would display a "total x-amount of recent-executed scripts".

Any help would be greatly appreciated.
Thanks.

(Note: included in screenshot is Windows 10's taskbar with a OpenShell-set theme).
Attachments
AHK, Shortcut-Icon's ''Context-Menu Inquiry'' 46.875.png
AHK, Shortcut-Icon's ''Context-Menu Inquiry'' 46.875.png (86.77 KiB) Viewed 378 times
User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Have a "Recent .ahk" quick access menu...

28 Aug 2023, 14:17

Just ideas here: you could have your scripts log themselves somewhere, or use the Windows Recent directory to find the script links.
User avatar
OrangeCat
Posts: 65
Joined: 14 Jun 2022, 00:47

Re: Have a "Recent .ahk" quick access menu...

29 Aug 2023, 06:29

I was thinking about Windows recent directory while writing this... the classic one located in %APPDATA%\Microsoft\Windows\Recent Items
(I'll have to do a quick search on how to extend said-directory to exceed 7 days)

Although, if not too much trouble, would you be able to point me to the proper direction of/or show a quick example of how I'd proceed to script something that...
‒ can read a folder's contained item of a specified directory-path of preference.
‒ while only reading file-extensions of preference.
‒ as-well as to only be reading .ahk files starting from a specified timestamp of preference?


And, if still not too much trouble,
How to do so via using read-preferences from an either a .xml or from a .ini file-extension?
I'd use certain variables such as:


‒ SelectDir = %AppData%\Microsoft\Windows\Recent Items
‒ SelectExt = ahk {using commas to include additional file-extensions}
‒ StartTime = 2023-08-01
‒ EndTime = {date entry, or, leaving blank would mean up to now}
User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Have a "Recent .ahk" quick access menu...

29 Aug 2023, 16:54

Ideas to get you started are below. "Recent" can indicate various forms of file access, not limited to execution.

Code: Select all

#Requires AutoHotkey v1.1.33
#SingleInstance
recent     := A_AppData "\Microsoft\Windows\Recent"
scriptList := []

; Identify recently accessed scripts
Loop Files, % recent "\*.lnk"                  ; Loop through the recent LNK files
{ FileGetShortcut % A_LoopFilePath, target     ; Get the link's target path
  If FileExist(target) && target ~= "i)\.ahk$" ; If target is an AHK script,
   scriptList.Push(target)                     ;  then add to array
}

; Display script's path and last access time
For n, script in scriptList                    ; Loop through array's elements
 If FileExist(script) {
  FileGetTime accessTime, % script, A          ; Get the script's last access time
  FormatTime accessTimeTxt, % accessTime, yyyy-MM-dd 'at' HH:mm
  MsgBox 0, % "Recent script (" n " of " scriptList.Length() ")", % script "`n`nAccessed: " accessTimeTxt
 }

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo, Bing [Bot], Google [Bot] and 141 guests