I want to create a startup script to determine which drive exists, set it to A_Scriptdir, and execute a file.
This is a script created by ChatGPT with an array. It does not work yet, but it added an array to determine which location to execute.
It does not work correctly. any help would be greatly appreciated.
Code: Select all
#noenv
#SingleInstance, force
#requires autohotkey v1
setscriptdir()
SetScriptDir()
{
static scriptDir := ""
if (scriptDir != "")
{
scriptDir := A_ScriptDir
;~ A_ScriptDir := scriptDir
return
}
pathArray := ["b:\", "f:\dropbox\autohotkey", "c:\dropbox\autohotkey"]
loop % pathArray.Length()
{
path := pathArray[A_Index]
;~ MsgBox %path%
if FileExist(path . "\" . bbb-1-myahkdefault.ahk)
{
scriptDir := path
scriptDir := A_ScriptDir
MsgBox %scriptDir%
;~A_ScriptDir := scriptDir
return
}
}
}