FileSelectFile Multi-select Option Issue. Please help! Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
boiler
Posts: 16913
Joined: 21 Dec 2014, 02:44

Re: FileSelectFile Multi-select Option Issue. Please help!

11 Feb 2018, 22:21

gamesguy383 wrote:What if i set the attributes "read-only" for the files I don't want to see. You think there is and expression I could use then? I remember seeing something like that
I don't know what you mean by files you don't want to see. You mean in the file selector box? No, you can't filter on attributes that I'm aware of.

I can't continue with this ongoing string of questions. Maybe someone else can help out. I suggest posting specific questions for specific issues in new threads.
gamesguy383
Posts: 21
Joined: 09 Feb 2018, 02:10

Re: FileSelectFile Multi-select Option Issue. Please help!

11 Feb 2018, 22:28

When I used FileSelectFile Option = 3, it gave me an output which I used to SplitPath for more outputs which I used in my formulas to write batch files for each rom to launch from a folder independently. I achieved that. When I used FileSelectFile Option = M, to repeat the function on many files once by one, I got really lost.
gamesguy383
Posts: 21
Joined: 09 Feb 2018, 02:10

Re: FileSelectFile Multi-select Option Issue. Please help!

11 Feb 2018, 22:44

Every folder may contain different file extensions for a rom, save, config and so on. I don't need to see them all and would like to see only the files that will launch the rom, but every folder will contain different rom extension. How could I filer out the files from the selector box
gamesguy383
Posts: 21
Joined: 09 Feb 2018, 02:10

Re: FileSelectFile Multi-select Option Issue. Please help!

14 Feb 2018, 22:48

not sure if anyone is interested but I managed to hide unwanted files with FileSetAttrib and then return them. Unfortunately the file list is massive and it takes about 10 sec to set it the first time and about 5 sec to set it the second time.

Code: Select all

FileSetAttrib:
{
	MsgBox, 4,Please select, Would you like to hide unwanted files?
	IfMsgBox, No, goto FileSelectFile
	}
FileSetAttrib, +H, %A_WorkingDir%\nullDC\*.*
FileSetAttrib, -H, %A_WorkingDir%\nullDC\*.iso
FileSetAttrib, +H, %A_WorkingDir%\Dolphin\*.*
FileSetAttrib, -H, %A_WorkingDir%\Dolphin\*.bin
FileSetAttrib, +H, %A_WorkingDir%\PPSSPP\*.*
FileSetAttrib, -H, %A_WorkingDir%\PPSSPP\*.cso
FileSetAttrib, +H, %A_WorkingDir%\pcsx-2\*.*
FileSetAttrib, -H, %A_WorkingDir%\pcsx-2\*.bin
FileSetAttrib, -H, %A_WorkingDir%\pcsx-2\*.iso
	MsgBox, ,Please proceed, Unwanted files have been hidden

FileSelectFile:
FileSelectFile, SourceFiles, M3, %A_WorkingDir%, Please select Roms you wish to add to the %LogDir%

{
	MsgBox, 4,Please select, Would you like to return the hidden files?
	IfMsgBox, No, goto Next
	}
FileSetAttrib, -H, %A_WorkingDir%\nullDC\*.*
FileSetAttrib, -H, %A_WorkingDir%\Dolphin\*.*
FileSetAttrib, -H, %A_WorkingDir%\PPSSPP\*.*
FileSetAttrib, -H, %A_WorkingDir%\pcsx-2\*.*

Next:
if SourceFiles = 
{
	MsgBox, ,Thank you!, You chose not to create the batch file.`n`n             Goodbye!
return
	}
	
Loop, parse, SourceFiles, `n

if A_Index = 1
{
Array := StrSplit(A_LoopField, "\")
SrcFileFolder := StrReplace(Array[6], "-")
	MsgBox, ,Please proceed, The selected files come from`n %SrcFileFolder%`n Folder.
}
else
{
SplitPath, A_LoopField, SourceFileName, SourceFileDir, SourceFileExt, SourceFileNoExt				; Multi input but only single OutputVar. Need an array for OutputVar.
	MsgBox, 4, The selected file is, %SourceFileName%`n`n Would you like to select the next file?	; Scrolls through the %SourceFileName% here, but overall result, it creates only one batch file not multiple files
	IfMsgBox, No, break
}
gamesguy383
Posts: 21
Joined: 09 Feb 2018, 02:10

Re: FileSelectFile Multi-select Option Issue. Please help!  Topic is solved

24 Feb 2018, 01:26

It turned out that I had the brackets in the wrong place. I've added a lot more script to it. It all works now!

Code: Select all

SetWorkingDir %A_ScriptDir%
LogDir := "favorites"

IfNotExist, %CLogDir%
FileCreateDir, %LogDir%
IfNotExist, ..\gamelists\%LogDir%
FileCreateDir, ..\gamelists\%LogDir%
	;MsgBox, , Please proceed, Your batch files will be saved in the %LogDir% directory
	
FileRead, systemsconfig, ..\systems.cfg
	;MsgBox, ,Please wait, Checking if the %LogDir% system exists in the systems.cfg

IfInString, systemsconfig, %LogDir%
{
	MsgBox, ,Please proceed, The %LogDir% system already exists
goto FileSetAttrib
}

IfNotInString, systemsconfig, %LogDir%
{
	;MsgBox, ,Please wait, The %LogDir% system needs to be created
	
	ROM_RAW := "%ROM_RAW%"
	%LogDir%node =
	(join`r`n
<system>
<name>%LogDir%</name>
<fullname>%LogDir%</fullname>
<path>%LogDir%</path>
<extension>.bat .BAT</extension>
<command>"%ROM_RAW%"</command>
<theme>%LogDir%</theme>
</system>

</systemList>
	)
	
	systemsconfig := StrReplace(systemsconfig, "</systemList>", %LogDir%node)
	
	FileDelete,  ..\systems.cfg
	FileAppend, %systemsconfig%, ..\systems.cfg
		MsgBox, ,Please proceed, The %LogDir% system was created in the systems.cfg
	}

FileSetAttrib:
{
	MsgBox, 4,Please select, Would you like to hide unwanted files?
	IfMsgBox, No, goto FileSelectFile
	}
FileSetAttrib, +H, %A_WorkingDir%\nullDC\*.*
FileSetAttrib, -H, %A_WorkingDir%\nullDC\*.iso
FileSetAttrib, +H, %A_WorkingDir%\Dolphin\*.*
FileSetAttrib, -H, %A_WorkingDir%\Dolphin\*.bin
FileSetAttrib, +H, %A_WorkingDir%\PPSSPP\*.*
FileSetAttrib, -H, %A_WorkingDir%\PPSSPP\*.cso
FileSetAttrib, +H, %A_WorkingDir%\pcsx-2\*.*
FileSetAttrib, -H, %A_WorkingDir%\pcsx-2\*.bin
FileSetAttrib, -H, %A_WorkingDir%\pcsx-2\*.iso
	MsgBox, ,Please proceed, Unwanted files have been hidden

FileSelectFile:
FileSelectFile, SourceFiles, M3, %A_WorkingDir%, Please select Roms you wish to add to the %LogDir%

{
	MsgBox, 4,Please select, Would you like to return the hidden files?
	IfMsgBox, No, goto Next
	}
FileSetAttrib, -H, %A_WorkingDir%\nullDC\*.*
FileSetAttrib, -H, %A_WorkingDir%\Dolphin\*.*
FileSetAttrib, -H, %A_WorkingDir%\PPSSPP\*.*
FileSetAttrib, -H, %A_WorkingDir%\pcsx-2\*.*

Next:
if SourceFiles = 
	{
		MsgBox, ,Thank you!, You chose not to create the batch file.`n`n             Goodbye!
		return
		}
	
Loop, parse, SourceFiles, `n

	if A_Index = 1
		{
		Array := StrSplit(A_LoopField, "\")
		SrcFileFolder := StrReplace(Array[6], "-")
			;MsgBox, ,Please proceed, The selected files come from`n %SrcFileFolder%`n Folder.
			}
	else
{
		SplitPath, A_LoopField, SourceFileName, SourceFileDir, SourceFileExt, SourceFileNoExt					
			
nullDC = %HOME%\nullDC.exe -config nullDC_GUI:Fullscreen=1 -config nullDC:Emulator.Autostart=1 -config ImageReader:LoadDefaultImage=1 -config ImageReader:DefaultImage="%SourceFileName%"
Dolphin = %HOME%\Dolphin.exe -e "%SourceFileName%"
PPSSPP = %HOME%\PPSSPPWindows.exe "%SourceFileName%"
pcsx2 = %HOME%\pcsx2.exe "%SourceFileName%"


if SourceFileDir contains pcsx-2
{
	FileDelete, %A_WorkingDir%\%LogDir%\%SourceFileNoExt% - pcsx-2.bat
	FileAppend, % pcsx2, %A_WorkingDir%\%LogDir%\%SourceFileNoExt% - pcsx-2.bat
		MsgBox, , Congratulations!, %SourceFileNoExt% - pcsx-2.bat`n`n Was successfully created in the %LogDir% directory
	
FileRead, gamelist, ..\gamelists\pcsx-2\gamelist.xml

	doc := ComObjCreate("MSXML2.DOMDocument.6.0")
	doc.async := false
	doc.loadXML(gamelist)
	
try {
	docNode := doc.selectSingleNode("//game[path='./" SourceFileNoExt "']") ;will select the first game with the SourceFileNoExt
}catch e {
	;ignore
}
if !docNode
		Msgbox, ,Please scrape from the front end, The %SourceFileName%`n was not found in the pcsx-2 gamelist

{
Haystack := docNode.xml
Loop, Parse, Haystack, `n

	if A_index = 2
		{
		Needle = <path>./%SourceFileNoExt% - pcsx-2.bat</path>
		Haystack1 := StrReplace(Haystack, A_LoopField, Needle)
		}
		else
		{
		Ndle = - pcsx-2</name>
		Haystack2 := StrReplace(Haystack1, "</name>", Ndle)
		Haystack3 := StrReplace(Haystack2, "</game>", "</game>`n</gameList>")
		}

FileRead, LogDirGameList, ..\gamelists\%LogDir%\gamelist.xml

	if ErrorLevel = 0
	{
		if LogDirGameList contains %SourceFileNoExt%
			{
			MsgBox, ,Please proceed, %SourceFileNoExt% - pcsx-2.bat`n`n Was found in the`n`n ..\gamelists\%LogDir%\gamelist.xml
			}
			else
			{
			LogDirGameList := StrReplace(LogDirGameList, "</gamelist>", Haystack3)
			FileDelete, ..\gamelists\%LogDir%\gamelist.xml
			FileAppend, %LogDirGameList%, ..\gamelists\%LogDir%\gamelist.xml
				MsgBox, , Congratulations!, %SourceFileNoExt% - pcsx-2.bat`n`n Was successfully created in the`n`n ..\gamelists\%LogDir%\gamelist.xml
				return
			}
	}	
			
	if ErrorLevel = 1
		{
		NewXmlLogDir = 
	(join`r`n
<?xml version="1.0"?>
<gameList>
	<game>
		<path></path>
		<name></name>
	</game>
</gameList>
	)

		Haystack4 := StrReplace(NewXmlLogDir, "</gameList>", Haystack3)
		FileAppend, %Haystack4%, ..\gamelists\%LogDir%\gamelist.xml
			MsgBox, , Congratulations!, %SourceFileNoExt% - pcsx-2.bat`n`n Was successfully created in the`n`n ..\gamelists\%LogDir%\gamelist.xml
			return
			}
				}
					}
else
{
BatchF := %SrcFileFolder%

	FileDelete, %A_WorkingDir%\%LogDir%\%SourceFileNoExt% - %SrcFileFolder%.bat
	FileAppend, %BatchF%, %A_WorkingDir%\%LogDir%\%SourceFileNoExt% - %SrcFileFolder%.bat
		MsgBox, , Congratulations!, %SourceFileNoExt% - %SrcFileFolder%.bat`n`n Was successfully created in the %LogDir% directory

FileRead, gamelist, ..\gamelists\%SrcFileFolder%\gamelist.xml

	doc := ComObjCreate("MSXML2.DOMDocument.6.0")
	doc.async := false
	doc.loadXML(gamelist)

try {
	docNode := doc.selectSingleNode("//game[path='./" SourceFileName "']") ;will select the first game with the SourceFileName
}catch e {
	;ignore
}
if !docNode
		Msgbox, ,Please scrape from the front end, The %SourceFileName%`n was not found in the %SrcFileFolder% gamelist

else
{
Haystack := docNode.xml
Loop, Parse, Haystack, `n

	if A_index = 2
		{
		Needle = <path>./%SourceFileNoExt% - %SrcFileFolder%.bat</path>
		Haystack1 := StrReplace(Haystack, A_LoopField, Needle)
		}
		else
		{
		Ndle = - %SrcFileFolder%</name>
		Haystack2 := StrReplace(Haystack1, "</name>", Ndle)
		Haystack3 := StrReplace(Haystack2, "</game>", "</game>`n</gameList>")
		}

FileRead, LogDirGameList, ..\gamelists\%LogDir%\gamelist.xml

	if ErrorLevel = 0
	{
		if LogDirGameList contains %SourceFileNoExt%
			{
			MsgBox, ,Please proceed, %SourceFileNoExt% - %SrcFileFolder%.bat`n`n Was found in the`n`n ..\gamelists\%LogDir%\gamelist.xml
			}
			else
			{
			LogDirGameList := StrReplace(LogDirGameList, "</gamelist>", Haystack3)

			FileDelete, ..\gamelists\%LogDir%\gamelist.xml
			FileAppend, %LogDirGameList%, ..\gamelists\%LogDir%\gamelist.xml
				MsgBox, , Congratulations!, %SourceFileNoExt% - %SrcFileFolder%.bat`n`n Was successfully created in the`n`n ..\gamelists\%LogDir%\gamelist.xml
				return
			}
				}
			
	if ErrorLevel = 1
	{
		NewXmlLogDir = 
	(join`r`n
<?xml version="1.0"?>
<gameList>
	<game>
		<path></path>
		<name></name>
	</game>
</gameList>
	)

		Haystack4 := StrReplace(NewXmlLogDir, "</gameList>", Haystack3)
		FileAppend, %Haystack4%, ..\gamelists\%LogDir%\gamelist.xml
			MsgBox, , Congratulations!, %SourceFileNoExt% - %SrcFileFolder%.bat`n`n Was successfully created in the`n`n ..\gamelists\%LogDir%\gamelist.xml
			return
			}
				}
					}
}
ExitApp
	
/*
;;;;;;;;;;;;;;;;;;;;;;; gamelist.xml format ;;;;;;;;;
<?xml version="1.0"?>
<gameList>
	<game>
		<path></path>
		<name></name>
		<desc></desc>
		<image></image>
		<rating></rating>
		<releasedate></releasedate>
		<developer></developer>
		<publisher></publisher>
		<genre></genre>
		<playcount></playcount>
		<lastplayed></lastplayed>
	</game>
	<game>
		<path></path>
		<name></name>
		<desc></desc>
		<image></image>
		<rating></rating>
		<releasedate></releasedate>
		<developer></developer>
		<publisher></publisher>
		<genre></genre>
		<playcount></playcount>
		<lastplayed></lastplayed>
	</game>
</gameList>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;##################### systems.cfg format ################
<systemList>
	<system>
		<name></name>
		<fullname></fullname>
		<path></path>
		<extension></extension>
		<command></command>
		<theme></theme>
	</system>
	<system>
		<name></name>
		<fullname></fullname>
		<path></path>
		<extension></extension>
		<command></command>
		<theme></theme>
	</system>
</systemList>
;##########################################################
*/

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], roeleboele and 388 guests