AutoHotkey Community

It is currently May 27th, 2012, 11:59 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: November 18th, 2010, 11:55 pm 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
One Script to rule them all, One Script to find them,
One Script to bring them all and in the darkness bind them


NOTE: As I stopped developing Master Script, I also created a spinoff that is more stable and simple, and allows for starting ANY file or program. See "AppStarter" further down for this version.

NOTE2: Development of The Master Script is permanently abandoned, consider this a topic saved for historic purposes only. See http://www.autohotkey.com/forum/topic71902.html for a far superior app/scriptlauncher!

Master Script

Link to stable version: http://www.autohotkey.net/~sumon/Master%20Script.rar
Code: (Scroll to the bottom of the post - note that the code will contain newer updates as we go along, I'll update the .zip when I am satisfied with another "stable" version)


Hey again AHK community! I was in "creative mode" today, and got caught in this little project of mine - I created a script to let me manage all the awesome scripts I have. Instead of manually having to edit the AHK files and add hotkeys to my "Always running" script, I wanted to have a "Master Script" that can list, somehow sort, keybind and eventually autostart any scripts from my script folder. I have a vague memory there was someone who did something like this, if you found his script you can of course compare and see which you prefer.

I'll take the freedom of inserting a screenshot for easier overview:
Image

The idea of this Master Script is simple, yet powerful. It parses its' folder for AHK scripts and lets you store data about them - A hotkey to launch them and if you want to autostart them or not. You can also run the scripts directly from this "Master Script". Might not sound so awesome, but being able to keybind Master Script to something handy gives you dozens of scripts at the tips of your finger.

How to run it:

Put the Master Script.ahk and Master Script Startup.ahk in your desired folder (that is, the folder that contains the scripts that you want to manage). Just open the Master Script.ahk to parse your scripts, and if you want to add hotkeys (or deactivate them - that is, remove them from the Master Script list and place them in a subfolder - "Inactive scripts". A simple workaround for now, but hey - My "Scripts" folder DID get cleaner, maybe you like it too!). Save and exit.

Next, run Master Script Startup.ahk. Et voilá, autostart-scripts will be started, and hotkey'd scripts will be hotkey'd. That's it!

(By the way, Master Script Startup places a .lnk of itself in your Autostart folder, so you can just install and forget this. It shouldn't be a nuisance, but if you don't want to use Master Script in the future, either edit the code or remove the Autostart .lnk manually. I might edit this somehow if it's desired - for me it's how I want it, makes the installation on new computers really easy).

If you want to see the code (else I'd recommend following the link and unzipping the contents to your script folder), here it is:

Master Script
Code:
; Script working name: Master Script
; Language:       English
; Platform:       Windows XP
; Author: Sumon (find me at AHK forums, www.autohotkey.com/forum)
; With help from: small_c0d3r
; Script Function: To be added: Searches "this" (%A_ScriptDir%) folder for scripts, and shows a GUI for enabling/disabling them, launching them, and adding hotkeys to launch them.
#singleinstance force
; Menu, Tray, Icon , msicon.ico, 1, 1 ---- OMG the icon was fugly
FileList =  ; Initialize to be blank.
Loop, *.ahk, 0, 1
{
   If (A_LoopFileDir = "Inactive Scripts")
      Continue
   Else
   {      
    FileList = %FileList%%A_LoopFileName%`n ;`n
   If (A_LoopFileDir = "")
      FileDir = %FileDir%\`n
   Else
      FileDir = %FileDir%`n%A_ScriptsDir%%A_LoopFileDir%\`n
}
}
Loop, parse, FileDir, `n
{
    if A_LoopField =  ; Ignore the blank item at the end of the list, for Directories
   {
   ; FileCount := A_Index-1 ; To also ignore the blank item in future "filecounts"
   continue
   }
   Dir%A_Index% = %A_LoopField%
}
; Sort, FileList
Loop, parse, FileList, `n
{
    if A_LoopField =  ; Ignore the blank item at the end of the list.
   {
   FileCount := A_Index-1 ; To also ignore the blank item in future Filecounts
        continue
      }
      File%A_Index% = %A_LoopField%
   /*
   MsgBox, 4,, File number %A_Index% is %A_LoopField%.  Continue?
    IfMsgBox, No
        break
      */
}
IniWrite, %Filecount%, Master Script Settings.ini, Filecount, Filecount
IniRead, Filecount, Master Script Settings.ini, Filecount, Filecount, 0
Loop, %Filecount% ; Inireads all needed values
{
   Iniread, Scriptname%A_Index%, Master Script Settings.ini, Scriptname, Script%A_Index%
   Iniread, Autostart%A_Index%, Master Script Settings.ini, Autostart, Script%A_Index%
   Iniread, Hotkey%A_Index%, Master Script Settings.ini, Hotkey, Script%A_Index%
   Iniread, Winkey%A_Index%, Master Script Settings.ini, Winkey, Script%A_Index%
   IniRead, ScriptDir%A_Index%, Master Script Settings.ini, Directory, Script%A_Index%, %A_ScriptDir%
   ; File%A_Index% := Scriptname%A_Index% <--- Commented out since there was a conflict
}
CreateGUI:
Gui -Maximizebox
Gui, Add, Text,, ... parsed your folder(s) for %Filecount% files...
Gui, Add, Button, gSubmit, Save && Update
; Gui, Add, Button, xp+95 yp gMasterstartup, Master Startup
Gui, Add, Button, xp+90 yp gReset, Reset
Gui, Add, Button, xp+50 yp w25 gHelp, ?
Gui, Add, Button, xp+30 yp gSettings, Settings
Gui, Add, Button, xp+50 yp gExit, Exit
Gui, Add, Text, y+15 xp-200, Run script   |   Autostart   |   Hotkey   |   +Win key?   |    Hide
Gui, Add, Tab, w300 h960 Buttons, 1-15|16-30|31-45|46-60|61-75
Gui, Tab, 1
Loop, %Filecount%
{
FileText := File%A_Index%
CurrentScriptDir := ScriptDir%A_Index%
PreviousScriptDir := "Null"
If (CurrentScriptDir ! PreviousScriptDir)
MsgBox New directory is %CurrentScriptDir%
   ;Gui, Add, Text, x20 yp+35, %CurrentScriptDir%
PreviousScriptDir := ScriptDir%A_Index%
If (A_Index = 16)
   Gosub, NewTab16
If (A_Index = 31)
   Gosub, NewTab31
If (A_Index = 46)
   Gosub, NewTab46
If (A_Index = 61)
   Gosub, NewTab61
Gui, Add, GroupBox, x20 yp+35 w350, %FileText%
GUI, Add, Button, Section xp+10 yp+20 h20 r1 gLaunchFileselect, %A_Index%
LaunchindexN = Launchindex%A_Index% ; ?
n := Autostart%A_Index%
Gui, Add, Checkbox, xp+70 yp+5 r1 vAutostartN%A_Index% checked%n%
n := Hotkey%A_Index%
Gui, Add, Hotkey, xp+50 yp-5 w70 vHotkeyN%A_Index%, %n%
n := Winkey%A_Index%
Gui, Add, Checkbox, xp+75 yp+5 r1 vWinkeyN%A_Index% checked%n%
Gui, Add, Checkbox, xp+75 yp vDeactivateN%A_Index%
LastScriptListed = %A_Index%
}
Gui, Color, EFFAE8
Gui, Show
return
NewTab16:
Gui, Tab, 2
Gui, Add, Text, x0 y100,
return
NewTab31:
Gui, Tab, 3
Gui, Add, Text, x0 y100,
return
NewTab46:
Gui, Tab, 4
Gui, Add, Text, x0 y100,
return
NewTab61:
Gui, Tab, 5
Gui, Add, Text, x0 y100,
return
reset:
Gui, Destroy
Gosub, CreateGUI
return
Submit:
Gui, Submit, nohide
Loop, %FileCount%
{
ScriptnameIni := File%A_Index%
IniWrite, %ScriptnameIni%, Master Script Settings.ini, Scriptname, Script%A_Index%
AutostartIni := AutostartN%A_Index%
DirIni := Dir%A_Index%
IniWrite, %DirIni%, Master Script Settings.ini, Directory, Script%A_Index% ; This row and above was added by small_c0d3r to allow for recursing foldersearch
IniWrite, %AutostartINI%, Master Script Settings.ini, Autostart, Script%A_Index%
HotkeyINI := HotkeyN%A_Index%
IniWrite, %HotkeyINI%, Master Script Settings.ini, Hotkey, Script%A_Index%
WinkeyINI := WinkeyN%A_Index%
IniWrite, %WinkeyINI%, Master Script Settings.ini, Winkey, Script%A_Index%
DeactivateINI := DeactivateN%A_Index% ; Yes, I know the this INI value won't be used, but can be good to have if someone wants to change the script
IniWrite, %DeactivateIni%, Master Script Settings.ini, Deactivate, Script%A_Index%
Filemovetext := File%A_Index%
FileCreateDir, Inactive Scripts
If (DeactivateN%A_Index% = 1)
FileMove, %DirIni%\%Filemovetext%, %A_ScriptDir%\Inactive Scripts\
}
reload
return
Settings:
Iniread, Extrafolder1, Master Script Settings, ExtraFolder, 1, _ _ _
Gui, 2:+Owner1 +Resize
Gui, 2: Add, Text,, SETTINGS ARE NOT YET FUNCTIONING - THEY ARE TO BE IMPLEMENTED SOON (tm)
Gui, 2:Add, Text,, Folders to be searched...`nDefault: %A_ScriptDir%`n1: %ExtraFolder1%`n2: %ExtraFolder2%`n3: %Extrafolder3%
Gui, 2: Add, Button, gAddFolder, Add folder...
Gui, 2:Add, Button, gSubmit2, Save settings
Gui, 2:Show, w400 h300, Settings
return
AddFolder:
FileSelectFolder, ExtraFolder1, *%A_ScriptDir%,, Select a folder to include in future searches
IniWrite, %Extrafolder1%, Master Script Settings, ExtraFolder, 1
return
Submit2:
Gui, 2:Submit
Gui, 2:Destroy
return
Exit:
ExitApp
return
reload:
Reload
return
Masterstartup:
MsgBox FAIL
return
Help:
MsgBox Run script - Runs the chosen script `nAutostart - The chosen script will always start when you start your computer `nHotkey & Win key - Assign a hotkey to launch the selected script, if you want to combine it with the Windows key: Also tick the "Win key?" button (remember to deactivate it when it's not used) `nDeactivate - Moves the designated script to a subfolder called "Inactive scripts", so it will not appear in this list
return
Launch:
SoundPlay, *64
Run, %FiletoLaunch%
return
; THE FOLLOWING "LaunchFileSelect subroutine considers which button was pressed (thanks to small_c0d3r)
LaunchFileSelect:
Selected_File:= File%A_GuiControl%
Selected_File_Dir:= Dir%A_GuiControl%
FiletoLaunch = %A_ScriptDir%%Selected_File_Dir%%Selected_File%
;Msgbox, %FiletoLaunch%
Gosub, Launch
Return


Master Script Startup

Code:
; Script working name: Master Script Startup
; Goes hand in hand with: Master Script.ahk, and Master Script Settings.ini
; Language:       English
; Platform:       Windows 7
; Version author: Sumon (find me at AHK forums, www.autohotkey.com/forum)
; Script Function: Autostarts itself (if commanded to) and other scripts you wish to autostart. Also keeps hotkeys available for desired scripts.
#singleinstance force
#NoEnv
SetBatchLines, -1
SplashTextOn, 400, 70, Master Script, Master Script has been launched :)
Sleep 3000
SplashTextOff
IfNotExist %A_Startup%\Master Script Startup.lnk ; Adds Master Script Startup to Autostart
FileCreateShortcut , %A_ScriptDir%\Master Script Startup.ahk, %A_Startup%\Master Script Startup.lnk
IniRead, Filecount, Master Script Settings.ini, Filecount, Filecount, 0
Loop, %Filecount% ; Inireads all needed values
{
   Iniread, Scriptname%A_Index%, Master Script Settings.ini, Scriptname, Script%A_Index%
   Iniread, Autostart%A_Index%, Master Script Settings.ini, Autostart, Script%A_Index%
   Iniread, Hotkey%A_Index%, Master Script Settings.ini, Hotkey, Script%A_Index%
   Iniread, Winkey%A_Index%, Master Script Settings.ini, Winkey, Script%A_Index%
   Iniread, Dir%A_Index%, Master Script Settings.ini, Directory, Script%A_Index% ; Added on behalf of Small_c0d3r
   File%A_Index% := Scriptname%A_Index%
}
Loop, %Filecount% ; Starts desired scripts on computer startup
{
   RunScriptName := Dir%A_index% "\" Scriptname%A_Index% ; To allow running of scripts in recursed folders (/Small_c0d3r)
   If (Autostart%A_Index% = 1)
   Run, %RunScriptName%
}
HotkeyCount = 0
Loop, %Filecount% ; Assigns desired hotkeys
{
   if (Hotkey%A_Index% = "")
      continue
   WK =
   if (Winkey%A_Index% = 1)
      WK = #
   HotkeyCount := (HotkeyCount + 1)
   Hotkeys := Hotkey%A_Index%
   Hotkey, %WK%%Hotkeys%, LaunchN%A_Index%
}
return
Launch:
MSS := Master Script Startup
StringTrimRight, FTL, Filetolaunch, 4 ; To remove the .ahk, for some reason I got "Unallowed variable" due to the dot (.)
If (FTL = MSS)
   MsgBox Error! Reload immediately!
Run, %FiletoLaunch%,,, PIDLaunched ; FiletoLaunch comes from the sub(s) below
Process, Wait, %PidLaunched%, 0.5
Process, Exist, %PidLaunched%
If (Errorlevel > 0){
   SoundPlay, *64
   SplashtextOn, 200, 50,, Launched %Filetolaunch%
   Sleep 2000
   SplashtextOff
}else{
   MsgBox Error
   }
return
; Alright, here we go again: The rest is basically the same!
LaunchN1:
FiletoLaunch = %File1%
Gosub, Launch
return
LaunchN2:
FiletoLaunch = %File2%
Gosub, Launch
return
LaunchN3:
FiletoLaunch = %File3%
Gosub, Launch
return
LaunchN4:
FiletoLaunch = %File4%
Gosub, Launch
return
LaunchN5:
FiletoLaunch = %File5%
Gosub, Launch
return
LaunchN6:
FiletoLaunch = %File6%
Gosub, Launch
return
LaunchN7:
FiletoLaunch = %File7%
Gosub, Launch
return
LaunchN8:
FiletoLaunch = %File8%
Gosub, Launch
return
LaunchN9:
FiletoLaunch = %File9%
Gosub, Launch
return
LaunchN10:
FiletoLaunch = %File10%
Gosub, Launch
return
LaunchN11:
FiletoLaunch = %File11%
Gosub, Launch
return
LaunchN12:
FiletoLaunch = %File12%
Gosub, Launch
return
LaunchN13:
FiletoLaunch = %File13%
Gosub, Launch
return
LaunchN14:
FiletoLaunch = %File14%
Gosub, Launch
return
LaunchN15:
FiletoLaunch = %File15%
Gosub, Launch
return
LaunchN16:
FiletoLaunch = %File16%
Gosub, Launch
return
LaunchN17:
FiletoLaunch = %File17%
Gosub, Launch
return
LaunchN18:
FiletoLaunch = %File18%
Gosub, Launch
return
LaunchN19:
FiletoLaunch = %File19%
Gosub, Launch
return
LaunchN20:
FiletoLaunch = %File20%
Gosub, Launch
return
LaunchN21:
FiletoLaunch = %File21%
Gosub, Launch
return
LaunchN22:
FiletoLaunch = %File22%
Gosub, Launch
return
LaunchN23:
FiletoLaunch = %File23%
Gosub, Launch
return
LaunchN24:
FiletoLaunch = %File24%
Gosub, Launch
return
LaunchN25:
FiletoLaunch = %File25%
Gosub, Launch
return
LaunchN26:
FiletoLaunch = %File26%
Gosub, Launch
return
LaunchN27:
FiletoLaunch = %File27%
Gosub, Launch
return
LaunchN28:
FiletoLaunch = %File28%
Gosub, Launch
return
LaunchN29:
FiletoLaunch = %File29%
Gosub, Launch
return
LaunchN30:
FiletoLaunch = %File30%
Gosub, Launch
return
LaunchN31:
FiletoLaunch = %File31%
Gosub, Launch
return
LaunchN32:
FiletoLaunch = %File32%
Gosub, Launch
return
LaunchN33:
FiletoLaunch = %File33%
Gosub, Launch
return
LaunchN34:
FiletoLaunch = %File34%
Gosub, Launch
return
LaunchN35:
FiletoLaunch = %File35%
Gosub, Launch
return
LaunchN36:
FiletoLaunch = %File36%
Gosub, Launch
return
LaunchN37:
FiletoLaunch = %File37%
Gosub, Launch
return
LaunchN38:
FiletoLaunch = %File38%
Gosub, Launch
return
LaunchN39:
FiletoLaunch = %File39%
Gosub, Launch
return
LaunchN40:
FiletoLaunch = %File40%
Gosub, Launch
return
LaunchN41:
FiletoLaunch = %File41%
Gosub, Launch
return
LaunchN42:
FiletoLaunch = %Fil42%
Gosub, Launch
return
LaunchN43:
FiletoLaunch = %File43%
Gosub, Launch
return


Link: http://www.autohotkey.net/~sumon/Master%20Script.rar

Important: The Script(s) must be placed in the folder that you want it to scan. I plan on eventually implementing a function to select additional parsing folders

Please comment, especially if you try it out. Any amount of feedback is appreciated.

Regards,
sumon

Known "bugs":

- The GUI can not be scrolled, so if you have more than ~18 scripts they won't all appear. If so, try out the "Deactivate", Save & Exit and repeat. (There used to be a reload button, but euhm, removed it).
- There's a limit to around 42 scripts maximum supported, although that is a secondary concern now - however it adds bulk to the code, that I do not want there. Any advice?
- Do NOT set "The Master Script Startup.ahk" to autostart, as that'll cause it to loop. I've been trying
Code:
If (%FiletoLaunch% = %MSS%){ ; You don't wanna selfstart the script, as that'd loop
MsgBox OMG ERROR!
}else{
Run, %FiletoLaunch% ; FiletoLaunch comes from the sub(s) below
}
to no avail.


AppStarter

For a more simple (read: user-friendly), all-programs alternative, I developed "AppStarter". This will let people start any file or program, and decide for themself which programs to include. It has a simple File-Select option, and lets your store and hotkey up to 9 applications (for now). This version is stable. If you want an .exe (includes icons and #includes), you can DOWNLOAD IT HERE.

Image

AppStarter.ahk
Code:
;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:         A.N.Other <myemail@nowhere.com>
;
; Script Function:
;   Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; ----
#Include IniLib.ahk
#SingleInstance, Force
#Persistent
IfExist, winpng.png
FileInstall, winpng.png, winpng.png
IfNotExist, AppStarterSettings.ini
   GoSub, CreateStandardIni
initializeini()
loadini() ; section_keyname
IfExist, AppStarterIcon.ico
Menu, Tray, Icon, AppStarterIcon.ico
Menu, Tray, Tip, AppStarter
Menu, Tray, NoStandard
Menu, Tray, Add, (*) Settings, Settings
Menu, Tray, Add, (?) Help, Help
Menu, Tray, Add, (X) Exit, ExitHotkey
OnExit, ExitHotkey
Gosub, Updatehotkeys
#Include SplashMe.ahk
return
Settings:
GuiCreate:
loadini()
Gui, Add, Text, x10, Application
IfExist, winpng.png
Gui, Add, Pic, x270 yp w16 h16, winpng.png
Gui, Add, Text, x310 yp, Hotkey
Loop, 9
{
   Check:=App_App%A_Index%
   IfNotExist, %Check%
      {
      Gui, Add, Button, gAddApp x10 vApp_App%A_Index%, [ Add app %A_Index% ]
       Continue
   }
   StringGetPos, Position, Check, \, R
   StringLen, Length, Check
   StringRight, Display, App_App%A_Index%, % (Length - Position - 1) ; Shortens the string for displaying
   Gui, Add, Button, gLaunchApp x10 vApp_App%A_Index%, %Display%
   WK:=Winkey_App%A_Index%
   Gui, Add, Checkbox, vWinkey_App%A_Index% yp x270 Checked%WK%
   HK:=Hotkey_App%A_Index%
   Gui, Add, Hotkey, vHotkey_App%A_Index% yp x310 w80, %HK%
}
Gui, Add, Button, gSubmit x150 yp+40, Save && close
Gui, Add, Button, gHelp x230 yp, ?
Gui, Add, Button, gGuiClose x250 yp, Close
Gui, Show, W400 H350, AppStarter Settings
Sleep 2000
SplashTextOff
return
AddApp:
StringRight, Display, A_GuiControl, 1
FileSelectFile, %A_GuiControl%, S, %A_ScriptDir%, Select the application you want to add as App #%Display%
if (Errorlevel = 1)
   return
saveini()
SplashOn("App was added")
SplashOff()
Gui, Destroy
Gosub, GuiCreate
return
Submit:
Gui, Submit
saveini()
SplashOn("Settings saved")
SplashOff()
Gui, Destroy
Gosub, UpdateHotkeys
return
UpdateHotkeys:
; Update Hotkeys:
Loop, 9
{
   Check:=App_App%A_Index%
   IfNotExist, %Check%
      {
       Continue
   }
   w =
   If (Winkey_App%A_Index% = 1)
      w = #
   HK:=Hotkey_App%A_index%
   Hotkey, ~%w%%HK%, LaunchApp%A_Index%, Off
   Hotkey, ~%w%%HK%, LaunchApp%A_Index%, On
}
return
GuiClose:
Gui, Destroy
Gosub, UpdateHotkeys
return
Help:
MsgBox Version: 0.9`nAuthor & (C): Simon Strålberg (simon.stralberg@gmail.com)`n`nAppStarter is intended to give an easy way to keybind and start your favorite applications. To add an application, simply press "Add application", navigate to the app, and select it. To add a hotkey, select the hotkey field, and press a hotkey (may include modifiers: shift/alt/ctrl). If you want to include the [Windows key], simply tick that box. REMEMBER: Do not add hotkeys that conflict with existing ones. The hotkeys will both work, eventually triggering two actions if you are not careful. Please select hotkeys with care. Recommended (and by default unused) hotkeys include [Win] combined with Q, W, A, Z, V, G, Y. `n`nIf you find this or any of my other software/apps useful, do not hesitate to send me an email at <simon.stralberg@gmail.com>.`n`nHave fun, and feel free to share this application with friends!
Return
CreateStandardINI:
FileAppend
, [App]`nApp1=`nApp2=`nApp3=`nApp4=`nApp5=`nApp6=`nApp7=`nApp8=`nApp9=`n[Hotkey]`nApp1=`nApp2=`nApp3=`nApp4=`nApp5=`nApp6=`nApp7=`nApp8=`nApp9=`n[Winkey]`nApp1=0`nApp2=0`nApp3=0`nApp4=0`nApp5=0`nApp6=0`nApp7=0`nApp8=0`nApp9=0
, AppStarterSettings.ini
return
LaunchApp:
; SoundPlay, *64
ToRun:=%A_GuiControl%
Run, %ToRun%
return
LaunchApp1:
Run, % App_App1
return
LaunchApp2:
Run, % App_App2
return
LaunchApp3:
Run, % App_App3
return
LaunchApp4:
Run, % App_App4
return
LaunchApp5:
Run, % App_App5
return
LaunchApp6:
Run, % App_App6
return
LaunchApp7:
Run, % App_App7
return
LaunchApp8:
Run, % App_App8
return
LaunchApp9:
Run, % App_App9
return
ExitHotkey:
; saveini()
ExitApp


NOTE: Requires IniLib.ahk & SplashMe.ahk

IniLib.ahk
Code:
; AUTHORSHIP for IniLib.ahk, see http://www.autohotkey.com/forum/topic21346.html (Note: It was called something else then, and is configured to work with AppStarter)

initializeini(inifile = "AppStarterSettings.ini"){
  global
  local key,temp
  inisections:=0
  loop,read,%inifile%
  {
    if regexmatch(A_Loopreadline,"\[(.*)?]")
      {
        inisections+= 1
        section%inisections%:=regexreplace(A_loopreadline,"(\[)(.*)?(])","$2")
        section%inisections%_keys:=0
      }
    else if regexmatch(A_LoopReadLine,"(\w+)=(.*)")
      {
        section%inisections%_keys+= 1
        key:=section%inisections%_keys
        section%inisections%_key%key%:=regexreplace(A_LoopReadLine,"(\w+)=(.*)","$1")
      }
  }
}

loadini(inifile = "AppStarterSettings.ini"){
  global
  local sec,var
  loop,%inisections%
    {
      sec:=A_index
      loop,% section%a_index%_keys
        {
          var:=section%sec% "_" section%sec%_key%A_index%,
          Stringreplace,var,var,%a_space%,,All
          iniread,%var%,%inifile%,% section%sec%,% section%sec%_key%A_index%
        }
    }
}

saveini(inifile = "AppStarterSettings.ini"){
  global
  local sec,var
   loop,%inisections%
    {
      sec:=A_index
      loop,% section%a_index%_keys
        {
          var:=section%sec% "_" section%sec%_key%A_index%
          Stringreplace,var,var,%a_space%,,All
          var:=%var%
          iniwrite,%var%,%inifile%,% section%sec%,% section%sec%_key%A_index%
        }
    }
}


SplashMe.ahk
Code:
;-- v1.0
; AUTHORSHIP: see http://www.autohotkey.com/forum/viewtopic.php?t=18040
;-- Important: Because this code includes a subroutine, you should
;   insert/include it AFTER the Auto-Execute section of a script.
;
;*******************
;*                 *
;*    Splash On    *
;*                 *
;*******************
;
;   Description
;   ===========
;   This function generates a borderless text Splash window and is used in
;   conjunction with the SplashOff, PreserveSplashWindow, and SplashOff_Timer
;   functions/subroutines.
;
;
;
;   Parameters
;   ==========
;
;       Name                    Description
;       ----                    -----------
;       p_MainText              Main text. [Optional]  The default is null.
;
;       p_SubText               Sub text. [Optional]  The default is null.
;
;       p_MinimumSplashTime     Minimum time (in seconds) the splash window is
;                               to be displayed. [Optional]  The default is
;                               0.85 seconds.
;
;                               If p_MinimumSplashTime contains a negative value
;                               (Ex: -3), this function will automatically call
;                               the SplashOff function using the absolute value
;                               value of this parameter as the minimum splash
;                               time.  This feature is useful when you know
;                               exactly how long you want the splash window to
;                               display.  It also removes the need for a
;                               separate call to the SplashOff function.
;
;       p_Font                  Font Name.  [Optional]  The default is null (the
;                               system default font is used).
;
;                               This font is used for both the MainText (top
;                               line(s)) and SubText (bottom line(s)).
;                               
;
;       p_Options               See the "Splash Options" section for more
;                               information.
;
;
;
;   Global Variables
;   ================
;
;       Name                    Description
;       ----                    -----------
;       $Splash_StartTime       This variable contains the time (A_TickCount)
;                               that the splash window was created.
;
;       $Splash_MinimumTime     This variable contains minimum time
;                               (developer-defined or default) that the splash
;                               window should be displayed.
;
;
;
;   Splash Options
;   ==============
;   The p_Options parameter is used to set any SplashImage options that are not
;   set by default.  If more than one option is defined, separate each option by
;   a space.  For example:
;
;       "CWBlack CTYellow"
;
;   For a complete list of SplashImage options, see the  AutoHotkey
;   documentation (keyword: SplashImage).
;
;
;   The following SplashImage options are automatically included by default:
;
;       Name                    Description
;       ----                    -----------
;       b2                      No title bar, dialog style border
;
;       W{Function determined}  Splash window width.  The size doesn't include
;                               border.
;
;
;   If not explicitly defined, the following SplashImage options/values are
;   included:
;
;       Name                    Description/Value
;       ----                    -----------------
;       FM10                    Font size for MainText - 10
;       FS12                    Font size for SubText - 12
;       WM600                   Font weight for MainText - 600 (Bold)
;       WS400                   Font weight for SubText - 400 (Normal)
;
;
;   In addition to the standard X/Y options, the following options are
;   available to position the Splash window on the screen:
;
;       Name                    Description/Value
;       ----                    -----------------
;       XL or XLeft             Left side of the screen.  Not necessarily the
;                               same as X0.
;
;       XM or XMiddle           Horizontally centered on the screen.  This is
;                               SplashImage default.
;
;       XR or XRight            Right side of the screen.
;
;       YT or YTop              Top of the screen.  Not necessarily the same as
;                               Y0.
;
;       YM or YMiddle           Vertically centered on the screen.  This is
;                               SplashImage default.
;
;       YB or YBottom           Bottom of the screen.
;
;
;   The preceding X/Y options are calculated based on the work area for the
;   primary monitor.  The work area excludes the taskbar and other registered
;   desktop toolbars.
;   
;
;
;   Calls To Other Functions
;   ========================
;   SplashOff
;
;
;
;   Calls To Subroutines
;   ====================
;   SplashOff_Timer
;
;
;
;   Programming Notes
;   =================
;   o   This function creates a temporary GUI window to ascertain the width of
;       the SplashImage window.  The function uses the first GUI window that is
;       available in the 71 to 99 range. If an available window cannot be found,
;       an error message is displayed.
;
;   o   So as not to interfere with any other SplashImage windows, an
;       arbitrarily selected SplashImage window number (8) is used.  Change if
;       needed.  See the AutoHotkey documentation (keyword: SplashImage) for
;       more information.
;
;
;-------------------------------------------------------------------------------
SplashOn(p_MainText=""
        ,p_SubText=""
        ,p_MinimumSplashTime=""
        ,p_Font=""
        ,p_Options="")
    {
    global $Splash_StartTime, $Splash_MinimumTime


    ;[==============]
    ;[  Initialize  ]
    ;[==============]
    l_DetectHiddenWindows:=A_DetectHiddenWindows
    DetectHiddenWindows On

    l_MainTextFontSize=10
    l_MainTextFontWeight=600
    l_SubTextFontSize=12
    l_SubTextFontWeight=400


    ;[==============]
    ;[  Parameters  ]
    ;[==============]
    ;-- p_MinimumSplashTime
    if p_MinimumSplashTime is not Number
        p_MinimumSplashTime=0


    ;-- p_Font
    p_Font=%p_Font%  ;-- AutoTrim


    ;[=======================]
    ;[  Extract font values  ]
    ;[  from p_Options       ]
    ;[=======================]
    loop parse,p_Options,%A_Space%
        {
        if A_LoopField is Space
            continue

        ;-- MainText options
        if instr(A_LoopField,"FM")=1
            if SubStr(A_LoopField,3) is Number
                StringTrimLeft l_MainTextFontSize,A_LoopField,2

        if instr(A_LoopField,"WM")=1
            if SubStr(A_LoopField,3) is Number
                StringTrimLeft l_MainTextFontWeight,A_LoopField,2


        ;-- SubText options
        if instr(A_LoopField,"FS")=1
            if SubStr(A_LoopField,3) is Number
                StringTrimLeft l_SubTextFontSize,A_LoopField,2

        if instr(A_LoopField,"WS")=1
            if SubStr(A_LoopField,3) is Number
                StringTrimLeft l_SubTextFontWeight,A_LoopField,2
        }


    ;[=============]
    ;[  p_Options  ]
    ;[=============]
    p_Options=%p_Options%  ;-- AutoTrim
    p_Options:="b2 " . p_Options

    ;-- If not explicitly defined, load font size just in case defaults don't
    ;   match system default
    ;
    if instr(p_Options," FM")=0
        p_Options:=p_Options . " FM" . l_MainTextFontSize

    if instr(p_Options," FS")=0
        p_Options:=p_Options . " FS" . l_SubTextFontSize


    ;-- Update/Simplify X/Y options
    StringReplace p_Options,p_Options,%A_Space%XLeft,%A_Space%XL,All
    StringReplace p_Options,p_Options,%A_Space%XMiddle,,All
    StringReplace p_Options,p_Options,%A_Space%XM,,All
    StringReplace p_Options,p_Options,%A_Space%XRight,%A_Space%XR,All
   
    StringReplace p_Options,p_Options,%A_Space%YTop,%A_Space%YT,All
    StringReplace p_Options,p_Options,%A_Space%YMiddle,,All
    StringReplace p_Options,p_Options,%A_Space%YM,,All
    StringReplace p_Options,p_Options,%A_Space%YBottom,%A_Space%YB,All


    ;[=====================]
    ;[  Preliminary stuff  ]
    ;[=====================]
    ;-- 1st run?
    if $Splash_MinimumTime is Space
        {
        $Splash_MinimumTime=850  ;-- Default in milliseconds.  Adjust if desired
        $Splash_StartTime=0
        }


    ;-- Turn off the SplashOff timer
    SetTimer SplashOff_Timer,off


    ;-- Minimum splash time defined?
    if p_MinimumSplashTime
        {
        $Splash_MinimumTime:=p_MinimumSplashTime*1000
        $Splash_StartTime=0
        }


    ;-- Reset start time?
    if not $Splash_StartTime
        $Splash_StartTime:=A_TickCount


    ;[=========================]
    ;[  Find available window  ]
    ;[   (Starting with 71)    ]
    ;[=========================]
    l_GUI=71
    loop
        {
        ;-- Window available?
        gui %l_GUI%:+LastFoundExist
        IfWinNotExist
            break

        ;-- Nothing available?
        if l_GUI=99
            {
            msgbox,262160,SplashOn Error,
               (ltrim
                Unable to create SplashOn temporary GUI.  %A_Space%
                GUI windows 71 to 99 are already in use.
               )

            return
            }

        ;-- Increment window
        l_GUI++
        }


    ;[==========================]
    ;[  Determine splash width  ]
    ;[==========================]
    ;-- Build temporary window to determine maximum width
    gui %l_GUI%:Margin,0,0
    gui %l_GUI%:Font,s%l_MainTextFontSize% w%l_MainTextFontWeight%,%p_Font%
    gui %l_GUI%:Add,Text,,%p_MainText%
    gui %l_GUI%:Font,s%l_SubTextFontSize% w%l_SubTextFontWeigth%
    gui %l_GUI%:Add,Text,,%p_SubText%
    gui %l_GUI%:Show,Hide  ;-- Render but don't show


    ;-- How wide is it?
    gui %l_GUI%:+LastFound
    WinGetPos ,,,l_SplashImageWidth,,% "ahk_id " . WinExist()
    gui %l_GUI%:Destroy


    ;-- Add some breathing room
    l_SplashImageWidth:=l_SplashImageWidth+60


    ;-- Too wide?
    l_MaxSplashImageWidth:=round(A_ScreenWidth*0.95)
    if (l_SplashImageWidth>l_MaxSplashImageWidth)
        l_SplashImageWidth:=l_MaxSplashImageWidth
   

    ;[==============]
    ;[  Splash it!  ]
    ;[==============]
    l_BreakLoop:=false
    loop 2
        {
        ;-- Create working copy of p_Options
        l_Options:=p_Options


        ;-- Function-specific X/Y options?
        if (instr(p_Options,A_Space . "XL")
        or  instr(p_Options,A_Space . "XR")
        or  instr(p_Options,A_Space . "YT")
        or  instr(p_Options,A_Space . "YB"))
            {
            StringReplace l_Options,l_Options,%A_Space%XL,,All
            StringReplace l_Options,l_Options,%A_Space%XR,,All
            StringReplace l_Options,l_Options,%A_Space%YT,,All
            StringReplace l_Options,l_Options,%A_Space%YB,,All
            l_Options:=l_Options . " Hide"
            }
         else
            l_BreakLoop:=true


        ;-- Splash using working copy of p_Options
        SplashImage 8:,W%l_SplashImageWidth% %l_Options%
            ,%p_SubText%
            ,%p_MainText%
            ,SplashOnWindow
            ,%p_Font%


        ;-- Are we done yet?
        if l_BreakLoop
            break


        ;-- Collect splash window width and height
        WinGetPos ,,,l_SplashWindowWidth,l_SplashWindowHeight,SplashOnWindow


        ;-- Collect work area dimensions for primary monitor
        SysGet l_MonitorWorkArea,MonitorWorkArea


        ;-- Update X/Y positions
        StringReplace p_Options
            ,p_Options
            ,%A_Space%XL
            ,% " X" . l_MonitorWorkAreaLeft
            ,All
       
        StringReplace p_Options
            ,p_Options
            ,%A_Space%XR
            ,% " X" . l_MonitorWorkAreaRight-l_SplashWindowWidth
            ,All
       
        StringReplace p_Options
            ,p_Options
            ,%A_Space%YT
            ,% " Y" . l_MonitorWorkAreaTop
            ,All

        StringReplace p_Options
            ,p_Options
            ,%A_Space%YB
            ,% " Y" . l_MonitorWorkAreaBottom-l_SplashWindowHeight
            ,All
        }


    ;-- Minor delay to give the window a chance to render
    sleep 1


    ;[===================]
    ;[  Auto SplashOff?  ]
    ;[===================]
    if $Splash_MinimumTime<0
        {
        $Splash_MinimumTime:=abs($Splash_MinimumTime)
        SplashOff()
        }


    ;[================]
    ;[  Housekeeping  ]
    ;[================]
    DetectHiddenWindows %l_DetectHiddenWindows%


    ;-- Return to sender
    return
    }



;********************
;*                  *
;*    Splash Off    *
;*                  *
;********************
;
;
;   Description
;   ===========
;   This function performs one of the following tasks:
;
;    1) If PreserveSplashWindow is TRUE (explicitly or by default), turn off
;       the SplashOff timer.  Do nothing else.
;
;    2) If the minimum splash time has elapsed, turn off (destroy) the splash
;       window created by the SplashOn function.
;
;    3) If the minimum splash time has NOT elapsed, set a timer to turn off
;       (destroy) the splash window created by the SplashOn function.
;
;
;
;   Parameters
;   ==========
;
;       Name                    Description
;       ----                    -----------
;       p_PreserveSplashWindow  Preserve Splash Window.  [Boolean, Optional]
;                               The default is FALSE or the value it was set to
;                               last.
;
;
;
;   Calls To Other Functions
;   ========================
;   PreserveSplashWindow
;
;
;
;   Calls To Subroutines
;   ====================
;   SplashOff_Timer
;
;
;-------------------------------------------------------------------------------
SplashOff(p_PreserveSplashWindow="")
    {
    global $Splash_MinimumTime, $Splash_StartTime


    ;-- Turn off SplashOff timer
    SetTimer SplashOff_Timer,off
   

    ;-- Preserve splash?
    if PreserveSplashWindow(p_PreserveSplashWindow)
        return

   
    ;-- Compute elapsed time.  Set timer if necessary
    l_SplashTimeElapsed:=A_TickCount-$Splash_StartTime
    if (l_SplashTimeElapsed<$Splash_MinimumTime)
        {
        l_SplashOffTimer:=$Splash_MinimumTime-l_SplashTimeElapsed
        SetTimer SplashOff_Timer,%l_SplashOffTimer%
        }
      else
         ;-- Destroy splash window
         SplashImage 8:Off
   

    ;-- Reset to defaults
    $Splash_MinimumTime=1350  ;-- Default in milliseconds.  Adjust if desired
    $Splash_StartTime=0
   

    ;-- Return to sender
    return
    }



;**************************
;*                        *
;*    Splash Off Timer    *
;*                        *
;**************************
SplashOff_Timer:
SetTimer SplashOff_Timer,Off
SplashImage 8:Off
return



;********************************
;*                              *
;*    Preserve Splash Window    *
;*                              *
;********************************
;
;
;   Description
;   ===========
;   This function sets and/or returns the current boolean value of
;   s_PreserveSplashWindow.
;
;   This function is called independently to set s_PreserveSplashWindow and is
;   used by the SplashOff function to determine if the splash window should be
;   preserved or not.
;
;
;
;   Parameters
;   ==========
;
;       Name                    Description
;       ----                    -----------
;       p_PreserveSplashWindow  Determines whether the splash window is
;                               preserved or not.  [Optional]  The default is
;                               FALSE or whatever it was set to last.
;
;                               Set to TRUE to preserve the splash window.  Set
;                               to FALSE to no longer preserve the splash
;                               window.
;
;
;   Calls To Other Functions
;   ========================
;   (None)
;
;
;-------------------------------------------------------------------------------
PreserveSplashWindow(p_PreserveSplashWindow="")
    {
    static s_PreserveSplashWindow

    ;-- Parameter?
    if p_PreserveSplashWindow is not Space
        s_PreserveSplashWindow:=p_PreserveSplashWindow


    ;-- Return to sender
    if s_PreserveSplashWindow
        return true
     else
        return false
    }


Last edited by sumon on November 14th, 2011, 4:18 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2010, 2:40 am 
how would one go about implementing a recursed folder scan of the script folder
curious as i have sorted my scripts into groups according to what they do or where i go them from


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2010, 4:16 am 
Offline

Joined: September 15th, 2009, 1:14 am
Posts: 562
Location: Tempe, Arizona
This looks good. I'll have to play with this soon now.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2010, 12:39 pm 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
Thanks Codybear.

Anonymous wrote:
how would one go about implementing a recursed folder scan of the script folder
curious as i have sorted my scripts into groups according to what they do or where i go them from


I'll come with an update soon, maybe today or tomorrow. Gotta add a "Preferences", where one can do stuff such as disable the autoload, and add additional "folders to scan". I think I could even implement Folder categories in the list, and a scrolling bar to support more scripts. Guest, it'd be better or worse if each folder of scripts was listed separately?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2010, 9:25 am 
Offline

Joined: November 29th, 2009, 7:53 am
Posts: 46
Location: Queensland
QUESTION: is there a way to make the script create multiple GUIs if there is too many scripts say;
Code:
Files:= %FileCount%
GuiMaxCount =  1
Loop
{
   If(Files > 15)
   {
      GuiMaxCount++
      Files -= 15
      Continue
   }
   Else
   {
      Break
   }
}
;create the Gui windows



Dear guest here is a working recursing version of the script
The master script edited;
Code:
; Script working name: Master Script
; Language:       English
; Platform:       Windows XP
; Version author: Sumon (find me at AHK forums, www.autohotkey.com/forum)
; Script Function: To be added: Searches "this" (%A_ScriptDir%) folder for scripts, and shows a GUI for enabling/disabling them, launching them, and adding hotkeys to launch them.
#singleinstance force
; Menu, Tray, Icon , msicon.ico, 1, 1 ---- OMG the icon was fugly
FileList =  ; Initialize to be blank.
Inactive_Dir=%A_ScriptDir%\Inactive Scripts

Loop, *.ahk,0,1
{
   If(A_LoopFileDir = "Inactive Scripts")
      Continue
   Else
   {
      FileList = %FileList%%A_LoopFileName%`n
      If(A_LoopFileDir ="")
         FileDir = %FileDir%%A_ScriptDir%`n
      Else
         FileDir = %FileDir%%A_ScriptDir%\%A_LoopFileDir%\`n

   }
}
loop, parse, FileList, `n
{
    if A_LoopField =  ; Ignore the blank item at the end of the list.
   {
   FileCount := A_Index-1 ; To also ignore the blank item in future Filecounts
   continue
   }
   File%A_Index% = %A_LoopField%
      
   /*
   MsgBox, 4,, File number %A_Index% is %A_LoopField%.  Continue?
    IfMsgBox, No
        break
      */
}
Loop, parse, FileDir, `n
{
    if A_LoopField =  ; Ignore the blank item at the end of the list.
   {
   FileCount := A_Index-1 ; To also ignore the blank item in future Filecounts
   continue
   }
   Dir%A_Index% = %A_LoopField%
      
   /*
   MsgBox, 4,, File number %A_Index% is %A_LoopField%.  Continue?
    IfMsgBox, No
        break
      */
}

IniWrite, %Filecount%, Master Script Settings.ini, Filecount, Filecount
IniRead, Filecount, Master Script Settings.ini, Filecount, Filecount, 0
Loop, %Filecount% ; Inireads all needed values
{
   Iniread, Scriptname%A_Index%, Master Script Settings.ini, Scriptname, Script%A_Index%
   Iniread, Autostart%A_Index%, Master Script Settings.ini, Autostart, Script%A_Index%
   Iniread, Hotkey%A_Index%, Master Script Settings.ini, Hotkey, Script%A_Index%
   Iniread, Winkey%A_Index%, Master Script Settings.ini, Winkey, Script%A_Index%
   IniRead, Deactivate%A_Index%, Master Script Settings.ini, Deactivate, Script%A_Index%
   IniRead, ScriptDir%A_Index%, Master Script Settings.ini, Directory, Script%A_Index%, %A_ScriptDir%
   ; File%A_Index% := Scriptname%A_Index% <--- Commented out since there was a conflict
}
CreateGUI:
Gui, Add, Text,, ... parsed your folder for %Filecount% files...
Gui, Add, Button, gSubmit, Save && Exit
; Gui, Add, Button, xp+95 yp gMasterstartup, Master Startup
Gui, Add, Button, xp+70 yp gReset, Reset
Gui, Add, Button, xp+55 yp w25 gHelp, ?
Gui, Add, Button, xp+35 yp gExit, Exit
Gui, Add, Text, y+15 xp-150, Run script   |   Autostart   |   Hotkey   |   +Win key?   |    Deactivate
Loop, %Filecount%
{
   FileText := File%A_Index%
   Gui, Add, GroupBox, xs0 w350, %FileText%
   GUI, Add, Button, xp+10 yp+20 h20 r1 gLaunchN%A_Index%, « »
   LaunchindexN = Launchindex%A_Index% ; ?
   n := Autostart%A_Index%
   Gui, Add, Checkbox, xp+70 yp+5 r1 vAutostartN%A_Index% checked%n%
   n := Hotkey%A_Index%
   Gui, Add, Hotkey, xp+50 yp-5 w70 vHotkeyN%A_Index%, %n%
   n := Winkey%A_Index%
   Gui, Add, Checkbox, xp+75 yp+5 r1 vWinkeyN%A_Index% checked%n%
   n:= Deactivate%A_Index%
   Gui, Add, Checkbox, xp+75 yp vDeactivateN%A_Index%   checked%n%
}
Gui, Show, Autosize
return
reset:
Gui, Destroy
Gosub, CreateGUI
return
Submit:
Gui, Submit, nohide
Loop, %FileCount%
{
   DirIni := Dir%A_Index%
   IniWrite, %DirIni%, Master Script Settings.ini, Directory, Script%A_Index%

   ScriptnameIni := File%A_Index%
   IniWrite, %ScriptnameIni%, Master Script Settings.ini, Scriptname, Script%A_Index%
   AutostartIni := AutostartN%A_Index%
   IniWrite, %AutostartINI%, Master Script Settings.ini, Autostart, Script%A_Index%
   HotkeyINI := HotkeyN%A_Index%
   IniWrite, %HotkeyINI%, Master Script Settings.ini, Hotkey, Script%A_Index%
   WinkeyINI := WinkeyN%A_Index%
   IniWrite, %WinkeyINI%, Master Script Settings.ini, Winkey, Script%A_Index%
   DeactivateINI := DeactivateN%A_Index% ; Yes, I know the this INI value won't be used, but can be good to have if someone wants to change the script
   IniWrite, %DeactivateIni%, Master Script Settings.ini, Deactivate, Script%A_Index%
   Filemovetext := File%A_Index%
   FileCreateDir, Inactive Scripts
   If (DeactivateN%A_Index% = 1)
   {
      MsgBox, 4, ,Do you want to move %FileMoveText% to %Inactive_Dir%
      IfMsgBox Yes
         FileMove, %Filemovetext%, %Inactive_Dir%
      Else
         Continue
   }
}
Gosub, Exit
return
Exit:
ExitApp
return
reload:
Reload
return
Masterstartup:
MsgBox FAIL
return
Help:
MsgBox Run script - Runs the chosen script `nAutostart - The chosen script will always start when you start your computer `nHotkey & Win key - Assign a hotkey to launch the selected script, if you want to combine it with the Left Windows key: Also tick the "Win key?" button `nDeactivate - Moves the designated script to a subfolder called "Inactive scripts", so it will not appear in this list
return
Launch:
SoundPlay, *64
Run, %FiletoLaunch%
return
; THE FOLLOWING "LaunchNX" subroutines are to accomodate for the different launchbuttons. I included a few extra just to be safe. Shoulda been some easier way to do it, but whattheheck.
LaunchN1:
FiletoLaunch = %File1%
Gosub, Launch
return
LaunchN2:
FiletoLaunch = %File2%
Gosub, Launch
return
LaunchN3:
FiletoLaunch = %File3%
Gosub, Launch
return
LaunchN4:
FiletoLaunch = %File4%
Gosub, Launch
return
LaunchN5:
FiletoLaunch = %File5%
Gosub, Launch
return
LaunchN6:
FiletoLaunch = %File6%
Gosub, Launch
return
LaunchN7:
FiletoLaunch = %File7%
Gosub, Launch
return
LaunchN8:
FiletoLaunch = %File8%
Gosub, Launch
return
LaunchN9:
FiletoLaunch = %File9%
Gosub, Launch
return
LaunchN10:
FiletoLaunch = %File10%
Gosub, Launch
return
LaunchN11:
FiletoLaunch = %File11%
Gosub, Launch
return
LaunchN12:
FiletoLaunch = %File12%
Gosub, Launch
return
LaunchN13:
FiletoLaunch = %File13%
Gosub, Launch
return
LaunchN14:
FiletoLaunch = %File14%
Gosub, Launch
return
LaunchN15:
FiletoLaunch = %File15%
Gosub, Launch
return
LaunchN16:
FiletoLaunch = %File16%
Gosub, Launch
return
LaunchN17:
FiletoLaunch = %File17%
Gosub, Launch
return
LaunchN18:
FiletoLaunch = %File18%
Gosub, Launch
return
LaunchN19:
FiletoLaunch = %File19%
Gosub, Launch
return
LaunchN20:
FiletoLaunch = %File20%
Gosub, Launch
return
LaunchN21:
FiletoLaunch = %File21%
Gosub, Launch
return
LaunchN22:
FiletoLaunch = %File22%
Gosub, Launch
return
LaunchN23:
FiletoLaunch = %File23%
Gosub, Launch
return
LaunchN24:
FiletoLaunch = %File24%
Gosub, Launch
return
LaunchN25:
FiletoLaunch = %File25%
Gosub, Launch
return
LaunchN26:
FiletoLaunch = %File26%
Gosub, Launch
return
LaunchN27:
FiletoLaunch = %File27%
Gosub, Launch
return
LaunchN28:
FiletoLaunch = %File28%
Gosub, Launch
return
LaunchN29:
FiletoLaunch = %File29%
Gosub, Launch
return
LaunchN30:
FiletoLaunch = %File30%
Gosub, Launch
return
LaunchN31:
FiletoLaunch = %File31%
Gosub, Launch
return
LaunchN32:
FiletoLaunch = %File32%
Gosub, Launch
return
LaunchN33:
FiletoLaunch = %File33%
Gosub, Launch
return
LaunchN34:
FiletoLaunch = %File34%
Gosub, Launch
return
LaunchN35:
FiletoLaunch = %File35%
Gosub, Launch
return
LaunchN36:
FiletoLaunch = %File36%
Gosub, Launch
return
LaunchN37:
FiletoLaunch = %File37%
Gosub, Launch
return
LaunchN38:
FiletoLaunch = %File38%
Gosub, Launch
return
LaunchN39:
FiletoLaunch = %File39%
Gosub, Launch
return
LaunchN40:
FiletoLaunch = %File40%
Gosub, Launch
return
LaunchN41:
FiletoLaunch = %File41%
Gosub, Launch
return
LaunchN42:
FiletoLaunch = %Fil42%
Gosub, Launch
return
LaunchN43:
FiletoLaunch = %File43%
Gosub, Launch
return

and the edited startup script;
Code:
; Script working name: Master Script Startup
; Goes hand in hand with: Master Script.ahk, and Master Script Settings.ini
; Language:       English
; Platform:       Windows 7
; Version author: Sumon (find me at AHK forums, www.autohotkey.com/forum)
; Script Function: Autostarts itself (if commanded to) and other scripts you wish to autostart. Also keeps hotkeys available for desired scripts.
#singleinstance force
#NoEnv
#NoTrayIcon
SetBatchLines,-1


IfNotExist %A_Startup%\Master Script Startup Recursing.lnk ; Adds Master Script Startup to Autostart
FileCreateShortcut , %A_ScriptDir%\Master Script Startup Recursing.ahk, %A_Startup%\Master Script Startup Recursing.lnk ; Moved to allow constant startup rather than if commanded to


IniRead, Filecount, Master Script Settings.ini, Filecount, Filecount, 0
Loop, %Filecount% ; Inireads all needed values
{
   Iniread, Scriptname%A_Index%, Master Script Settings.ini, Scriptname, Script%A_Index%
   Iniread, Autostart%A_Index%, Master Script Settings.ini, Autostart, Script%A_Index%
   Iniread, Hotkey%A_Index%, Master Script Settings.ini, Hotkey, Script%A_Index%
   Iniread, Winkey%A_Index%, Master Script Settings.ini, Winkey, Script%A_Index%
   Iniread, Dir%A_Index%, Master Script Settings.ini, Directory, Script%A_Index%
   File%A_Index% := Scriptname%A_Index%
}
Loop, %Filecount% ; Starts desired scripts
{
   RunScriptName := Dir%A_Index% "\" Scriptname%A_Index% ; allow running of the scripts in the recursed folders
   If (Autostart%A_Index% = 1)
   Run, %RunScriptName%
}
HotkeyCount = 0
Loop, %Filecount% ; Assigns desired hotkeys
{
   if (Hotkey%A_Index% = "")
      continue
   WK =
   if (Winkey%A_Index% = 1)
      WK = #
   HotkeyCount := (HotkeyCount + 1)
   Hotkeys := Hotkey%A_Index%
   Hotkey, %WK%%Hotkeys%, LaunchN%A_Index%
}
return


Launch:
SoundPlay, *64
Run, %FiletoLaunch% ; FiletoLaunch comes from the sub(s) below
return

; Alright, here we go again: The rest is basically the same!
LaunchN1:
FiletoLaunch = %File1%
Gosub, Launch
return
LaunchN2:
FiletoLaunch = %File2%
Gosub, Launch
return
LaunchN3:
FiletoLaunch = %File3%
Gosub, Launch
return
LaunchN4:
FiletoLaunch = %File4%
Gosub, Launch
return
LaunchN5:
FiletoLaunch = %File5%
Gosub, Launch
return
LaunchN6:
FiletoLaunch = %File6%
Gosub, Launch
return
LaunchN7:
FiletoLaunch = %File7%
Gosub, Launch
return
LaunchN8:
FiletoLaunch = %File8%
Gosub, Launch
return
LaunchN9:
FiletoLaunch = %File9%
Gosub, Launch
return
LaunchN10:
FiletoLaunch = %File10%
Gosub, Launch
return
LaunchN11:
FiletoLaunch = %File11%
Gosub, Launch
return
LaunchN12:
FiletoLaunch = %File12%
Gosub, Launch
return
LaunchN13:
FiletoLaunch = %File13%
Gosub, Launch
return
LaunchN14:
FiletoLaunch = %File14%
Gosub, Launch
return
LaunchN15:
FiletoLaunch = %File15%
Gosub, Launch
return
LaunchN16:
FiletoLaunch = %File16%
Gosub, Launch
return
LaunchN17:
FiletoLaunch = %File17%
Gosub, Launch
return
LaunchN18:
FiletoLaunch = %File18%
Gosub, Launch
return
LaunchN19:
FiletoLaunch = %File19%
Gosub, Launch
return
LaunchN20:
FiletoLaunch = %File20%
Gosub, Launch
return
LaunchN21:
FiletoLaunch = %File21%
Gosub, Launch
return
LaunchN22:
FiletoLaunch = %File22%
Gosub, Launch
return
LaunchN23:
FiletoLaunch = %File23%
Gosub, Launch
return
LaunchN24:
FiletoLaunch = %File24%
Gosub, Launch
return
LaunchN25:
FiletoLaunch = %File25%
Gosub, Launch
return
LaunchN26:
FiletoLaunch = %File26%
Gosub, Launch
return
LaunchN27:
FiletoLaunch = %File27%
Gosub, Launch
return
LaunchN28:
FiletoLaunch = %File28%
Gosub, Launch
return
LaunchN29:
FiletoLaunch = %File29%
Gosub, Launch
return
LaunchN30:
FiletoLaunch = %File30%
Gosub, Launch
return
LaunchN31:
FiletoLaunch = %File31%
Gosub, Launch
return
LaunchN32:
FiletoLaunch = %File32%
Gosub, Launch
return
LaunchN33:
FiletoLaunch = %File33%
Gosub, Launch
return
LaunchN34:
FiletoLaunch = %File34%
Gosub, Launch
return
LaunchN35:
FiletoLaunch = %File35%
Gosub, Launch
return
LaunchN36:
FiletoLaunch = %File36%
Gosub, Launch
return
LaunchN37:
FiletoLaunch = %File37%
Gosub, Launch
return
LaunchN38:
FiletoLaunch = %File38%
Gosub, Launch
return
LaunchN39:
FiletoLaunch = %File39%
Gosub, Launch
return
LaunchN40:
FiletoLaunch = %File40%
Gosub, Launch
return
LaunchN41:
FiletoLaunch = %File41%
Gosub, Launch
return
LaunchN42:
FiletoLaunch = %Fil42%
Gosub, Launch
return
LaunchN43:
FiletoLaunch = %File43%
Gosub, Launch
return


Last edited by small_c0d3r on November 24th, 2010, 9:44 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2010, 9:28 am 
Offline

Joined: November 29th, 2009, 7:53 am
Posts: 46
Location: Queensland
and your script has come in very handy as it has declutered my startup folder


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2010, 12:14 pm 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
Thanks for the edits Small_C0d3r, and for showing the edits in red text. I'm gonna start working on improving the script. The recursing function (it searches in subfolders...) is so easy and so good. Think I'll add "Search folders..." too, though.

I think the easier way would probably be to compress the standard GUI in size (but without destroying the nice looks of it) and/or add a scrollbar, tabs, or a "Next button". Maybe categories, but that'd be too difficult for me I think.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2010, 1:53 am 
Offline

Joined: November 29th, 2009, 7:53 am
Posts: 46
Location: Queensland
i did a bit of testing and found a way to make multiple windows but it still needs a bit of work;
Code:
CreateGUI:
;the first peice doesn't have to reside in this area but it is added here for easier editing as it is part of the gui creation process
Files:= FileCount
GuiMaxCount =  1
Loop   ;dicovering how many gui windows are required to show the whole file list
{
   If(Files > 15)   ;15 choosen as the limit of programs per gui
   {
      GuiMaxCount++
      Files -= 15
      Continue
   }
   Else   ;if there is less than 15 files no extra guis required
   {
      Break
   }
}
window = 0   ;set to blank to allow for incrimental counting
Loop,%GuiMaxCount%   ;loop though the creation once for each gui
{
   window ++   ;add 1 to window to keeptrack of what gui window we are editing
   If (window > GuiMaxCount)   ; if script tries to make uneeded windows this if will prevent it
      Break
   Else   ;create the gui
   {
      Low_Lim:= 15*(window-1)+1   ;calculating for the text of the gui
      if(window = GuiMaxCount)   ;deciphering wether the gui is a full gui or a partial one and calculating the appropriate High_Lim
         High_Lim:= FileCount
      Else
         High_Lim:= 15*window
      ;add the controls of the current gui
      Gui, %window%: Add, Text,, ... %FileCount% files found showing results %Low_Lim% to %High_Lim%   ; text to show the user what files of the filecount are showed on the gui
      Gui, %window%: Add, Button, gSubmit, Save && Exit
      Gui, %window%: Add, Button, xp+70 yp gReset, Reset
      Gui, %window%: Add, Button, xp+55 yp w25 gHelp, ?
      Gui, %window%: Add, Button, xp+35 yp gExit, Exit
      Gui, %window%: Add, Text, y+15 xp-150, Run script   |   Autostart   |   Hotkey   |   +Win key?   |    Deactivate
      Loop, 15   ;add the controls for each program shown in the gui
      {
         instance :=(15*(window - 1)) + A_Index   ;becuase of multiple windows a_Index is unable to be used thus current program has to be calculated
         ;MsgBox, %instance%
         If(instance > FileCount)   ;since it repeats 15 times must ensure that only the amount of files is added not any extras usually blanks
            Break
         Else   ;same process as in orignial script except %instance% used instead of %A_Index%
         {
            FileText := File%instance%
            Gui, %window%: Add, GroupBox, xs0 w350, %FileText%
            Gui, %window%: Add, Button, xp+10 yp+20 h20 r1 gLaunchN%instance%, « »
            LaunchindexN = Launchindex%instance% ; ?
            n := Autostart%instance%
            Gui, %window%: Add, Checkbox, xp+70 yp+5 r1 vAutostartN%instance% checked%n%
            n := Hotkey%instance%
            Gui, %window%: Add, Hotkey, xp+50 yp-5 w70 vHotkeyN%instance%, %n%
            n := Winkey%instance%
            Gui, %window%: Add, Checkbox, xp+75 yp+5 r1 vWinkeyN%instance% checked%n%
            n:= Deactivate%instance%
            Gui, %window%: Add, Checkbox, xp+75 yp vDeactivateN%instance%   checked%n%
         }
      }
      Gui, %window%:Show, Autosize, Master Script settings (window %window% of %GuiMaxCount%)   ;title showing which window of the series it is
      ; if only wanted one window to show at a time extra button would be required to go next and return would have to be placed herewith the button g-label would contain the  Continue command
   }
}
return
reset:
Gui, Destroy
Gosub, CreateGUI
return
Submit:
Gui, Submit, nohide
Loop, %FileCount%
{
   DirIni := Dir%A_Index%
   IniWrite, %DirIni%, Master Script Settings.ini, Directory, Script%A_Index%
   ScriptnameIni := File%A_Index%
   IniWrite, %ScriptnameIni%, Master Script Settings.ini, Scriptname, Script%A_Index%
   AutostartIni := AutostartN%A_Index%
   IniWrite, %AutostartINI%, Master Script Settings.ini, Autostart, Script%A_Index%
   HotkeyINI := HotkeyN%A_Index%
   IniWrite, %HotkeyINI%, Master Script Settings.ini, Hotkey, Script%A_Index%
   WinkeyINI := WinkeyN%A_Index%
   IniWrite, %WinkeyINI%, Master Script Settings.ini, Winkey, Script%A_Index%
   DeactivateINI := DeactivateN%A_Index% ; Yes, I know the this INI value won't be used, but can be good to have if someone wants to change the script
   IniWrite, %DeactivateIni%, Master Script Settings.ini, Deactivate, Script%A_Index%
   Filemovetext := File%A_Index%
   FileCreateDir, Inactive Scripts
   If (DeactivateN%A_Index% = 1)
   {
      MsgBox, 4, ,Do you want to move %FileMoveText% to %Inactive_Dir%
      IfMsgBox Yes
         FileMove, %Filemovetext%, %Inactive_Dir%
      Else
         Continue
   }
}
Gosub, Exit
return
Exit:
ExitApp
return
reload:
Reload
return
Masterstartup:
MsgBox FAIL
return
Help:
MsgBox Run script - Runs the chosen script `nAutostart - The chosen script will always start when you start your computer `nHotkey & Win key - Assign a hotkey to launch the selected script, if you want to combine it with the Left Windows key: Also tick the "Win key?" button `nDeactivate - Moves the designated script to a subfolder called "Inactive scripts", so it will not appear in this list
return
Launch:
SoundPlay, *64
Run, %FiletoLaunch%
return
; THE FOLLOWING "LaunchNX" subroutines are to accomodate for the different launchbuttons. I included a few extra just to be safe. Shoulda been some easier way to do it, but whattheheck. (Now supports 60 different scripts)
LaunchN1:
FiletoLaunch = %File1%
Gosub, Launch
return
LaunchN2:
FiletoLaunch = %File2%
Gosub, Launch
return
LaunchN3:
FiletoLaunch = %File3%
Gosub, Launch
return
LaunchN4:
FiletoLaunch = %File4%
Gosub, Launch
return
LaunchN5:
FiletoLaunch = %File5%
Gosub, Launch
return
LaunchN6:
FiletoLaunch = %File6%
Gosub, Launch
return
LaunchN7:
FiletoLaunch = %File7%
Gosub, Launch
return
LaunchN8:
FiletoLaunch = %File8%
Gosub, Launch
return
LaunchN9:
FiletoLaunch = %File9%
Gosub, Launch
return
LaunchN10:
FiletoLaunch = %File10%
Gosub, Launch
return
LaunchN11:
FiletoLaunch = %File11%
Gosub, Launch
return
LaunchN12:
FiletoLaunch = %File12%
Gosub, Launch
return
LaunchN13:
FiletoLaunch = %File13%
Gosub, Launch
return
LaunchN14:
FiletoLaunch = %File14%
Gosub, Launch
return
LaunchN15:
FiletoLaunch = %File15%
Gosub, Launch
return
LaunchN16:
FiletoLaunch = %File16%
Gosub, Launch
return
LaunchN17:
FiletoLaunch = %File17%
Gosub, Launch
return
LaunchN18:
FiletoLaunch = %File18%
Gosub, Launch
return
LaunchN19:
FiletoLaunch = %File19%
Gosub, Launch
return
LaunchN20:
FiletoLaunch = %File20%
Gosub, Launch
return
LaunchN21:
FiletoLaunch = %File21%
Gosub, Launch
return
LaunchN22:
FiletoLaunch = %File22%
Gosub, Launch
return
LaunchN23:
FiletoLaunch = %File23%
Gosub, Launch
return
LaunchN24:
FiletoLaunch = %File24%
Gosub, Launch
return
LaunchN25:
FiletoLaunch = %File25%
Gosub, Launch
return
LaunchN26:
FiletoLaunch = %File26%
Gosub, Launch
return
LaunchN27:
FiletoLaunch = %File27%
Gosub, Launch
return
LaunchN28:
FiletoLaunch = %File28%
Gosub, Launch
return
LaunchN29:
FiletoLaunch = %File29%
Gosub, Launch
return
LaunchN30:
FiletoLaunch = %File30%
Gosub, Launch
return
LaunchN31:
FiletoLaunch = %File31%
Gosub, Launch
return
LaunchN32:
FiletoLaunch = %File32%
Gosub, Launch
return
LaunchN33:
FiletoLaunch = %File33%
Gosub, Launch
return
LaunchN34:
FiletoLaunch = %File34%
Gosub, Launch
return
LaunchN35:
FiletoLaunch = %File35%
Gosub, Launch
return
LaunchN36:
FiletoLaunch = %File36%
Gosub, Launch
return
LaunchN37:
FiletoLaunch = %File37%
Gosub, Launch
return
LaunchN38:
FiletoLaunch = %File38%
Gosub, Launch
return
LaunchN39:
FiletoLaunch = %File39%
Gosub, Launch
return
LaunchN40:
FiletoLaunch = %File40%
Gosub, Launch
return
LaunchN41:
FiletoLaunch = %File41%
Gosub, Launch
return
LaunchN42:
FiletoLaunch = %File42%
Gosub, Launch
return
LaunchN43:
FiletoLaunch = %File43%
Gosub, Launch
return
LaunchN44:
FiletoLaunch = %File44%
Gosub, Launch
return
LaunchN45:
FiletoLaunch = %File45%
Gosub, Launch
return
LaunchN46:
FiletoLaunch = %File46%
Gosub, Launch
return
LaunchN47:
FiletoLaunch = %File47%
Gosub, Launch
return
LaunchN48:
FiletoLaunch = %File48%
Gosub, Launch
return
LaunchN49:
FiletoLaunch = %File49%
Gosub, Launch
return
LaunchN50:
FiletoLaunch = %File50%
Gosub, Launch
return
LaunchN51:
FiletoLaunch = %File51%
Gosub, Launch
return
LaunchN52:
FiletoLaunch = %File52%
Gosub, Launch
return
LaunchN53:
FiletoLaunch = %File53%
Gosub, Launch
return
LaunchN54:
FiletoLaunch = %File54%
Gosub, Launch
return
LaunchN55:
FiletoLaunch = %File55%
Gosub, Launch
return
LaunchN56:
FiletoLaunch = %File56%
Gosub, Launch
return
LaunchN57:
FiletoLaunch = %File57%
Gosub, Launch
return
LaunchN58:
FiletoLaunch = %File58%
Gosub, Launch
return
LaunchN59:
FiletoLaunch = %File59%
Gosub, Launch
return
LaunchN60:
FiletoLaunch = %File60%
Gosub, Launch
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2010, 2:29 am 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
Great. I'll look at it tomorrow. I've been implementing a few things myself too, and improved a few things.

Any thoughts on how to make a smoother system so I won't have to manually add X subroutines at the bottom of the script (due to every reference to a subrouting requiring the subroutine to exist).

Another problem found too: The scripts are "saved" too much ackording to position rather than name, so that if a script is added, it might get the hotkeys of another script. Gotta test that out and fix it.


Last edited by sumon on November 26th, 2010, 12:03 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2010, 8:06 am 
Offline

Joined: November 29th, 2009, 7:53 am
Posts: 46
Location: Queensland
update on the multi gui section;
Code:
CreateGUI_Stage1:
;the first peice doesn't have to reside in this area but it is added here for easier editing as it is part of the gui creation process
Files:= FileCount
GuiMaxCount =  1
Loop   ;dicovering how many gui windows are required to show the whole file list
{
   If(Files > 15)   ;15 choosen as the limit of programs per gui
   {
      GuiMaxCount++
      Files -= 15
      Continue
   }
   Else   ;if there is less than 15 files no extra guis required
   {
      Break
   }
}
window = 0   ;set to blank to allow for incrimental counting
CreateGUI_Stage2:
window ++   ;add 1 to window to keeptrack of what gui window we are editing
If (window > GuiMaxCount)   ; if script tries to make uneeded windows this if will prevent it
   Gosub,Exit
Else   ;create the gui
{
   Low_Lim:= 15*(window-1)+1   ;calculating for the text of the gui
   if(window = GuiMaxCount)   ;deciphering wether the gui is a full gui or a partial one and calculating the appropriate High_Lim
      High_Lim:= FileCount
   Else
      High_Lim:= 15*window
   ;add the controls of the current gui
   Gui, %window%:Default
   Gui, %window%: Add, Text,, ... %FileCount% files found showing results %Low_Lim% to %High_Lim%   ; text to show the user what files of the filecount are showed on the gui
   Gui, %window%: Add, Button, gSubmit, Save && Exit
   Gui, %window%: Add, Button, xp+70 yp gReset, Reset
   Gui, %window%: Add, Button, xp+55 yp w25 gHelp, ?
   Gui, %window%: Add, Button, xp+35 yp gExit, Exit
   Gui, %window%: Add, Text, y+15 xp-150, Run script   |   Autostart   |   Hotkey   |   +Win key?   |    Deactivate
   Loop, 15   ;add the controls for each program shown in the gui
   {
      instance :=(15*(window - 1)) + A_Index   ;becuase of multiple windows a_Index is unable to be used thus current program has to be calculated
      ;MsgBox, %instance%
      If(instance > FileCount)   ;since it repeats 15 times must ensure that only the amount of files is added not any extras usually blanks
         Break
      Else   ;same process as in orignial script except %instance% used instead of %A_Index%
      {
         FileText := File%instance%
         Gui, %window%: Add, GroupBox, xs0 w350, %FileText%
         Gui, %window%: Add, Button, xp+10 yp+20 h20 r1 gLaunchN%instance%, « »
         LaunchindexN = Launchindex%instance% ; ?
         n := Autostart%instance%
         Gui, %window%: Add, Checkbox, xp+70 yp+5 r1 vAutostartN%instance% checked%n%
         n := Hotkey%instance%
         Gui, %window%: Add, Hotkey, xp+50 yp-5 w70 vHotkeyN%instance%, %n%
         n := Winkey%instance%
         Gui, %window%: Add, Checkbox, xp+75 yp+5 r1 vWinkeyN%instance% checked%n%
         n:= Deactivate%instance%
         Gui, %window%: Add, Checkbox, xp+75 yp vDeactivateN%instance%   checked%n%
      }
   }
   Gui, %window%:Show, Autosize, Master Script settings (window %window% of %GuiMaxCount%)   ;title showing which window of the series it is
   Return
}

return
reset:
Run,%A_ScriptFullPath%
return
Submit:
Gui,Submit
Loop, 15
{
   instance :=(15*(window - 1)) + A_Index
   If(instance > FileCount)   ;since it repeats 15 times must ensure that only the amount of files is added not any extras usually blanks
      Break
   Else   ;same process as in orignial script except %instance% used instead of %A_Index%
   {
      DirIni := Dir%instance%
      IniWrite, %DirIni%, Master Script Settings.ini, Directory, Script%instance%
      ScriptnameIni := File%instance%
      IniWrite, %ScriptnameIni%, Master Script Settings.ini, Scriptname, Script%instance%
      AutostartIni := AutostartN%instance%
      IniWrite, %AutostartINI%, Master Script Settings.ini, Autostart, Script%instance%
      HotkeyINI := HotkeyN%instance%
      IniWrite, %HotkeyINI%, Master Script Settings.ini, Hotkey, Script%instance%
      WinkeyINI := WinkeyN%instance%
      IniWrite, %WinkeyINI%, Master Script Settings.ini, Winkey, Script%instance%
      DeactivateINI := DeactivateN%instance% ; Yes, I know the this INI value won't be used, but can be good to have if someone wants to change the script
      IniWrite, %DeactivateIni%, Master Script Settings.ini, Deactivate, Script%instance%
      Filemovetext := File%instance%
      FileCreateDir, Inactive Scripts
      If (DeactivateN%instance% = 1)
      {   
         MsgBox, 4, ,Do you want to move %FileMoveText% to %Inactive_Dir%
         IfMsgBox Yes
            FileMove, %Filemovetext%, %Inactive_Dir%
         Else
            Continue
      }
   }
}
Gui,Destroy
Goto,CreateGUI_Stage2
return
Exit:
ExitApp
return
reload:
Reload
return
Masterstartup:
MsgBox FAIL
return
Help:
MsgBox Run script - Runs the chosen script `nAutostart - The chosen script will always start when you start your computer `nHotkey & Win key - Assign a hotkey to launch the selected script, if you want to combine it with the Left Windows key: Also tick the "Win key?" button `nDeactivate - Moves the designated script to a subfolder called "Inactive scripts", so it will not appear in this list
return
Launch:
SoundPlay, *64
Run, %FiletoLaunch%
return
; THE FOLLOWING "LaunchNX" subroutines are to accomodate for the different launchbuttons. I included a few extra just to be safe. Shoulda been some easier way to do it, but whattheheck. (Now supports 60 different scripts)
LaunchN1:
FiletoLaunch = %File1%
Gosub, Launch
return
LaunchN2:
FiletoLaunch = %File2%
Gosub, Launch
return
LaunchN3:
FiletoLaunch = %File3%
Gosub, Launch
return
LaunchN4:
FiletoLaunch = %File4%
Gosub, Launch
return
LaunchN5:
FiletoLaunch = %File5%
Gosub, Launch
return
LaunchN6:
FiletoLaunch = %File6%
Gosub, Launch
return
LaunchN7:
FiletoLaunch = %File7%
Gosub, Launch
return
LaunchN8:
FiletoLaunch = %File8%
Gosub, Launch
return
LaunchN9:
FiletoLaunch = %File9%
Gosub, Launch
return
LaunchN10:
FiletoLaunch = %File10%
Gosub, Launch
return
LaunchN11:
FiletoLaunch = %File11%
Gosub, Launch
return
LaunchN12:
FiletoLaunch = %File12%
Gosub, Launch
return
LaunchN13:
FiletoLaunch = %File13%
Gosub, Launch
return
LaunchN14:
FiletoLaunch = %File14%
Gosub, Launch
return
LaunchN15:
FiletoLaunch = %File15%
Gosub, Launch
return
LaunchN16:
FiletoLaunch = %File16%
Gosub, Launch
return
LaunchN17:
FiletoLaunch = %File17%
Gosub, Launch
return
LaunchN18:
FiletoLaunch = %File18%
Gosub, Launch
return
LaunchN19:
FiletoLaunch = %File19%
Gosub, Launch
return
LaunchN20:
FiletoLaunch = %File20%
Gosub, Launch
return
LaunchN21:
FiletoLaunch = %File21%
Gosub, Launch
return
LaunchN22:
FiletoLaunch = %File22%
Gosub, Launch
return
LaunchN23:
FiletoLaunch = %File23%
Gosub, Launch
return
LaunchN24:
FiletoLaunch = %File24%
Gosub, Launch
return
LaunchN25:
FiletoLaunch = %File25%
Gosub, Launch
return
LaunchN26:
FiletoLaunch = %File26%
Gosub, Launch
return
LaunchN27:
FiletoLaunch = %File27%
Gosub, Launch
return
LaunchN28:
FiletoLaunch = %File28%
Gosub, Launch
return
LaunchN29:
FiletoLaunch = %File29%
Gosub, Launch
return
LaunchN30:
FiletoLaunch = %File30%
Gosub, Launch
return
LaunchN31:
FiletoLaunch = %File31%
Gosub, Launch
return
LaunchN32:
FiletoLaunch = %File32%
Gosub, Launch
return
LaunchN33:
FiletoLaunch = %File33%
Gosub, Launch
return
LaunchN34:
FiletoLaunch = %File34%
Gosub, Launch
return
LaunchN35:
FiletoLaunch = %File35%
Gosub, Launch
return
LaunchN36:
FiletoLaunch = %File36%
Gosub, Launch
return
LaunchN37:
FiletoLaunch = %File37%
Gosub, Launch
return
LaunchN38:
FiletoLaunch = %File38%
Gosub, Launch
return
LaunchN39:
FiletoLaunch = %File39%
Gosub, Launch
return
LaunchN40:
FiletoLaunch = %File40%
Gosub, Launch
return
LaunchN41:
FiletoLaunch = %File41%
Gosub, Launch
return
LaunchN42:
FiletoLaunch = %File42%
Gosub, Launch
return
LaunchN43:
FiletoLaunch = %File43%
Gosub, Launch
return
LaunchN44:
FiletoLaunch = %File44%
Gosub, Launch
return
LaunchN45:
FiletoLaunch = %File45%
Gosub, Launch
return
LaunchN46:
FiletoLaunch = %File46%
Gosub, Launch
return
LaunchN47:
FiletoLaunch = %File47%
Gosub, Launch
return
LaunchN48:
FiletoLaunch = %File48%
Gosub, Launch
return
LaunchN49:
FiletoLaunch = %File49%
Gosub, Launch
return
LaunchN50:
FiletoLaunch = %File50%
Gosub, Launch
return
LaunchN51:
FiletoLaunch = %File51%
Gosub, Launch
return
LaunchN52:
FiletoLaunch = %File52%
Gosub, Launch
return
LaunchN53:
FiletoLaunch = %File53%
Gosub, Launch
return
LaunchN54:
FiletoLaunch = %File54%
Gosub, Launch
return
LaunchN55:
FiletoLaunch = %File55%
Gosub, Launch
return
LaunchN56:
FiletoLaunch = %File56%
Gosub, Launch
return
LaunchN57:
FiletoLaunch = %File57%
Gosub, Launch
return
LaunchN58:
FiletoLaunch = %File58%
Gosub, Launch
return
LaunchN59:
FiletoLaunch = %File59%
Gosub, Launch
return
LaunchN60:
FiletoLaunch = %File60%
Gosub, Launch
return

and as 4 ur question on the X subroutines i haven't found a solution yet but i can work on it as i have plenty of spare time for testing
Edit(26/11/2010): the script with the new subroutine to replace the x subroutines required;
Code:
; Script working name: Master Script
; Language:       English
; Platform:       Windows XP
; Version author: Sumon (find me at AHK forums, www.autohotkey.com/forum)
; Script Function: To be added: Searches "this" (%A_ScriptDir%) folder for scripts, and shows a GUI for enabling/disabling them, launching them, and adding hotkeys to launch them.
#singleinstance force
; Menu, Tray, Icon , msicon.ico, 1, 1 ---- OMG the icon was fugly
FileList =  ; Initialize to be blank.
Inactive_Dir=%A_ScriptDir%\Inactive Scripts

Loop, *.ahk,0,1
{
   If(A_LoopFileDir = "Inactive Scripts")
      Continue
   Else
   {
      FileList = %FileList%%A_LoopFileName%`n
      If(A_LoopFileDir ="")
         FileDir = %FileDir%%A_ScriptDir%\`n
      Else
         FileDir = %FileDir%%A_ScriptDir%\%A_LoopFileDir%\`n
   }
}
loop, parse, FileList, `n
{
    if A_LoopField =  ; Ignore the blank item at the end of the list.
   {
   FileCount := A_Index-1 ; To also ignore the blank item in future Filecounts
   continue
   }
   File%A_Index% = %A_LoopField%
      
   /*
   MsgBox, 4,, File number %A_Index% is %A_LoopField%.  Continue?
    IfMsgBox, No
        break
      */
}
Loop, parse, FileDir, `n
{
    if A_LoopField =  ; Ignore the blank item at the end of the list.
   {
   FileCount := A_Index-1 ; To also ignore the blank item in future Filecounts
   continue
   }
   Dir%A_Index% = %A_LoopField%
      
   /*
   MsgBox, 4,, File number %A_Index% is %A_LoopField%.  Continue?
    IfMsgBox, No
        break
      */
}
IniWrite, %Filecount%, Master Script Settings.ini, Filecount, Filecount
IniRead, Filecount, Master Script Settings.ini, Filecount, Filecount, 0
Loop, %Filecount% ; Inireads all needed values
{
   Iniread, Scriptname%A_Index%, Master Script Settings.ini, Scriptname, Script%A_Index%,0
   Iniread, Autostart%A_Index%, Master Script Settings.ini, Autostart, Script%A_Index%,0
   Iniread, Hotkey%A_Index%, Master Script Settings.ini, Hotkey, Script%A_Index%
   Iniread, Winkey%A_Index%, Master Script Settings.ini, Winkey, Script%A_Index%,0
   IniRead, Deactivate%A_Index%, Master Script Settings.ini, Deactivate, Script%A_Index%,0
   IniRead, ScriptDir%A_Index%, Master Script Settings.ini, Directory, Script%A_Index%, %A_ScriptDir%
   ; File%A_Index% := Scriptname%A_Index% <--- Commented out since there was a conflict
}
CreateGUI_Stage1:
;the first peice doesn't have to reside in this area but it is added here for easier editing as it is part of the gui creation process
Files:= FileCount
GuiMaxCount =  1
Loop   ;dicovering how many gui windows are required to show the whole file list
{
   If(Files > 15)   ;15 choosen as the limit of programs per gui
   {
      GuiMaxCount++
      Files -= 15
      Continue
   }
   Else   ;if there is less than 15 files no extra guis required
   {
      Break
   }
}
window = 0   ;set to blank to allow for incrimental counting
CreateGUI_Stage2:
window ++   ;add 1 to window to keeptrack of what gui window we are editing
If (window > GuiMaxCount)   ; if script tries to make uneeded windows this if will prevent it
   Gosub,Exit
Else   ;create the gui
{
   Low_Lim:= 15*(window-1)+1   ;calculating for the text of the gui
   if(window = GuiMaxCount)   ;deciphering wether the gui is a full gui or a partial one and calculating the appropriate High_Lim
      High_Lim:= FileCount
   Else
      High_Lim:= 15*window
   ;add the controls of the current gui
   Gui, %window%:Default
   Gui, %window%: Add, Text,, ... %FileCount% files found showing results %Low_Lim% to %High_Lim%   ; text to show the user what files of the filecount are showed on the gui
   Gui, %window%: Add, Button, gSubmit, Save && Exit
   Gui, %window%: Add, Button, xp+70 yp gReset, Reset
   Gui, %window%: Add, Button, xp+55 yp w25 gHelp, ?
   Gui, %window%: Add, Button, xp+35 yp gExit, Exit
   Gui, %window%: Add, Text, y+15 xp-150, Run script   |   Autostart   |   Hotkey   |   +Win key?   |    Deactivate
   Loop, 15   ;add the controls for each program shown in the gui
   {
      instance :=(15*(window - 1)) + A_Index   ;becuase of multiple windows a_Index is unable to be used thus current program has to be calculated
      ;MsgBox, %instance%
      If(instance > FileCount)   ;since it repeats 15 times must ensure that only the amount of files is added not any extras usually blanks
         Break
      Else   ;same process as in orignial script except %instance% used instead of %A_Index%
      {
         FileText := File%instance%
         Gui, %window%: Add, GroupBox, xs0 w350, %FileText%
         Gui, %window%: Add, Button, xp+10 yp+20 h20 r1 gLaunchFileSelect, %instance%   ;set to the file number to allow the "LaunchFileSelect" subroutine to be able to function correctly
         LaunchindexN = Launchindex%instance% ; ?
         n := Autostart%instance%
         Gui, %window%: Add, Checkbox, xp+70 yp+5 r1 vAutostartN%instance% checked%n%
         n := Hotkey%instance%
         Gui, %window%: Add, Hotkey, xp+50 yp-5 w70 vHotkeyN%instance%, %n%
         n := Winkey%instance%
         Gui, %window%: Add, Checkbox, xp+75 yp+5 r1 vWinkeyN%instance% checked%n%
         n:= Deactivate%instance%
         Gui, %window%: Add, Checkbox, xp+75 yp vDeactivateN%instance%   checked%n%
      }
   }
   Gui, %window%:Show, Autosize, Master Script settings (window %window% of %GuiMaxCount%)   ;title showing which window of the series it is
   Return
}

return
reset:
Run,%A_ScriptFullPath%
return
Submit:
Gui,Submit
Loop, 15
{
   instance :=(15*(window - 1)) + A_Index
   If(instance > FileCount)   ;since it repeats 15 times must ensure that only the amount of files is added not any extras usually blanks
      Break
   Else   ;same process as in orignial script except %instance% used instead of %A_Index%
   {
      DirIni := Dir%instance%
      IniWrite, %DirIni%, Master Script Settings.ini, Directory, Script%instance%
      ScriptnameIni := File%instance%
      IniWrite, %ScriptnameIni%, Master Script Settings.ini, Scriptname, Script%instance%
      AutostartIni := AutostartN%instance%
      IniWrite, %AutostartINI%, Master Script Settings.ini, Autostart, Script%instance%
      HotkeyINI := HotkeyN%instance%
      IniWrite, %HotkeyINI%, Master Script Settings.ini, Hotkey, Script%instance%
      WinkeyINI := WinkeyN%instance%
      IniWrite, %WinkeyINI%, Master Script Settings.ini, Winkey, Script%instance%
      DeactivateINI := DeactivateN%instance% ; Yes, I know the this INI value won't be used, but can be good to have if someone wants to change the script
      IniWrite, %DeactivateIni%, Master Script Settings.ini, Deactivate, Script%instance%
      Filemovetext := File%instance%
      FileCreateDir, Inactive Scripts
      If (DeactivateN%instance% = 1)
      {   
         MsgBox, 4, ,Do you want to move %FileMoveText% to %Inactive_Dir%
         IfMsgBox Yes
            FileMove, %Filemovetext%, %Inactive_Dir%
         Else
            Continue
      }
   }
}
Gui,Destroy
Goto,CreateGUI_Stage2
return
Exit:
ExitApp
return
reload:
Reload
return
Masterstartup:
MsgBox FAIL
return
Help:
MsgBox Run script - Runs the chosen script `nAutostart - The chosen script will always start when you start your computer `nHotkey & Win key - Assign a hotkey to launch the selected script, if you want to combine it with the Left Windows key: Also tick the "Win key?" button `nDeactivate - Moves the designated script to a subfolder called "Inactive scripts", so it will not appear in this list
return
Launch:
SoundPlay, *64
Run, %FiletoLaunch%
return
; THE FOLLOWING "LaunchFileSelect" subroutine uses the name of the button to decipher what file the user wants to run, collects it respectable directory, colaborates these together to give a path to the file to be sent to the Launch subroutine
LaunchFileSelect:
Selected_File:= File%A_GuiControl%
Selected_File_Dir:= Dir%A_GuiControl%
FiletoLaunch = %Selected_File_Dir%%Selected_File%
;Msgbox, %FiletoLaunch%
Gosub, Launch
Return

hope this helps


Last edited by small_c0d3r on November 26th, 2010, 5:05 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2010, 10:14 am 
Thanks, the scripts from the First post work fine, I also tried the changed ones by Small Cod3r but it only partly worked, if I assigned a hot key to launch a script it didnt - but gave an error of not being able to launch. But the script from the first post is fine.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2010, 11:08 pm 
Offline

Joined: November 8th, 2010, 5:49 pm
Posts: 16
So let me see if I understand correctly.

I have a bunch of scripts I want to run on startup. So far I have been trying to join them in a single script, as I prefer to run them all under a single process. But I have had little success, as I am a total novice in ahk, many times some scripts no longer work after adding them to the big one (of course some condition I dont know about yet).

So this master scripts just adds a nice UI and I can select the ones I want to run on startup and they are guaranteed to work with no problems among them and all under a process?

thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2010, 12:28 am 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
Sorry for no update yet, had less time than expected.

vaderetro wrote:
So let me see if I understand correctly.

I have a bunch of scripts I want to run on startup. So far I have been trying to join them in a single script, as I prefer to run them all under a single process. But I have had little success, as I am a total novice in ahk, many times some scripts no longer work after adding them to the big one (of course some condition I dont know about yet).

So this master scripts just adds a nice UI and I can select the ones I want to run on startup and they are guaranteed to work with no problems among them and all under a process?

thanks


Almost. This Master Script(s) is a Script that collects all your scripts, displays them on a nice GUI and lets you choose which ones to run on startup (or run when pressing certain hotkeys). Upon startup, the Master Script Startup will launch. When the Master Script Startup launches, it will launch any scripts you have asked for launching (as separate applications).

Your scripts will always work "as usual", this does not modify anything in any way. It just makes it so that you won't have to copy/paste things into a certain script, but can instead freely choose which script(s) to startup.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2010, 12:44 am 
Offline

Joined: November 8th, 2010, 5:49 pm
Posts: 16
understood, thanks.

I prefer the idea of all running under a single process, but maybe it's just a silly search of optimizing everything when possible.

Is having, say, 10 ahk processes that just wait for hotkeys and things like that totally negligible in a current pc in terms of processing overhead?? Or do people try to run everything under a single process?

What is the general consensus among the community?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2010, 7:00 am 
Offline

Joined: November 29th, 2009, 7:53 am
Posts: 46
Location: Queensland
sumon wrote:
Another problem found too: The scripts are "sved" too much ackording to position rather than name, so that if a script is added, it might get the hotkeys of another script. Gotta test that out and fix it.

yes the ini data is confused with the adding of a new script but a simple iniread and file check loop would remove the conflicts as you read the filenames and the number would then be assigned to the script and since the data was set at the same time the corrisponding ini data would be set to the correct file.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: notsoobvious, rrhuffy and 17 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group