Tab := MyGui.Add("Tab3","Choose1", ["AHK Desktop Folder","AHK Documents Folder","Python Folder"])
Each of these Tabs would correspond to a corresponding "Loop Files".
By choosing one of these Tabs, I could thus choose one of the files contained in these Folders.
Thereafter, I could "Double Click" or "Click OK" to open the chosen file.
In the current state of the script, only the 1st Tab displays the result of "Loop Files".
The following two Tabs contain absolutely NOTHING, and additionally I get this warning:
Warning: This variable appears to never be assigned a value.
Specifically: local LB
039: MyGui.Show()
042: {
▶ 043: if MsgBox("Would you like to launch the file or document below?`n`n" LB.Text,, 4) = "No"
044: Return
046: Try
I've tried various ways to fix this warning, but I still can't fix it.
Your help would be greatly appreciated. Thanks in advance.
Code: Select all
#Requires Autohotkey v2
#SingleInstance Force
MyGui := Gui()
RetrievedTitle := MyGui.Title
MyGui.SetFont("s12") ; Set a font size (11-point).
Tab := MyGui.Add("Tab3","Choose1", ["AHK Desktop Folder","AHK Documents Folder","Python Folder"])
MyGui.Add("Text",, "Pick a file to launch from the list below.")
Tab.UseTab(1)
LV := MyGui.Add("ListView", "xm r20 w700", ["Name","In Folder","Size (KB)","Type"])
LV.ModifyCol(1, 280) ; Auto-size each column to fit its contents.
LV.ModifyCol(2, 270) ; Auto-size each column to fit its contents.
LV.ModifyCol(3, 70) ; Make the Size column at little wider to reveal its header.
LV.ModifyCol(4, 50,) ; Make the Size column at little wider to reveal its header.
LV.OnEvent("DoubleClick", LaunchFile)
Loop Files, "C:\Users\UserName\Desktop\AutoHotkey\*.ahk" ; Change this folder and wildcard pattern to suit your preferences.
LV.Add(, A_LoopFileName, A_LoopFileDir, A_LoopFileSizeKB, A_LoopFileExt)
;MyGui.Add("Button", "Default", "Launch File").OnEvent("Click", LaunchFile)
Tab.UseTab(2)
LV := MyGui.Add("ListView", "xm r20 w700", ["Name","In Folder","Size (KB)","Type"])
LV.ModifyCol(1, 280) ; Auto-size each column to fit its contents.
LV.ModifyCol(2, 270) ; Auto-size each column to fit its contents.
LV.ModifyCol(3, 70) ; Make the Size column at little wider to reveal its header.
LV.ModifyCol(4, 50,) ; Make the Size column at little wider to reveal its header.
LV.OnEvent("DoubleClick", LaunchFile)
Loop Files, "C:\Users\UserName\Documents\AutoHotkey\*.ahk"
LV.Add(, A_LoopFileName, A_LoopFileDir, A_LoopFileSizeKB, A_LoopFileExt)
;MyGui.Add("Button", "Default", "Launch File").OnEvent("Click", LaunchFile)
Tab.UseTab(3)
LV := MyGui.Add("ListView", "xm r20 w700", ["Name","In Folder","Size (KB)","Type"])
LV.ModifyCol(1, 280) ; Auto-size each column to fit its contents.
LV.ModifyCol(2, 270) ; Auto-size each column to fit its contents.
LV.ModifyCol(3, 70) ; Make the Size column at little wider to reveal its header.
LV.ModifyCol(4, 50,) ; Make the Size column at little wider to reveal its header.
LV.OnEvent("DoubleClick", LaunchFile)
Loop Files, "C:\Users\UserName\Desktop\Script Python\*.py"
LV.Add(, A_LoopFileName, A_LoopFileDir, A_LoopFileSizeKB, A_LoopFileExt)
;MyGui.Add("Button", "Default", "Launch File").OnEvent("Click", LaunchFile)
MyGui.Show()
LaunchFile(*)
{
if MsgBox("Would you like to launch the file or document below?`n`n" LB.Text,, 4) = "No"
return
; Otherwise, try to launch it:
try Run(LB.Text)
if A_LastError
MsgBox("Could not launch the specified file. Perhaps it is not associated with anything.")
}