Compare commits

...

3 Commits

Author SHA1 Message Date
Yuriy
05800d08a9 added automated compiler for Chromedriver-mover 2023-12-15 16:35:35 -05:00
Yuriy
7d967c7f33 Merge branch 'main' of https://freedomain.dev/yuriy/posters-shared-functions 2023-12-15 16:30:22 -05:00
Yuriy
1dd0557970 added chrome-driver mover tool 2023-12-15 16:30:12 -05:00
4 changed files with 205 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
Chromedriver-Mover.exe

View File

@@ -0,0 +1,71 @@
;---ENVIRONMENT---------------------------------------------------------------------
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn ; Enable warnings to assist with detecting common errors.
;DetectHiddenWindows, On
#SingleInstance, Force
DetectHiddenWindows, ON
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;SetKeyDelay, 500
CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen
; #NoTrayIcon
; Menu, Tray, Icon, RMScriptManager.ico
;---Notes/Extra Info/#Includes------------------------------------------------------
;---VARIABLES-----------------------------------------------------------------------
;---MAIN SCRIPT---------------------------------------------------------------------
AHKFilepath = %A_ScriptDir%\Chromedriver-Mover.ahk
Exefilepath = %A_ScriptDir%\Chromedriver-Mover.exe
icopath = %A_ScriptDir%\Chromedriver-Mover.ico
; Kill any active intances of the uploaders so the .exe file can be overwriten by the compilation
process, close, Chromedriver-Mover.exe
sleep, 1000
; Delete the .exe file so it can be repalced
if(FileExist(Exefilepath)){
FileDelete, %Exefilepath%
if(ErrorLevel){
msgbox, failed to delete Exe file. Please delete manually and re-run the compiler.
ExitApp
}
}
if(!FileExist(AHKFilepath)){
msgbox, %AHKFilepath% does not exist`nExiting
ExitApp
}
if(!FileExist(icopath)){
msgbox, %icopath% does not exist`nExiting
ExitApp
}
run, %comspec% /c ""C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%""
ExitApp
;---FUNCTIONS-----------------------------------------------------------------------

133
Chromedriver-Mover.ahk Normal file
View File

@@ -0,0 +1,133 @@
; ENVIRONMENT
;------------------------------------------------
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn ; Enable warnings to assist with detecting common errors.
;DetectHiddenWindows, On
#SingleInstance, Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;SetKeyDelay, 500
CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen
; #NoTrayIcon
; Notes/Extra Info/#Includes
;------------------------------------------------
; #Include C:\Users\%A_Username%\Syncthing\Scripts\AutoHotKey\RadialMenu\My codes\My Global Variables.ahk
if(InStr(A_ScriptFullPath, ".ahk")){
try Menu, Tray, Icon, %A_ScriptDir%\Assets\icon.ico
}
; Menu, Tray, Icon, C:\Users\%A_Username%\Syncthing\Git\Copy-ChromeDriver-To-Program-Files\Assets\icon.ico
ChromeDriverTemporaryFilepath = %1%
; Msgbox % "Passed in ChromeDriverTemporaryFilepath: " ChromeDriverTemporaryFilepath
; msgbox
; VARIABLES
;------------------------------------------------
SettingsFilepath = %A_ScriptDir%\ChromedriverMover.ini
; Msgbox % "SettingsFilepath: " SettingsFilepath
if(ChromeDriverTemporaryFilepath)
IniWrite, %ChromeDriverTemporaryFilepath%, %SettingsFilepath%, Selenium, ChromeDriverTemporaryFilepath
; MAIN SCRIPT
;------------------------------------------------
StartScriptAsAdmin()
if(ChromeDriverTemporaryFilepath = "")
IniRead, ChromeDriverTemporaryFilepath, %SettingsFilepath%, Selenium, ChromeDriverTemporaryFilepath
ChromeDriverProgramFilesFilepath = C:\Program Files\SeleniumBasic\chromedriver.exe
if(FileExist(ChromeDriverProgramFilesFilepath)){
FileDelete, %ChromeDriverProgramFilesFilepath%
if(ErrorLevel){
msgbox, failed to delete old chromedriver from: C:\Program Files\SeleniumBasic\chromedriver.exe. Please make sure all Selenium Connected instances of Chromium are closed and then try again or move the Chromedriver.exe file manually from:`n%ChromeDriverTemporaryFilepath%
}
}
if(FileExist(ChromeDriverProgramFilesFilepath)){
msgbox, failed to delete old chromedriver from: C:\Program Files\SeleniumBasic\chromedriver.exe. Please run this program as admin or move the chromedriver manually from:`n%ChromeDriverTemporaryFilepath%
ExitApp
}
; msgbox, pause
; Msgbox % "ChromeDriverTemporaryFilepath: " ChromeDriverTemporaryFilepath
if(!InStr(ChromeDriverTemporaryFilepath, ".exe")){ ; parent directory passed in instead of exact filepath. Loop through directory contents and find the .exe file
Loop, files, %ChromeDriverTemporaryFilepath%\*.*, DFR
{ ; D = Directories, F = Files, R = Recursive
SplitPath, A_LoopFileFullPath, FileNameWExt, FileDir, FileExt, FileNameNoExt,
if(FileNameWExt = "chromedriver.exe"){
ChromeDriverTemporaryFilepath := A_LoopFileFullPath
break
}
}
}
if(!InStr(ChromeDriverTemporaryFilepath, ".exe")){
msgbox, Failed to find chromedriver.exe to move. Please move the chromedriver manually.
ExitApp
}
FileCopy, %ChromeDriverTemporaryFilepath%, %ChromeDriverProgramFilesFilepath%, 1
if(ErrorLevel){
msgbox, unable to copy chromedriver.exe from: `n%ChromeDriverTemporaryFilepath%`nto:`n%ChromeDriverProgramFilesFilepath%
ExitApp
}
if(!FileExist(ChromeDriverProgramFilesFilepath)){
msgbox, failed to move chromedriver to %ChromeDriverProgramFilesFilepath%. Please run this program as admin or move the chromedriver manually.
ExitApp
}
; clear the settings file
IniWrite, %A_Tab%, %SettingsFilepath%, Selenium, ChromeDriverTemporaryFilepath
ExitApp
; Functions
;------------------------------------------------
StartScriptAsAdmin(){
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)")) {
try {
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
if(!A_IsAdmin){
Msgbox, failed to get admin to move chromedriver to program files
Return
}
}
; Misc
;------------------------------------------------
; Escape::ExitApp

BIN
Chromedriver-Mover.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB