;;; | ;;; ACE app bits (starting script) | #Include %A_AppData%\ACE\#aces.ahb ;;; | ; SetWorkingDir %A_ScriptDir% ; Consistent starting directory SendMode Input ; Superior speed and reliability #NoEnv ; Performance and release compatibility ;#Warn ; Enable warnings to detect common errors ;;; ;;; Declare/initiate global vars; parse arguments passed via command line ;;; Global AceID, SpaceID, FaceID, PlaceID, TitleID ; Terms0 Term"TERM" Global AceName, SpaceName, FaceName, PlaceName ; Terms1...999 Global AcePlace, FacePlace, PlaceIndex ; keep ONE of these (same) Global AcePath, SpacePath, FacePath, PlacePath ; Terms TermsFile Global FaceAbout, PlaceAbout, FaceAboutPath, PlaceAboutPath Global AceApps, FaceApps, PlaceApps, AceAppsPath, FaceAppsPath, PlaceAppsPath Global AceBits, FaceBoard, PlaceBoard, AceBitsPath, FaceBoardPath, PlaceBoardPath Global AceArt, FaceGuide, PlaceGuide, AceArtPath, FaceGuidePath, PlaceGuidePath Global FaceMail, PlaceMail, FaceMailPath, PlaceMailPath Global FaceNotes, PlaceNotes, FaceNotesPath, PlaceNotesPath Global FaceTalk, PlaceTalk, FaceTalkPath, PlaceTalkPath Global FaceText, PlaceText, FaceTextPath, PlaceTextPath Global FaceTube, PlaceTube, FaceTubePath, PlaceTubePath Global FaceTunes, PlaceTunes, FaceTunesPath, PlaceTunesPath Global FaceTop, PlaceTop ; added 101317 Global UserProfile Global UserName Global CharterMirrorName := "desktop.ini" Global CharterMasterName := "ACE.ini" StringSplit, Bit, A_ScriptName, `;`,`.`(`)`[`]`{`} bitName := Bit1 bitPar1 := Bit2 bitPar2 := Bit3 bitPar3 := Bit4 bitPar4 := Bit5 bitPar5 := Bit6 bitPar6 := Bit7 bitPar7 := Bit8 bitPar8 := Bit9 bitPar9 := Bit10 ; MAX parameters (9) bitArg1 = %1% bitArg2 = %2% bitArg3 = %3% bitArg4 = %4% bitArg5 = %5% bitArg6 = %6% bitArg7 = %7% bitArg8 = %8% bitArg9 = %9% ; MAX parameters (9) bitArgs = %0% ReadReg: RegRead, AcePlace0, HKEY_CURRENT_USER, Environment, AcePlace0 RegRead, AcePlace1, HKEY_CURRENT_USER, Environment, AcePlace1 RegRead, AcePlace2, HKEY_CURRENT_USER, Environment, AcePlace2 RegRead, AcePlace3, HKEY_CURRENT_USER, Environment, AcePlace3 RegRead, AcePlace4, HKEY_CURRENT_USER, Environment, AcePlace4 RegRead, AcePlace5, HKEY_CURRENT_USER, Environment, AcePlace5 RegRead, AcePlace6, HKEY_CURRENT_USER, Environment, AcePlace6 RegRead, AcePlace7, HKEY_CURRENT_USER, Environment, AcePlace7 RegRead, AcePlace8, HKEY_CURRENT_USER, Environment, AcePlace8 RegRead, AcePlace9, HKEY_CURRENT_USER, Environment, AcePlace9 RegRead, AcePath, HKEY_CURRENT_USER, Environment, AcePath RegRead, AcePlace, HKEY_CURRENT_USER, Environment, AcePlace RegRead, PlacePath, HKEY_CURRENT_USER, Environment, AcePlace%AcePlace% RegRead, FacePath, HKEY_CURRENT_USER, Environment, AcePlace0 RegRead, SpacePath, HKEY_CURRENT_USER, Environment, SpacePath IniRead, SpaceID, %SpacePath%\%CharterMirrorName%, Place, ID, CLOUD IniRead, FaceID, %FacePath%\%CharterMirrorName%, Place, ID, ME IniRead, PlaceID, %PlacePath%\%CharterMirrorName%, Place, ID, HERE IniRead, SpaceName, %SpacePath%\%CharterMirrorName%, Place, Name, Internet IniRead, FaceName, %FacePath%\%CharterMirrorName%, Place, Name, device IniRead, PlaceName, %PlacePath%\%CharterMirrorName%, Place, Name, location MissingSpaceStuff := (SpacePath="") ? True : False MissingFaceStuff := (FacePath="") ? True : False If (MissingSpaceStuff <> 0) SpacePath := Spacement() If (MissingFaceStuff <> 0) FacePath := Facement() If (MissingSpaceStuff or MissingFaceStuff) Goto ReadReg FacePlace := (AcePlace<>0) ? "Place" : "Face" GetCharter("Face") GetCharter("Place") PlaceTop := SubStr(PlacePath, StrLen(SpacePath) + 2, StrLen(PlacePath) - StrLen(SpacePath) - 1) ; added FaceTop := SubStr(FacePath, StrLen(SpacePath) + 2, StrLen(FacePath) - StrLen(SpacePath) - 1) ; 101317 AceApps := "apps" AceArt := "art" AceBits := AceApps . "\bits" AceAppsPath := AcePath . "\" . AceApps AceArtPath := AcePath . "\" . AceArt AceBitsPath := AcePath . "\" . AceBits ;;; ;;; public functions ;;; FaceSetting(dToken, dOlderToken, dDefaultValue, dRunIfMissing) { ; ; in the CLOUD for FACE apps ; Return % _initAceSetting("Face", "Place", dToken) ; , dOlderToken, dDefaultValue, dRunIfMissing) } PlaceSetting(dToken, dOlderToken, dDefaultValue, dRunIfMissing) { ; ; in the CLOUD for PLACE apps ; Return % _initAceSetting("Place", "Place", dToken) ; , dOlderToken, dDefaultValue, dRunIfMissing) } AceSetting(dToken, dOlderToken, dDefaultValue, dRunIfMissing) { ; ; not in CLOUD - only on this DEVICE and ACE apps have access ; Return % _initDevSetting(dToken, dOlderToken, dDefaultValue, dRunIfMissing, "Software\ACE") } DeviceSetting(dToken, dOlderToken, dDefaultValue, dRunIfMissing) { ; ; not in CLOUD - only on this DEVICE and ALL apps have access ; Return % _initDevSetting(dToken, dOlderToken, dDefaultValue, dRunIfMissing, "Environment") } ;;; ;;; private functions (two OS methods: File.ini, Registry) ;;; _initAceSetting(aFile, aSection, aKey) { ; ; values returned are CLOUD shared (i.e., common to member devices) ; If (aFile = "ace" or aFile = "space" or aFile = "face" or aFile = "place") aFile := %aFile%Path IniRead, aValue, %aFile%, %aSection%, %aKey% ; If (aValue = "") ; IniRead, aValue, %aFile%, %aSection%, %aOldKey% ; If (aValue = "" or aValue = "ERROR") ; aValue := aDefaultValue Return %aValue% } _initDevSetting(aKey, oldKey, defValue, RunThisIfMissing, aSection) { ; ; values returned are not CLOUD shared but from Registry or Environment of the device ; RegRead, aValue, HKEY_CURRENT_USER, %aSection%, %aKey% If (aValue = "") { If (oldKey <> "") { RegRead, aValue, HKEY_CURRENT_USER, %aSection%, %oldKey% If (aValue <> "") { MsgBox, 64, #Aces, '%aKey%' is not recorded. `n'%oldKey%' will be inherited.`n`n`"%aValue%`" RegWrite, REG_SZ, HKEY_CURRENT_USER, %aSection%, %aKey%, %aValue% } } } If (aValue = "" and RunThisIfMissing <> "") { MsgBox, 64, #Aces, '%aKey%' value isn't valid. `n`n`"%aValue%`" `n`nClick OK to run %RunThisIfMissing% RunWait, %RunThisIfMissing% Reload } If (aValue = "") Return % defValue Else Return % aValue } AboutEnum(){ Return ":Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "!\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "#\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "123\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "ABCs\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "about\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "access\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "aces\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "apps\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return "asap\:Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" ; Return ":Apps:Board:Guide:Mail:Notes:Talk:Text:Tube:Tunes" } AnyplaceEnum(){ Return "about\" . AboutEnum() . "|Listen\:Book:Music|Read\:Book:Magazine:News|Watch\:Movie:Picture:Video" } HomeplaceEnum(){ Return "aces\" . AboutEnum() . "|Documents|Games|Music|Pictures|Records|Shops|Videos" } WorkplaceEnum(){ Return "asap\" . AboutEnum() . "|Customer|Employee|Facility|Government|MANAGE|Product|Public|Vendor" } SomeplaceEnum(){ Return "apps\" . AboutEnum() . "" } GetCharter(Face_Place) { Global FacePath, PlacePath, CharterMasterName, CharterMirrorName MirrorPath := %Face_Place%Path MasterPath := FileExist(MirrorPath . "\about\ACE.ini") ? "about" : FileExist(MirrorPath . "\aces\ACE.ini") ? "aces" : FileExist(MirrorPath . "\asap\ACE.ini") ? "asap" : FileExist(MirrorPath . "\tapps\ACE.ini") ? "tapps" MasterPath := MirrorPath . "\" . MasterPath MirrorFile := MirrorPath . "\" . CharterMirrorName MasterFile := MasterPath . "\" . CharterMasterName Section := "Place" Terms := "ERROR" IfExist, %MirrorFile% IniRead, Terms, %MirrorFile%, %Section%, Terms IniRead, PlaceClass, %MirrorFile%, Place, Class, Someplace ClassEnum := %PlaceClass%Enum ; ; %Terms% should represent your PLACE basic folder structure ; BUT double check and update CharterMirrorName if missing (use defaults) ; If (Terms = "ERROR" or Terms = "") { ; MUST add choice of PLACE here ; MsgBox, 64, %a_ScriptName%, Pairing . . . devices . . . charters`n`n[%Face_Place%]`nTerms=%Terms%, 5 If (Face_Place = "FACE") Terms := AnyplaceEnum() Else Terms := WorkplaceEnum() IniRead, MasterTerms, %MasterFile%, %Section%, Terms IniWrite, %MasterTerms%, %MirrorFile%, %Section%, Terms IfExist, %MirrorFile% { If (AcePath <> "") IfExist, %AcePath%\AceSync.ahk { RunWait %AcePath%\AceSync.ahk "-silent" "-%Face_Place%" Reload } Else { MsgBox, 64, %AceID%, Attempted to pair but AceSync wasn't available. `n`n%AcePath%\AceSync.ahk Return AcePath } } Else MsgBox, 64, #%AceID%, %MirrorFile% cannot be completed. Check that folder exists and user has sufficient rights to write to this file. ExitApp } Else IniRead, PlaceEnum, %MirrorFile%, %Section%, Terms, %ClassEnum% ; ; parse by PIPE - get BRANCHES ; StringSplit, TermRoots, PlaceEnum, | Loop, %TermRoots0% { Root_Index := A_Index TermRoot := TermRoots%Root_Index% ; ; parse by COLON - get LEAVES aka NODES ; StringSplit, TermNodes, TermRoot, : Loop, %TermNodes0% { Node_Index := A_Index Term := TermNodes%Node_Index% StringReplace, Term, Term, %A_SPACE%, _, All ; added 011517 NewTerm := ":" . Term StringSplit, NodeRoot, Term, \ IniRead, %Face_Place%%NodeRoot1%Term, %MirrorFile%, Terms, %NodeRoot1%, %Term% If (Node_Index = 1) { NewTerm := "" NodePrefix := %Face_Place%%NodeRoot1%Term StringRight, LastPrefixChr, NodePrefix, 1 If (LastPrefixChr <> "\") NodePrefix := NodePrefix . "\" If FileExist(%Face_Place%Path . "\" . NodePrefix) NewTerms := NewTerms . NodeRoot1 ; . "\" ; removed . "\" on 012617 with initial good results Else { InvalidAces := InvalidAces . MirrorPath . "\" . NodeRoot1 . "`n" Continue } } If (Node_Index > 1) { ThisNode := NodePrefix . %Face_Place%%Term%Term } Else { ThisNode := %Face_Place%%NodeRoot1%Term } If (FileExist(%Face_Place%Path . "\" . ThisNode)<>"") { %Face_Place%%NodeRoot1% := ThisNode %Face_Place%%NodeRoot1%Path := %Face_Place%Path . "\" . ThisNode ; add 100717 for $FaceGuidePath argument NewTerms := NewTerms . NewTerm ; NewTerm vs Term } Else { InvalidAces := InvalidAces . MirrorPath . "\" . ThisNode . "`n" } } StringRight, LastChr, NewTerms, 1 If (LastChr <> "|") NewTerms := NewTerms . "|" } If (InvalidAces <> "") { ;msgbox, 64, Terms (spoken here), Mirror: `n%Terms% `n`nValidated: `n%NewTerms% IniWrite, %NewTerms%, %MirrorFile%, %Section%, Terms } Return InvalidAces } Spacement() { Global SpacePath, PlacePath, FacePath, AcePath, AcePlace IfExist, %SpacePath% Return SpacePath Drive1 = %HOMEDRIVE% Drive2 = %SystemDrive% EnvGet, Drive1, HomeDrive EnvGet, Drive2, SystemDrive MsgBox 36, ACE Install, A Cloud Ensemble `n`nACE is often shared by every user of a device. Locating it at `nthe root of a drive is simple to remember. `n`nDesignate Cloud storage at %Drive1%\ ? IfMsgBox Yes AceDrive := Drive1 If (AceDrive = "") { If (Drive1 <> Drive2) { MsgBox 36, ACE Install, Designate Cloud storage at %Drive2%\? IfMsgBox Yes AceDrive = %SYSTEMDRIVE% } } If (AceDrive <> "") { SpacePath = %AceDrive%\CLOUD } Else { MsgBox 36, ACE Install, Okay`, how about locating Cloud storage to the Public user? IfMsgBox Yes SpacePath = %PUBLIC%\CLOUD Else { AceDrive := ChooseDrive("Fixed", "Choose a CLOUD storage folder (this device)`n`nSelect a folder and OK `t- or -`tCANCEL to next drive", 1) StringRight, LastChar, AceDrive, 1 If (LastChar = "") { MsgBox, 64, ACE Install, Installation fails! You must select a Cloud storage folder. ExitApp } If (LastChar = "\") { LeftLen := StrLen(AceDrive) - 1 StringLeft, SpacePath, AceDrive, LeftLen } Else SpacePath := AceDrive } } ;Assert(FileExist(SpacePath), "SpacePath does not exist. `n%SpacePath%", 0) ;RegWrite, REG_SZ, HKEY_CURRENT_USER, Environment, AceFolder, %SpacePath% RegWrite, REG_SZ, HKEY_CURRENT_USER, Environment, SpacePath, %SpacePath% Return SpacePath } Facement() { Global SpacePath, PlacePath, FacePath, AcePath, AcePlace IfNotExist, %SpacePath% { MsgBox, 64, ACE Install, Cloud offline storage path does NOT exist. Cannot establish FACE path. Return } If (AcePlace = "" or AcePlace > 99 or AcePlace < 0) RegWrite, REG_SZ, HKEY_CURRENT_USER, Environment, AcePlace, 0 Facement1: IfExist, %FacePath% { RegWrite, REG_SZ, HKEY_CURRENT_USER, Environment, AcePlace0, %FacePath% RegWrite, REG_SZ, HKEY_CURRENT_USER, Environment, FacePath, %FacePath% Return FacePath } FileSelectFolder, FacePath, %SpacePath%, 3, CLOUD personal storage...`n`nSelect your FACE folder: IfExist, %FacePath% Goto Facement1 MsgBox, 35, ACE Install, Your FACE path does not exist`, create it? `n`n`t%FacePath% IfMsgBox Yes FileCreateDir, %FacePath% Goto Facement1 } ChooseDrive(TypeWanted, PromptMsg, ReturnPath) { DriveGet, DriveList, list DriveListX := 1 Loop { StringMid, Drive, DriveList, %DriveListX%, 1 If (Drive = "") Return DriveLetter := Drive Drive := Drive . ":" DriveGet, DriveStatus, status, %Drive% DriveGet, DriveCap, capacity, %Drive% DriveGet, DriveType, type, %Drive% DriveGet, DriveStatus, status, %Drive% DriveGet, DriveLabel, label, %Drive% DriveGet, DriveFS, fs, %Drive% DriveGet, DriveSerial, serial, %Drive% DrivespaceFree, DriveFree, %Drive% If (DriveStatus <> "NotReady" and (TypeWanted = "" or TypeWanted = DriveType)) { If (PromptMsg <> "") FileSelectFolder, Folder, %Drive%, 3, %PromptMsg% `nDrive %DriveLetter%: `t%DriveFree% free `t`"%DriveLabel%`" `n %DriveStatus% `t%DriveCap% total `t is %DriveType% Else FileSelectFolder, Folder, %Drive%, 3, Drive %DriveLetter%: `t%DriveFree% free `t`"%DriveLabel%`" `n %DriveStatus% `t%DriveCap% total `t is %DriveType% If (Folder <> "") If (ReturnPath = "Y" or ReturnPath = "Yes" or ReturnPath = "YES" or ReturnPath = "1" or ReturnPath = "-1") Return Folder Else Return Drive } DriveListX := DriveListX + 1 } }