#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. ; ;------------------------------------------------------------------------------------; ; Script Menu Qwertyfly Design ; ;------------------------------------------------------------------------------------; ;Version 0.003 SetVar := SettingsGet() Collapsed := false drawMain(SetVar) #IfWinActive, ahk_class illustrator SC029:: ; Start Of Script KeyWait, VKc0 ; Wait for shortcut to be lifted before running script WinActivate, ahk_class AutoHotkeyGUI, Script Panel return #IfWinActive, ahk_class AutoHotkeyGUI, Script Panel SC029:: ; Start Of Script KeyWait, VKc0 ; Wait for shortcut to be lifted before running script WinActivate, ahk_class illustrator return ; ;---- Triggers Main Window ---; ; Submit: Gui, WinMain:Submit If (MyCh == "") { return } Else If (MyCh > TotalCount) { GuiControl,,MyCh, Return } Else stat := MyCh + 3 ControlGetText, Sel,% "Static" . stat Selection := RegExReplace( Sel, "\A[0-9]+\s-\s" ) Run,% SetVar[11] . " " . SetVar[9] . "\" . Selection GuiControl,,MyCh, ;Clear MyCh edit Box return ; CLICK: GuiControlGet,%A_GuiControl%,,, Text Selection := RegExReplace( %A_GuiControl%, "\A[0-9]+\s-\s" ) Run,% SetVar[11] . " " . SetVar[9] . "\" . Selection return ; EXPAND: MsgBox, expand via mouse. has not been implemented as yet... return ; Qsettings: drawSett(SetVar) return ; WinMainGuiEscape: Qcollapse: If (Collapsed == false) { newHeight := 0 Qhigh := 65 Collapsed := true } Else If (Collapsed == true) { newHeight := 15 Qhigh := (TotalCount * 15) + (folderQty * 15) + 65 Collapsed := false } Loop, %TotalCount% { GuiControl, Move,% "Vari" . A_Index,% "h" . newHeight } Loop %folderQty% { GuiControl, Move,% "FolVar" . A_Index,% "h" . newHeight GuiControl, Move,% "FolNameVar" . A_Index,% "h" . newHeight } Qedit := Qhigh - 27 Qedit2 := Qhigh - 20 GuiControl, Move, MyChText,% "y" . Qedit2 GuiControl, Move, MyCh,% "y" . Qedit Gui, WinMain:Show, h%Qhigh% NoActivate, Script Panel ; Show Window return ; WinMainGuiClose: ;Gui, WinMain:Hide Return ; ;-- Triggers Settings Window -; ; Qsave: SettSave() return Qreload: Reload return WinSettGuiEscape: Gui, WinSett:Destroy return ; ;-----------------------------; ; ; - - - Settings File - - - ; Remember to update expectedLines in settings file ; 1) expectedLines ; 2) Background Colour ; 3) Foreground Colour ; 4) Heading Font ; 5) Main Font ; 6) Symbol Font ; 7) Window Title ; 8) Settings Button ; 9) Directory of Scripts ;10) List of File Types to show in panel ;11) Path to illustrator ;12) Collapse Window Button ;13) Save and Return Button (settings window) ;14) Reload Program Button (settings window) ;15) Heading Font Size ;16) List Font Size ;17) Button Font Size ;18) Arrow Font Size ; - - - - - - - - - - - - - ; ; ;*****Functions*****; ; ;-- Vars from Settings File --; SettingsGet() { settings := "Settings.txt" SettArray := Object() ;Initalise Array for settings Loop,Read,%settings%,%settings% ;Loop through Text File { SettArray.Insert(A_LoopReadLine) ;Append this line to the array. actualLines = % A_Index ;Total number of Lines in text File } expectedLines := SettArray[1] ;Test that correct number of Settings got retrieved If (actualLines > expectedLines) { MsgBox, "Settings file contains too many lines..." Return } Else If (actualLines < expectedLines) { MsgBox, "Settings file contains too few lines..." Return } Return SettArray } ;-----------------------------; ; ;------ Settings Window ------; drawSett(SetVar) { Global settLineHeight :=20 Gui, WinSett:+AlwaysOnTop -Caption -SysMenu +ToolWindow +Border Gui, WinSett:Margin,6 ,0 Gui, WinSett:Color, % SetVar[2] Gui, WinSett:Font,% "S" SetVar[15] " w600 C" SetVar[3],% SetVar[4] Gui, WinSett:Add, Text, x10 y5 h35 w320 +Center, Settings Gui, WinSett:Font,% "S" SetVar[17] " w200 C" SetVar[3],% SetVar[6] ;Set font for return button Gui, WinSett:Add, Text, x5 y5 h20 gQsave,% SetVar[13] ;Save and Return button Gui, WinSett:Add, Text, x310 y5 h20 gQreload,% SetVar[14] ;Reload Program button ; settLineHeight += 15 Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[3], % SetVar[5] ;Set Main Font for title Gui, WinSett:Add, Text,% "x15 y" . settLineHeight . " h15 " , Path to Illustrator: ;Add Line to Window Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[2], % SetVar[5] ;Set Main Font for edit Gui, WinSett:Add, Edit, h17 w300 vProgramPath Limit200 ,% SetVar[11] ;Add Edit Box for Program Path ; settLineHeight += 38 Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[3], % SetVar[5] ;Set Main Font for title Gui, WinSett:Add, Text,% "x15 y" . settLineHeight . " h15 " , Path to Script Folder: ;Add Line to Window Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[2], % SetVar[5] ;Set Main Font for edit Gui, WinSett:Add, Edit, h17 w300 vScriptFolderPath Limit200,% SetVar[9] ;Add Edit Box for Script Folder Path ; settLineHeight += 38 Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[3], % SetVar[5] ;Set Main Font for title Gui, WinSett:Add, Text,% "x15 y" . settLineHeight . " h15 " , List of File Types to show in panel: ;Add Line to Window Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[2], % SetVar[5] ;Set Main Font for edit Gui, WinSett:Add, Edit, h17 w300 vListOfTypes Limit50,% SetVar[10] ;Add Edit Box for Script Folder Path ; settLineHeight += 38 Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[3], % SetVar[5] ;Set Main Font for title Gui, WinSett:Add, Text,% "x15 y" . settLineHeight . " h15 " , Background Colour: ;Add Line to Window Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[2], % SetVar[5] ;Set Main Font for edit Gui, WinSett:Add, Edit, h17 w140 vBGcol Limit6,% SetVar[2] ;Add Edit Box for Script Folder Path ; Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[3], % SetVar[5] ;Set Main Font for title Gui, WinSett:Add, Text,% "x175 y" . settLineHeight . " h15 " , Foreground Colour: ;Add Line to Window Gui, WinSett:Font,% "S" SetVar[16] " w500 C" SetVar[2], % SetVar[5] ;Set Main Font for edit Gui, WinSett:Add, Edit, h17 w140 vFGcol Limit6,% SetVar[3] ;Add Edit Box for Script Folder Path ; settLineHeight += 38 Gui, WinSett:Font,% "S6 w500 C" SetVar[3], % SetVar[5] Gui, WinSett:Add, Text,% "x15 y" . settLineHeight . " h15 " , Version 0.003 ; Gui, WinSett:Show, h200 , Script Panel ; Show Window } ;-----------------------------; ; ;-- Save Settings and return -; SettSave() { Global GuiControlGet, newSet2,, BGcol GuiControlGet, newSet3,, FGcol GuiControlGet, newSet9,, ScriptFolderPath GuiControlGet, newSet10,, ListOfTypes GuiControlGet, newSet11,, ProgramPath FileMove, Settings.txt, Settings.bac,1 FileAppend,% SetVar[1] . "`n", Settings.txt FileAppend,% newSet2 . "`n", Settings.txt FileAppend,% newSet3 . "`n", Settings.txt FileAppend,% SetVar[4] . "`n", Settings.txt FileAppend,% SetVar[5] . "`n", Settings.txt FileAppend,% SetVar[6] . "`n", Settings.txt FileAppend,% SetVar[7] . "`n", Settings.txt FileAppend,% SetVar[8] . "`n", Settings.txt FileAppend,% newSet9 . "`n", Settings.txt FileAppend,% newSet10 . "`n", Settings.txt FileAppend,% newSet11 . "`n", Settings.txt FileAppend,% SetVar[12] . "`n", Settings.txt FileAppend,% SetVar[13] . "`n", Settings.txt FileAppend,% SetVar[14] . "`n", Settings.txt FileAppend,% SetVar[15] . "`n", Settings.txt FileAppend,% SetVar[16] . "`n", Settings.txt FileAppend,% SetVar[17] . "`n", Settings.txt FileAppend,% SetVar[18] . "`n", Settings.txt Reload return } ;-----------------------------; ; ;---- Drag Window w/ Mouse ---; WM_LBUTTONDOWN() { PostMessage, 0xA1, 2 } ;-----------------------------; ; ;-------- Menu Window --------; drawMain(SetVar) { Global heightPos := 20 ;Height for Main Window Heading Gui, WinMain:+AlwaysOnTop -Caption -SysMenu +ToolWindow +Border ;Initalise Main Window Gui, WinMain:Margin,6 ,0 ;Fix Margins for Main Window Gui, WinMain:Color, % SetVar[2] ;Set Colour for Main Window Gui, WinMain:Font,% "S" SetVar[15] " w600 C" SetVar[3],% SetVar[4] ;Set font for Heading Gui, WinMain:Add, Text, x10 y5 h35 w320 +Center,% SetVar[7] ;Heading Gui, WinMain:Font,% "S" SetVar[17] " w200 C" SetVar[3],% SetVar[6] ;Set font for Settings button Gui, WinMain:Add, Text, x5 y5 h20 gQsettings,% SetVar[8] ;Settings button Gui, WinMain:Add, Text, x310 y5 h20 gQcollapse,% SetVar[12] ;Collapse Window button Gui, WinMain:Font,% "S" SetVar[16] " w500 C" SetVar[3], % SetVar[5] ;Set font for script list ; showList() Qhigh := (TotalCount * 15) + (folderQty * 15) + 65 showWinMain() MainLoop() } ; ;-----------------------------; ; ;-------- WinMain loop -------; MainLoop() { Global Qloop: WinWaitActive, ahk_class illustrator, ;---> Work only from Illustrator Gui, WinMain:Show, h%Qhigh% NoActivate, Script Panel ; Show Window OnMessage(0x201, "WM_LBUTTONDOWN") ; Allow Drag Window w/ Mouse Qhold: WinWaitNotActive, ahk_class illustrator IfWinActive, ahk_class AutoHotkeyGUI, Script Panel { WinWaitNotActive, ahk_class AutoHotkeyGUI, Script Panel ;Sleep, 100 IfWinActive, ahk_class illustrator { Goto, Qhold } } Gui, WinMain:Hide Goto, Qloop return } ;-----------------------------; ; ;-------- Show WinMain -------; showWinMain() { Global Qedit := Qhigh - 27 Qedit2 := Qhigh - 20 Gui, WinMain:Font,% "S" SetVar[16] " w600 C" SetVar[3],% SetVar[5] Gui, WinMain:Add, Text, x10 y%Qedit2% h15 vMyChText +Left, Enter Number or Click Selection (ESC to Cancel) Gui, WinMain:Add, Edit, Number Limit2 x310 y%Qedit% w25 vMyCh Gui, WinMain:Add, Button, Default Hidden x0 y0 gSubmit return } ;-----------------------------; ; ;---------- Show List --------; showList() { Global TotalCount := 0 ;Reset List Counter TotalCount := list_files(SetVar[9],TotalCount,heightPos,SetVar[10]) ;Display First Level Scripts folderQty := 0 ;Reset Folder Counter foldersList := list_folders(SetVar[9],folderQty) ;Get list of sub folders Loop %folderQty% { heightPos += 15 Gui, WinMain:Font,% "S" SetVar[18] " w200 C" SetVar[3],% SetVar[6] ;Set font for Arrow arrowPos := heightPos - 3 Gui, WinMain:Add, Text,% "x4 y" . arrowPos . " h15 gEXPAND vFolVar" . A_Index , 4 Gui, WinMain:Font,% "S" SetVar[16] " w800 C" SetVar[3], % SetVar[5] folderName := foldersList[A_Index] SplitPath, folderName, folderName Gui, WinMain:Add, Text,% "x20 y" . heightPos . " h15 vFolNameVar" . A_Index ,% folderName Gui, WinMain:Font,% "S" SetVar[16] " w500 C" SetVar[3], % SetVar[5] TotalCount := list_files(foldersList[A_Index],TotalCount,heightPos,SetVar[10]) } } ;-----------------------------; ; ;-------- File Scanner -------; list_files(Directory,Count,ByRef heightPos,ScriptType) { Global Loop %Directory%\*.*, 0 { ext := A_LoopFileExt name := A_LoopFileName Loop, parse, ScriptType, `, { if (ext == A_LoopField) { heightPos += 15 ;Add Line Height Count ++ ;Total File Count in Dir Gui, WinMain:Add, Text,% "x15 y" . heightPos . " h15 gCLICK vVari" . Count , % Count . " - " . name ;Add Line to Window } } } return Count } ;-----------------------------; ; ;------- Folder Scanner ------; list_folders(Directory,ByRef folderQty) { foldersArray := Object() Loop %Directory%\*.*, 2 { foldersArray.Insert(A_LoopFileLongPath) folderQty ++ } return foldersArray } ;-----------------------------;