Jump to content

Search acting strange


Recommended Posts

#include <Array.au3>
#Include <File.au3>

$Dir = ("C:\Windows\")
$array = _FileListToArray ($Dir,'*',2)
_ArrayDelete ($array,0)
$result = _ArrayToString ($array,"|")
$fixed =StringReplace ($result ,'|','" "' & $Dir)
$Total = ('"' & $Dir & $fixed & '"')
$Search = FileFindFirstFile ($Dir & "*")
MsgBox(0,'',$Total); this is full path of each sub folders found,but not sub\subfolders.


While 1
    $FindNext = FileFindNextFile ($Search)
    $GetExt = StringRight ($FindNext,4)
    If $GetExt = ".ini" Then
    MsgBox(0,'',"Copy " & $FindNext)
EndIf
FileCopy ($Dir & $FindNext & "\*.ini", @DesktopDir,1)
If $FindNext = "" Then ExitLoop
WEnd

Somehow this would MsgBox me but not every single .ini file found so i dont even know what .ini file was copied :(

Also: Is it possible to search to look not just in $Dir and $Dir\subdir, but also in $Dir's sub\subdirs as well ? or any other possible subdirs that may exist under $Dir ? :mellow:

Link to comment
Share on other sites

  • Moderators

dirty,

This seems to work for me:

#include <File.au3>

$Dir = ("C:\Windows\")
$array = _FileListToArray($Dir, '*', 2)

$Total = ""
For $i = 1 To $array[0]
    $Total &= '"' & $Dir & $array[$i] & '" '
Next

MsgBox(0, "", $Total)

$Search = FileFindFirstFile($Dir & "*")

While 1
    $FindNext = FileFindNextFile($Search)
    If StringRight($FindNext, 4) = ".ini" Then
        MsgBox(0, '', "Copy " & $FindNext)
    EndIf
    ;FileCopy($Dir & $FindNext & "\*.ini", @DesktopDir, 1)
    If $FindNext = "" Then ExitLoop
WEnd

FileClose($Search)

I have not bothered copying everything, but I certainly get a MsgBox for every .ini file. :(

I also made the initial code a little shorter.... :mellow:

M23

Edit:

Is it possible to search to look not just in $Dir and $Dir\subdir, but also in $Dir's sub\subdirs as well ? or any other possible subdirs that may exist under $Dir?

Sorry, missed that bit first time round. You would need a recursive search to do that. Use the forum Search function - there are lots on the forum, including some of mine! :lol: Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

It gives same thing, it shows MSGBOX and i would think that its gonna copy file right after but its not.

Very first ini file returned by $FindNext would be copied somewhere along the way but not right after msgbox.

Isn't FileCopy stands after msgbox ? Yes but somehow its not doing its job right or am going crazy :mellow:

Am not saying its not working, it does copy all the INI's from C:\Windows and all C:\Windows\Dir1 but not from C:\Windows\Dir1\Dir2 which is where i need to pull ini files from, its just doing it and i cant track each file with msgbox.

In fact most of copied INI's were not included in msgbox as if they were ignored. Maybe because they were in sub-dir of C:\Windows i dont know.

Link to comment
Share on other sites

  • Moderators

dirty,

Crossed posts - look at the edit above. :mellow:

At present you only get the .ini files in $Dir.

M23

Edit: And if you wonder why it is not copying, have you tried looking at the path you have set as the source? :(

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

its copying, but with strange result.

1st i see is msgbox saying "Copy msdfmap.ini"

But before i press OK, i already got Desktop.ini came from somewhere.

Then i press OK and expecting "msdfmap.ini" to be copied to desktop due to copy being set after msgbox right ? :mellow:

Wrong, its not there till loop exits. :(

MSGBOX told me that i'' have 4 ini files but i end up having 10 :P

But anyway it does the job and it does copy all the INI files. Its not copying ini files from folders like C:\Windows\System32\SomeDir\ as it it can only look into 1 subdire but not all that may exist. Anyway to make it look in all existing subdirs without having to list them manually ?

Thanks for help :lol:

Link to comment
Share on other sites

  • Moderators

dirty,

I get many more .ini files than that.

As I said earlier, if you want to look in subfolders, then you need a recursive search. There are lots on the forum - use the Search function. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I found this:

#Include <File.au3>
$OS = @OSVersion
If $OS = "WIN_7" Then
_search(@UserProfileDir & "\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\")
ElseIf $OS = "WIN_Vista" Then
_search(@UserProfileDir & "\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\")
ElseIf $OS = "WIN_XP" Then
_search(@UserProfileDir & "\My Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\")
EndIf

Func _search($dir)
    Local $ArrTargetItems, $TargetItem
    If (StringRight($dir, 1) = "\") Then $dir = StringTrimRight($dir, 1)
    $ArrTargetItems = _FileListToArray($dir, "*", 0)
    If IsArray($ArrTargetItems) Then
        For $n = 1 To $ArrTargetItems[0]
            $TargetItem = $dir & '\' & $ArrTargetItems[$n]
            If StringInStr(FileGetAttrib($TargetItem), "D") Then ;This is a folder
                _search($TargetItem) ;Call recursively
            Else ;This is a file
                $getext = StringRight ($TargetItem,4)
                If $getext = ".uz3" Then
                    FileCopy ($TargetItem, @DesktopDir,1)
                    Endif
            EndIf
        Next
    EndIf
EndFunc   ;==>_search

It works great but only if this whole code is all i have in my script

I cant add this code to my script, i get errors like

ERROR: syntax error
Func

or if i try to create new file and include it in script, then call its function with _search() i woudl get

ERROR: _search() called with wrong number of args.
_search()

Can you help me to put this function into my code so it would work ?

Here is my code

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=Archive2.ico
#AutoIt3Wrapper_outfile=..\Unreal Compressor.exe
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.4.0
 Author:         [ADP]-Dirty
 Script Function:
    Template AutoIt script.
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GuiStatusBar.au3>
#Include <File.au3>
#include <Sound.au3>

FileInstall ('MMGreetingsComrads.wav', @TempDir & '/MMGreetingsComrads.wav',1)
FileInstall ('MMSeeya.wav', @TempDir & '/MMSeeya.wav',1)
FileInstall ('MMSorry.wav', @TempDir & '/MMSorry.wav',1)
FileInstall ('MMSweet.wav', @TempDir & '/MMSweet.wav')
FileInstall ('MMYouSuckB.wav', @TempDir & '/MMYouSuckB.wav',1)
FileInstall ('MMNice.wav', @TempDir & '/MMNice.wav',1)
FileInstall ('MMSearchAndDestroy.wav', @TempDir & '/MMSearchAndDestroy.wav',1)
FileInstall ('MMGotIt.wav', @TempDir & '/MMGotIt.wav',1)
FileInstall ('MMYouSuckB.wav', @TempDir & '/MMYouSuckB.wav',1)

FileInstall ('MMFinally.wav', @TempDir & '/MMFinally.wav',1)
FileInstall ('MMIHateWhenThatHappens.wav', @TempDir & '/MMIHateWhenThatHappens.wav',1)
FileInstall ('MMINeedSomeBackup.wav', @TempDir & '/MMINeedSomeBackup.wav',1)
FileInstall ('MMLetsRockB.wav', @TempDir & '/MMLetsRockB.wav',1)
FileInstall ('MMSonOfABitch.wav', @TempDir & '/MMSonOfABitch.wav',1)
FileInstall ('01_UT2007_MenuTheme.wav', @TempDir & '/01_UT2007_MenuTheme.wav',1)
FileInstall ('MMNext.wav', @TempDir & '/MMNext.wav',1)
FileInstall ('ut301.wav', @TempDir & '/ut301.wav',1)
FileInstall ('ut200401.wav', @TempDir & '/ut200401.wav',1)
FileInstall ('Empty.wav', @TempDir & '/Empty.wav',1)
FileInstall ('ut2004MenuMusic.wav', @TempDir & '/ut2004MenuMusic.wav',1)

AutoItSetOption("WinTitleMatchMode", 2)
Opt("GUIDataSeparatorChar", @CRLF)
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitFunction") ;About is the function name
TraySetState(1)

;Variables

$OS = @OSVersion
$UT3CompressedFilesXPCooked = (@UserProfileDir & "\My Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\") ;this cvariable only good for UT3. UT2004 uses current system folder
$UT3CompressedFilesXP = (@UserProfileDir & "\My Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\")
$UT3CompressedFilesVistaCooked = (@UserProfileDir & "\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\")
$UT3CompressedFilesVista = (@UserProfileDir & "\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\")
$aboutmessage = ("Unreal compressos V1.0 made by [ADP]-Dirty AKA Dirty_tampon AKA www.adrenalineparty.com" & @CRLF & "File is absolutely free to use/modify by anyone due to it being an open source program coded using AUTOIT programming language." & @CRLF & "Please report any issues to dirty@adrenalineparty.com and or visit my page at www.adrenalineparty.com for updates on this and many other apps." & @CRLF & "Thank you for using my app's")

$Title = @ScriptName ;get script full name including extension
$MsgTitle = StringLeft ($Title,17) ;read only first 17 characters of the filename
$MSGERROR = (@CRLF & "Error " & @ScriptName & " Line #" & @ScriptLineNumber) ;used to make mesage error shorter.

$UT3com = IniRead (@ScriptDir & "\Settings.ini", "UT3","comPath","")
$UT3Output = IniRead (@ScriptDir & "\Settings.ini", "UT3","OutputPath","")
$UT3FileList = (@ScriptDir & "\UT3FileList.txt")
$UT3ReadFileList = FileRead ($UT3FileList)
$UT2004UCC = IniRead (@ScriptDir & "\Settings.ini", "UT2004","UCCPath","")
$UT2004Output = IniRead (@ScriptDir & "\Settings.ini", "UT2004","OutputPath","")
$UT2004FileList = (@ScriptDir & "\UT2004FileList.txt")
$UT2004ReadFileList = FileRead ($UT2004FileList)

;GUI
$MainGUI = GUICreate ("Unreal Compressor.",400,420,-1,-1)
;GUI components
    #Region ;UT3
GUICtrlCreateTab (0,0,400,150)
GUICtrlCreateTabItem("Unreal Tournament 3")
GUICtrlCreateGroup ("",5,25,390,120)
GUICtrlCreateLabel ("Path to UT3.com.",10,40)
$UT3comPathEdit = GUICtrlCreateInput ($UT3com,10,60,320,20)
$UT3ComBrowser = GUICtrlCreateButton ("Browse",330,60,60,20)
GUICtrlSetTip ($UT3ComBrowser, "Press this button to browse for UT3.com file")
GUICtrlCreateLabel ("Output compressed files.",10,90)
$UT3OutputPathEdit = GUICtrlCreateInput ($UT3Output,10,110,320,20)
$UT3OutputBrowser = GUICtrlCreateButton ("Browse",330,110,60,20)
GUICtrlSetTip ($UT3OutputBrowser, "Press this button to browse for folder where to place compressed .uz3 files")
GUICtrlCreateGroup ("",5,150,390,230)
GUICtrlCreateLabel ("File's to compress   ---------->---------->---------->---------->---------->",10,163)
$UT3FileBrowser = GUICtrlCreateButton ("Browse",290,160,100,20)
GUICtrlSetTip ($UT3FileBrowser, "Press this button to browse for files you wish to compress.")
$UT3List = GUICtrlCreateEdit ($UT3ReadFileList,10,180,380,192)
$UT3Compress = GUICtrlCreateButton ("Compress",5,380,100,40)
GUICtrlSetTip ($UT3Compress, "Press this button to start.")
GUICtrlSetFont ($UT3Compress,12)
$UT3Save = GUICtrlCreateButton ("Save File list",105,390,190,20)
GUICtrlSetTip ($UT3Save, "Press this button to save curent UT3 file list.")
$UT3Clear = GUICtrlCreateButton ("Clear",295,380,100,40)
GUICtrlSetTip ($UT3Clear, "Press this button to clear Output and file list.")
GUICtrlSetFont ($UT3Clear,12)
#EndRegion

    #Region ;UT2004
GUICtrlCreateTab (100,0,400,200)
GUICtrlCreateTabItem("Unreal Tournament 2004")
GUICtrlCreateGroup ("",5,25,390,120)
GUICtrlCreateLabel ("UT2004 System folder",10,40)
$UT2004SystemPathEdit = GUICtrlCreateInput ($UT2004UCC,10,60,320,20)
$UT2004UCCBrowser = GUICtrlCreateButton ("Browse",330,60,60,20)
GUICtrlSetTip ($UT2004UCCBrowser, "Press this button to browse for UCC.exe file")
GUICtrlCreateLabel ("Output compressed files.",10,90)
$UT2004OutputPathEdit = GUICtrlCreateInput ($UT2004Output,10,110,320,20)
$UT2004OutputBrowser = GUICtrlCreateButton ("Browse",330,110,60,20)
GUICtrlSetTip ($UT2004OutputBrowser, "Press this button to browse for folder where to place compressed .uz2 files")
GUICtrlCreateGroup ("",5,150,390,230)
GUICtrlCreateLabel ("File's to compress   ---------->---------->---------->---------->---------->",10,163)
$UT2004FileBrowser = GUICtrlCreateButton ("Browse",290,160,100,20)
GUICtrlSetTip ($UT2004FileBrowser, "Press this button to browse for files you wish to compress.")
$UT2004List = GUICtrlCreateEdit ($UT2004ReadFileList,10,180,380,192)
$UT2004Compress = GUICtrlCreateButton ("Compress",5,380,100,40)
GUICtrlSetTip ($UT2004Compress, "Press this button to start.")
GUICtrlSetFont ($UT2004Compress,12)
$UT2004Save = GUICtrlCreateButton ("Save File list",105,390,190,20)
GUICtrlSetTip ($UT2004Save, "Press this button to save curent UT2004 file list.")
$UT2004Clear = GUICtrlCreateButton ("Clear",295,380,100,40)
GUICtrlSetTip ($UT2004Clear, "Press this button to clear Output and file list.")
GUICtrlSetFont ($UT2004Clear,12)
#EndRegion

GUICtrlCreateTabItem("About")    ; end tabitem definition
GUICtrlCreateGroup ("",5,25,390,120)
GUICtrlCreateLabel ($aboutmessage,15,35,380,100)
GUISetState (@SW_SHOW, $MainGUI)
SoundPlay (@TempDir & '/MMGreetingsComrads.wav')
#Region ;UT3 shit goes here
While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
    Case $GUI_EVENT_CLOSE
        SoundPlay (@TempDir & '/MMSeeya.wav',1)
           Exit
;====UT3 Cases
       Case $UT3ComBrowser
           SoundPlay (@TempDir & '/MMSearchAndDestroy.wav',1)
           SoundPlay (@TempDir & '/01_UT2007_MenuTheme.wav')
           $UT3comFileopendialog = FileOpenDialog ("Localte UT3.com", "", "UT3.com (UT3.com)", 1,"",$MainGUI)
           If @error Then
               SoundPlay (@TempDir & '/MMSonOfABitch.wav')
               MsgBox (64, $MsgTitle, "No file selected. Please try again." & $MSGERROR,"",$MainGUI)
               SoundPlay (@TempDir & '/MMSorry.wav')
           Else
               SoundPlay (@TempDir & '/MMNice.wav')
               GUICtrlSetData ($UT3comPathEdit, $UT3comFileopendialog)
               IniWrite (@ScriptDir & "\Settings.ini","UT3","comPath",$UT3comFileopendialog)
           EndIf

       Case $UT3OutputBrowser
           SoundPlay (@TempDir & '/MMSearchAndDestroy.wav')
           $UT3OutputFileopendialog = FileSelectFolder ("Chose output directory to result .uz3 files.",@DesktopDir,1+2+4,'',$MainGUI)
            If @error Then
                SoundPlay (@TempDir & '/MMYouSuckB.wav')
               MsgBox (64, $MsgTitle, "No file selected: Please try again." & $MSGERROR,"",$MainGUI)
               SoundPlay (@TempDir & '/MMIHateWhenThatHappens.wav')
           Else
               SoundPlay (@TempDir & '/MMNice.wav')
               GUICtrlSetData ($UT3OutputPathEdit, $UT3OutputFileopendialog)
               IniWrite (@ScriptDir & "\Settings.ini","UT3","OutputPath",$UT3OutputFileopendialog)
           EndIf

       Case $UT3FileBrowser
           SoundPlay (@TempDir & '/MMSearchAndDestroy.wav')
           $UT3FilesBrowser = FileOpenDialog ("Select files", "", "UT3 files (*.upk;*.u;*.ut3)",1+4)
           If @error Then
               SoundPlay (@TempDir & '/MMYouSuckB.wav')
               MsgBox (64, $MsgTitle, "No files selected: Please try again." & $MSGERROR,"",$MainGUI)
               SoundPlay (@TempDir & '/MMSorry.wav')
           Else
               SoundPlay (@TempDir & '/MMSweet.wav')

                If StringInStr($UT3FilesBrowser, "|") Then; Multiple files selected so transform into array
        $aFileList = StringSplit($UT3FilesBrowser, "|") ; Now add the filenames into the edit, preceded with the path and ending with @CRLF
    For $i = 2 To $aFileList[0]
        GUICtrlSetData($UT3List, '"' & $aFileList[1] &'\' & $aFileList[$i] & ' " ', "1")
    Next
    Else; Only a single file selected, so add directly to the edit
        GUICtrlSetData($UT3List, '"' & $UT3FilesBrowser & '" ',"edit")
    EndIf

           EndIf

       Case $UT3Compress
           $CheckUT3PathToUT3com = GUICtrlRead ($UT3comPathEdit)
           $CheckUT3Output =  GUICtrlRead ($UT3OutputPathEdit)
           $CheckUT3List = GUICtrlRead ($UT3List)
        If $CheckUT3PathToUT3com = "" And $CheckUT3Output > "" And $CheckUT3List > "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UT3.com path is not defined." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT3PathToUT3com > "" And $CheckUT3Output = "" And $CheckUT3List > "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UT3 Output is not defined." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT3PathToUT3com > "" And $CheckUT3Output > "" And $CheckUT3List = "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: No files selected. Select files first and try again." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT3PathToUT3com = "" And $CheckUT3Output = "" And $CheckUT3List > "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UT3.com path and output are not defined." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT3PathToUT3com > "" And $CheckUT3Output = "" And $CheckUT3List = "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UT3 output is not defined and no files selected." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT3PathToUT3com = "" And $CheckUT3Output > "" And $CheckUT3List = "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UT3.com path is not defined and no files selected." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT3PathToUT3com = "" And $CheckUT3Output = "" And $CheckUT3List = "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UT3.com path and output are not defined. No files selected." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT3PathToUT3com > "" And $CheckUT3Output > "" And $CheckUT3List > "" Then
        CompressUT3Function()
        EndIf

       Case $UT3Save
           SoundPlay (@TempDir & '/MMINeedSomeBackup.wav')
           $readList = GUICtrlRead ($UT3List)
           $OpenFileList = FileOpen ($UT3FileList,2+8)
           FileClose ($OpenFileList)
           $WriteUT3FileList = FileWrite ($UT3FileList, $readList)
           MsgBox (64,@ScriptName,"Saved to: " & @ScriptDir & "\UT3FileList.txt","",$MainGUI)

        Case $UT3Clear
           SoundPlay (@TempDir & '/MMGotIt.wav')
           GUICtrlSetData ($UT3OutputPathEdit,"")
           GUICtrlSetData ($UT3List,"")
           $UT3OpenToClear = FileOpen ($UT3FileList,2+8)
           FileClose ($UT3OpenToClear)
           MsgBox (64,@ScriptName,"Cleared")
;===UT2004 Cases===
        Case $UT2004UCCBrowser
           SoundPlay (@TempDir & '/MMSearchAndDestroy.wav',1)
           SoundPlay (@TempDir & '/ut2004MenuMusic.wav')
           $UT2004SystemFolderOpendialog = FileSelectFolder ("Select UT2004 System folder","",'','',$MainGUI)
           If @error Then
               SoundPlay (@TempDir & '/MMSonOfABitch.wav')
               MsgBox (64, $MsgTitle, "No file selected. Please try again." & $MSGERROR,"",$MainGUI)
               SoundPlay (@TempDir & '/MMSorry.wav')
           Else
               SoundPlay (@TempDir & '/MMNice.wav')
               GUICtrlSetData ($UT2004SystemPathEdit, $UT2004SystemFolderOpendialog)
               IniWrite (@ScriptDir & "\Settings.ini","UT2004","UCCPath",$UT2004SystemFolderOpendialog)
           EndIf

       Case $UT2004OutputBrowser
           SoundPlay (@TempDir & '/MMSearchAndDestroy.wav')
           $UT2004OutputFileopendialog = FileSelectFolder ("Chose output directory to result .uz2 files.",@DesktopDir,1+2+4,'',$MainGUI)
            If @error Then
                SoundPlay (@TempDir & '/MMYouSuckB.wav')
               MsgBox (64, $MsgTitle, "No file selected: Please try again." & $MSGERROR,"",$MainGUI)
               SoundPlay (@TempDir & '/MMIHateWhenThatHappens.wav')
           Else
               SoundPlay (@TempDir & '/MMNice.wav')
               GUICtrlSetData ($UT2004OutputPathEdit, $UT2004OutputFileopendialog)
               IniWrite (@ScriptDir & "\Settings.ini","UT2004","OutputPath",$UT2004OutputFileopendialog)
           EndIf

       Case $UT2004FileBrowser
           SoundPlay (@TempDir & '/MMSearchAndDestroy.wav')
           $UT2004FilesBrowser = FileOpenDialog ("Select files", "", "UT2004 files (*.ukx;*.u;*.utx;*.usx;*.uax;*.upl;*.ut2)",1+4)
           If @error Then
               SoundPlay (@TempDir & '/MMYouSuckB.wav')
               MsgBox (64, $MsgTitle, "No files selected: Please try again." & $MSGERROR,"",$MainGUI)
               SoundPlay (@TempDir & '/MMSorry.wav')
           Else

               If StringInStr($UT2004FilesBrowser, "|") Then; Multiple files selected so transform into array
    $aUT2004FileList = StringSplit($UT2004FilesBrowser, "|") ; Now add the filenames into the edit, preceded with the path and ending with @CRLF
    For $i = 2 To $aUT2004FileList[0]
        GUICtrlSetData($UT2004List, '"' & $aUT2004FileList[1] &'\' & $aUT2004FileList[$i] & '" ', "1")
    Next
    Else; Only a single file selected, so add directly to the edit
    GUICtrlSetData($UT2004List, '"' & $UT2004FilesBrowser & '" ',"edit")
EndIf

               SoundPlay (@TempDir & '/MMSweet.wav')
           EndIf

       Case $UT2004Compress
           $CheckUT2004PathToUT2004UCC = GUICtrlRead ($UT2004SystemPathEdit)
           $CheckUT2004Output =  GUICtrlRead ($UT2004OutputPathEdit)
           $CheckUT2004List = GUICtrlRead ($UT2004SystemPathEdit)
        If $CheckUT2004PathToUT2004UCC = "" And $CheckUT2004Output > "" And $CheckUT2004List > "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UCC.exe path is not defined." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT2004PathToUT2004UCC > "" And $CheckUT2004Output = "" And $CheckUT2004List > "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UT2004 Output is not defined." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT2004PathToUT2004UCC > "" And $CheckUT2004Output > "" And $CheckUT2004List = "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: No files selected. Select files first and try again." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT2004PathToUT2004UCC = "" And $CheckUT2004Output = "" And $CheckUT2004List > "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UCC.exe path and output are not defined." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT2004PathToUT2004UCC > "" And $CheckUT2004Output = "" And $CheckUT2004List = "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UT2004 output is not defined and no files selected." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT2004PathToUT2004UCC = "" And $CheckUT2004Output > "" And $CheckUT2004List = "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UCC.exe path is not defined and no files selected." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT2004PathToUT2004UCC = "" And $CheckUT2004Output = "" And $CheckUT2004List = "" Then
            SoundPlay (@TempDir & '/MMYouSuckB.wav')
            MsgBox (16,@ScriptName, "Error: UCC.exe path and output are not defined. No files selected." & $MSGERROR,"",$MainGUI)
        ElseIf $CheckUT2004PathToUT2004UCC > "" And $CheckUT2004Output > "" And $CheckUT2004List > "" Then
        CompressUT2004Function()
        EndIf

       Case $UT2004Save
           SoundPlay (@TempDir & '/MMINeedSomeBackup.wav')
           $readList = GUICtrlRead ($UT2004List)
           $OpenFileList = FileOpen ($UT2004FileList,2+8)
           FileClose ($OpenFileList)
           $WriteUT2004FileList = FileWrite ($UT2004FileList, $readList)
           MsgBox (64,@ScriptName,"Saved to: " & @ScriptDir & "\UT2004FileList.txt","",$MainGUI)

        Case $UT2004Clear
           SoundPlay (@TempDir & '/MMGotIt.wav')
           GUICtrlSetData ($UT2004OutputPathEdit,"")
           GUICtrlSetData ($UT2004List,"")
           $UT2004OpenToClear = FileOpen ($UT2004FileList,2+8)
           FileClose ($UT2004OpenToClear)
           MsgBox (64,@ScriptName,"Cleared")
EndSwitch
WEnd

Global $UT3IsPlaying, $UT3MusicOption, $UT3MusicFunction
Func CompressUT3Function()
    TrayTip ($MsgTitle, "Compressing files. Please wait......",99)
$UT3MusicOnItem = TrayCreateItem("Turn music ON")
TrayItemSetOnEvent(-1,"StartUT3MusicFunction") ;function name
$UT3MusicOFFItem = TrayCreateItem("Turn music OFF")
TrayItemSetOnEvent(-1,"StopUT3MusicFunction") ;function name
TraySetState(1)


    SoundPlay (@TempDir & '/MMLetsRockB.wav',1) ;play sound lets rock
    $UT3compressor = GUICtrlRead ($UT3comPathEdit) ;read $UT3comPathEdit value
    $UT3FilesToCompress = GUICtrlRead ($UT3List) ;read $UT3List calue
    $UT3ResultPath = GUICtrlRead ($UT3OutputPathEdit) ;read $UT3OutputPathEdit value
    $UT3IsPlaying = "No" ;$UT3IsPlaying is set to "NO" but changes by "assign"
GUISetState (@SW_DISABLE,$MainGUI)
TraySetState(4) ; blink tray icon

;Run ($UT3compressor & " compress " & $UT3FilesToCompress)

; "Full path1\file1.ext" "Full path2\file2.ext" Outputs to "%userprofile%\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC"
While 1 ;loop
        $UT3Exist = ProcessExists ("UT3.com") ;check for ur3.com process
    If $UT3Exist > "" And $UT3IsPlaying = "No" Then ;if ut3.com is running and $UT3IsPlaying is "NO" then
        SoundPlay (@TempDir & '/ut301.wav') ;play ut301.wav
        Assign ("UT3IsPlaying", "Yes") ;and change $UT3IsPlaying "NO" to "YES"
    ElseIf $UT3Exist > "" And $UT3IsPlaying = "Yes" Then
        ContinueLoop
    ElseIf $UT3Exist = "" And $UT3IsPlaying = "Yes" Then
        ExitLoop
            ElseIf $UT3Exist = "" And $UT3IsPlaying = "NO" Then
        ExitLoop
    EndIf
WEnd

TrayTip ($MsgTitle, "Moving compressed files to Output" & @CRLF & "Please wait....... ...",99)
;move files from -nohomedir to output folder.
;==================================================================================================================================
;
;
;
;
;
;==================================================================================================================================
MsgBox(0,'','Exit function')
TrayTip ($MsgTitle, "Finished moving compressed files",2)
;end moving files

    TraySetState(8) ;return tray to normal state
    TrayItemDelete ($UT3MusicOnItem) ; Erase $UT3MusicOnItem from tray
    TrayItemDelete ($UT3MusicOFFItem) ;$UT3MusicOFFItem from tray
GUISetState (@SW_ENABLE,$MainGUI) ;enable main GUI
SoundPlay (@TempDir & '/MMFinally.wav') ;play sound Finaly
MsgBox(64,$MsgTitle,"All Done !"); display message all done
EndFunc

Func StopUT3MusicFunction()
    SoundPlay (@TempDir & '/Empty.wav',1)
    Assign ("UT3IsPlaying", "No")
EndFunc

Func StartUT3MusicFunction()
    SoundPlay (@TempDir & '/ut301.wav')
    Assign ("UT3IsPlaying", "Yes")
EndFunc
    #EndRegion

#Region ;UT2004 shit goes here
Global $UT2004IsPlaying, $UT2004MusicOption, $UT2004MusicFunction
Func CompressUT2004Function()
$UT2004MusicOnItem = TrayCreateItem("Turn music ON")
TrayItemSetOnEvent(-1,"StartUT2004MusicFunction") ;function name
$UT2004MusicOFFItem = TrayCreateItem("Turn music OFF")
TrayItemSetOnEvent(-1,"StopUT2004MusicFunction") ;function name
TraySetState(1)

    SoundPlay (@TempDir & '/MMLetsRockB.wav',1) ;play sound lets rock
    $UT2004compressor = GUICtrlRead ($UT2004SystemPathEdit) ;read $UT2004SystemPathEdit value
    $UT2004UCC = ($UT2004compressor & "\UCC.exe")
    $UT2004FilesToCompress = GUICtrlRead ($UT2004List) ;read $UT2004List calue
    $UT2004ResultPath = GUICtrlRead ($UT2004OutputPathEdit) ;read $UT2004OutputPathEdit value
    $UT2004IsPlaying = "No" ;$UT2004IsPlaying is set to "NO" but changes by "assign"
GUISetState (@SW_DISABLE,$MainGUI)
TraySetState(4)

    Run ($UT2004UCC & ' compress ' & $UT2004FilesToCompress)

    While 1 ;loop
        $UT2004Exist = ProcessExists ("UCC.exe") ;check for UCC.exe process
    If $UT2004Exist > "" And $UT2004IsPlaying = "No" Then ;if UCC.exe is running and $UT2004IsPlaying is "NO" then
        SoundPlay (@TempDir & '/ut200401.wav') ;play ut200401.wav
        Assign ("UT2004IsPlaying", "Yes") ;and change $UT2004IsPlaying "NO" to "YES"
    ElseIf $UT2004Exist > "" And $UT2004IsPlaying = "Yes" Then
        ContinueLoop
    ElseIf $UT2004Exist = "" And $UT2004IsPlaying = "Yes" Then
        ExitLoop
    ElseIf $UT2004Exist = "" And $UT2004IsPlaying = "NO" Then
        ExitLoop
    EndIf
WEnd

TrayTip ($MsgTitle, "Moving compressed files to Output" & @CRLF & "Please wait..........",99)

;move files from -nohomedir to output folder.
$UT2004SystemDir = GUICtrlRead ($UT2004SystemPathEdit)
$SearchIn = StringReplace ($UT2004SystemDir,"System","")

$UT2004search = FileFindFirstFile ($SearchIn & "*")
;=======================================
DirCreate ($UT2004ResultPath)
While 1
    $UT2004searchreturn = FileFindNextFile ($UT2004search)
    If  $UT2004searchreturn = "" Then
    ExitLoop
ElseIf  $UT2004searchreturn > "" Then
FileMove ($SearchIn & $UT2004searchreturn & "\*.uz2", $UT2004ResultPath, 1)
EndIf
WEnd
;==========================================================

TrayTip ($MsgTitle, "Finished moving compressed files",2)
;end moving files

    TraySetState(8) ;Stop flashing icon
    TrayItemDelete ($UT2004MusicOnItem) ; Erase $UT2004MusicOnItem from tray
    TrayItemDelete ($UT2004MusicOFFItem) ;$UT2004MusicOFFItem from tray
GUISetState (@SW_ENABLE,$MainGUI) ;enable main GUI
SoundPlay (@TempDir & '/MMFinally.wav') ;play sound Finaly
MsgBox(64,$MsgTitle,"All Done !"); display message all done
EndFunc

Func StopUT2004MusicFunction()
    SoundPlay (@TempDir & '/Empty.wav',1)
    Assign ("UT2004IsPlaying", "No")
EndFunc

Func StartUT2004MusicFunction()
    SoundPlay (@TempDir & '/ut200401.wav')
    Assign ("UT2004IsPlaying", "Yes")
EndFunc
    #EndRegion
Func Exitfunction()
    Exit
EndFunc

I need this function to go betwin here :

;==================================================================================================================================
;
;
;
;
;
;==================================================================================================================================
Edited by dirty
Link to comment
Share on other sites

  • Moderators

dirty,

I see now we are dealing with a game - "Unreal Tournament". :mellow:

Have you read the announcement at the top of the forum? Is your script within the rules set out there? Are you permitted by the rules of this game to use AutoIt to do whatever it is you want to do?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

i am sure i am permited to do what ever i need to do with CMD.

Because command line is long and can be very complicated i had to use autoit. :mellow:

If you know how unreal tournament redirect works then you would not ask me this question., but i can explane.

When you connect to server (Unreal tournament) if server is running custom map or any mods you would normaly download files directly from that server in order to be able to play on it right ?

Well, unreal engine supports redirect and file compression.

Redirect is= server will not let you download files directly from its host, instead it can redirect connected clients to other HTTP servers to download files from there and much faster because they are compressed.

Compression is a command supported by unreal engine games (most of multiplayer unreal engine games do) which is hard to use with CMD.

There are plenty of UT3 or UT2004 compressors out there, but i wanted to make my own. Plus its much faster and it supports both games

This utility is not a modification utility, it simply gives command to game executable to compress files "but command can be very long and complicated"

Anyway. Can you help me put this function into that code i posted ?

I tried everything i could and its still not working.

The script i found (and modified to fit my needs) works on its own but not when i add it to my script.

I noticed i was adding function within function but even if i add it after its still not working and giving me these strange errors like "Wrong arguments or ERROR: missing EndIf.

Func" and lots more.

Edited by dirty
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...