관리 메뉴

ㄴrㅎnㅂrㄹrㄱi

AHK Automated Installation 본문

AUTOHOTKEY/스크립트

AHK Automated Installation

님투 2007. 11. 4. 22:52
반응형
The following script:
- Checks the latest version of ahk installation from web
- Let you select web or local ahk installation file
- Shows download progress while file is being downloaded.
- Backs up registry entries for Compiler/Editor etc. of AHK scripts
- Exits all running uncompiled ahk scripts (asks you to confirm this step)
- Runs installation and automates the process
- Loads back old registry settings
- Runs the scripts exited during installation and upto 3 custom files as per user reqmt (can be your 24*7 scripts or anything else)

IMPORTANT : Compile this script before running.



DetectHiddenWindows On 

;___________________________________________
;           CONFIGURATION AREA

DownloadURL = http://www.autohotkey.com/download
DownloadFolder = %A_Desktop%

;UnComment to save all keys
RegRead, RegCmp, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Compile\Command,
RegRead, RegEdt, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command,
RegRead, RegOpn, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Open\Command,
RegRead, RegRun, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Run\Command,


;Scripts/programs to run after installation
Run1 = E:\dos\batch\ManFriday.ahk
Run2 = E:\dos\batch\AhkIcons.ahk
Run3 =


;___________________________________________

RunScripts = %Run1%`n%Run2%`n%Run3%

;get version from system
RegRead, AHKPATH, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Run\Command,
StringGetPos, POS, AHKPATH, \AutoHotkey.exe
StringLeft, AHKPATH, AHKPATH, %POS%
StringReplace, AHKPATH, AHKPATH, ",, A
FileGetVersion, CurrVer, %AHKPath%\AutoHotkey.exe 

;get version from web
Random, Rnd1, 1, 1000
Random, Rnd2, 1, 1000
FileDelete, %Temp%\LatestVer.txt
URLDownloadToFile, %DownloadURL%/CurrentVersion.txt?%Rnd1%=%Rnd2%, %Temp%\LatestVer.txt
FileReadLine, LatestVer, %Temp%\LatestVer.txt, 1


MsgBox, 3, AHK AutoInstaller, Latest Version`t:    %LatestVer%`nLocal Version`t:    %CurrVer%`n`nPress Yes to download and install latest version.`nPress No to install from local file.`nPress Cancel to Exit.

IfMsgBox, Cancel
  ExitApp

IfMsgBox, Yes
{
  StringReplace, LatestVer2, LatestVer, .,, All
    TrayTip, AHK AutoInstaller, Downloading`nPlease Wait....
  SetTimer, GetSize, 2000
  URLDownloadToFile, %DownloadURL%/AutoHotkeyInstall.exe?%Rnd1%=%Rnd2%, %DownloadFolder%\AutoHotkey%LatestVer2%.exe
  IfNotEqual, ErrorLevel, 0
  {
    TrayTip
    Msgbox,, AHK AutoInstaller, There was a problem downloading the installation file.
    ExitApp
  }
  SetTimer, GetSize, Off
  TrayTip
  Installer = %DownloadFolder%\AutoHotkey%LatestVer2%.exe
}

IfMsgBox, No  
  FileSelectFile, Installer, 1,, Select AutoHotkey Installation File, AutoHotkey (*.exe)

IfNotExist, %Installer%, ExitApp

Process, Exist, AutoHotkey.exe
IfNotEqual, ErrorLevel, 0
{
  MsgBox, 4, AHK AutoInstaller, Exit all running scripts?
  IfMsgBox, Yes
  {
    ;Function by Chris    
    WinGet, List, List, ahk_class AutoHotkey 
    Loop, %List% 
    { 
       ListItem := List%A_Index% 
       WinGetTitle, Title, ahk_id %ListItem% 
       StringGetPos, Pos, Title, %A_Space%- AutoHotkey v 
       if pos < 0  ; Compiled scripts can be left running without harm. 
        continue  ; Skip this script, since it's an EXE. 
       StringLeft, ScriptFileName, Title, %Pos% 
       RunScripts = %RunScripts%`n%ScriptFileName% 
    }

    Loop
    {
      Process, Exist, AutoHotkey.exe
      IfEqual, ErrorLevel, 0, Break
      Process, Close, AutoHotkey.exe
    }
  }
}



Run, %Installer%

    TrayTip, AHK AutoInstaller, Downloading`nPlease Wait....

;Output from AutoScriptWriter
WinWait, AutoHotkey 1.0., Welcome to the AutoH
IfWinNotActive, AutoHotkey 1.0., Welcome to the AutoH, WinActivate, AutoHotkey 1.0., Welcome to the AutoH
WinWaitActive, AutoHotkey 1.0., Welcome to the AutoH
Send, {ALTDOWN}n{ALTUP}
WinWait, AutoHotkey 1.0. , Nullsoft Install Sys
IfWinNotActive, AutoHotkey 1.0. , Nullsoft Install Sys, WinActivate, AutoHotkey 1.0. , Nullsoft Install Sys
WinWaitActive, AutoHotkey 1.0. , Nullsoft Install Sys
Send, {ALTDOWN}a{ALTUP}{DOWN  2}{SPACE}{ALTDOWN}n{ALTUP}{ALTDOWN}i{ALTUP}
WinWait, AutoHotkey 1.0. , Completing the AutoH
IfWinNotActive, AutoHotkey 1.0. , Completing the AutoH, WinActivate, AutoHotkey 1.0. , Completing the AutoH
WinWaitActive, AutoHotkey 1.0. , Completing the AutoH
Send, {ALTDOWN}s{ALTUP}{ALTDOWN}f{ALTUP}

TrayTip

IfNotEqual, RegCmp,
  RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Compile\Command,, %RegCmp%

IfNotEqual, RegEdt,
  RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Edit\Command,, %RegEdt%

IfNotEqual, RegOpn,
  RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Open\Command,, %RegOpn%

IfNotEqual, RegRun,
  RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AutoHotkeyScript\Shell\Run\Command,, %RegRun%

Sort, RunScripts, U

Loop, Parse, RunScripts, `n
  IfExist, %A_LoopField%, Run, %A_LoopField%,, UseErrorLevel


GetSize:
  FileGetSize, FSize, %DownloadFolder%\AutoHotkey%LatestVer2%.exe, K
  IfEqual, FSize, FSize0, Return
  IfNotEqual, ErrorLevel, 1
    TrayTip, AHK AutoInstaller, Downloading`nPlease Wait....`n%FSize% Kb
  FSize0 = %FSize%
Return


반응형
Comments