Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Double Gui @ScriptDir Problem?

$
0
0

At least i think it is..

 

I have a Gui like this that basically helps the user finds the folder he needs and adds the file to it, mainly so they dont have to create duplicate files all over the place.

AutoIt         
#include <Misc.au3> #include <GUIConstantsEx.au3> ;>>>>>>>>>>>>>>>>>>>>>>>> Global $GUI_Start, $button1, $label1, $image1, $label5, $sSetDefault Global $Gui = _Gui() DirCreate(@TempDir & "\Sup") FileInstall(".\compile\Uploader.exe", @TempDir & "\Sup\", 1) ;>>>>>>>>>>>>>>>>>>>>>>>> Func _Gui()     $GUI_Start = GUICreate("Packer", 300, 110, -1, -1)     ;>>>>>>>>>>>>>>>>>>>>>>>>     $label1 = GUICtrlCreateLabel("Select the folder where the files are stored" & @CRLF & _             "     that you wish to prepare", 20, 10, 600)     GUICtrlSetFont(-1, 9, 550, -1, "Tahoma")     ;>>>>>>>>>>>>>>>>>>>>>>>>     $button1 = GUICtrlCreateButton(" Choose Folder ", 70, 55, 160, 35)     GUICtrlSetFont(-1, 10, 550, -1, "Tahoma")     ;>>>>>>>>>>>>>>>>>>>>>>>> ;~  $image1 = GUICtrlCreatePic(@TempDir & "\" & "chim_logo.jpg", 420, 230, 104, 25)     ;>>>>>>>>>>>>>>>>>>>>>>>>     GUISetState() EndFunc   ;==>_Gui Local $nMsg = 0 While 1     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $button1             $sSetDefault = _FindDefault() ;~          ConsoleWrite($sSetDefault & @CRLF)             Sleep(100)             FileMove(@TempDir & "\Sup\Uploader.exe", $sSetDefault & "\Uploader.exe", 9)             Run($sSetDefault & "\Uploader.exe")             Sleep(500)             WinClose("Simple Packer")     EndSwitch WEnd Func _FindDefault()     #region $sFindDefault     Local $sDefault = ""     $sDefault = FileSelectFolder("Choose a drive.", @ScriptDir) ;"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"     If @error = 1 Then ; User cancel or X close error check         MsgBox(48, "Cancelled", "Cancelled By User", 4)         $sDefault = ""     EndIf     If DriveSpaceTotal($sDefault) = 0 Then ; Drive contains no files error check         MsgBox(48, "Source Error", "There Is No Data On That Drive", 4)         $sDefault = ""     EndIf     Local $sDefaultEnd = StringRight($sDefault, 1)     If $sDefaultEnd = "" Then         $sDefault = ""     ElseIf $sDefaultEnd = "\" Then         StringTrimRight($sDefault, 1);make sure backslash is NOT on the end     EndIf ;~  ConsoleWrite("Default = " & $sDefault & @CRLF) ;######## Checking ########     Return $sDefault     #endregion $sFindDefault EndFunc   ;==>_FindDefault

Its quite simple like the above

 

the problem im having is the second GUi is started from the first but seems to inherit the @scriptDir characteristics from the first GUi

 

Then when it starts moving files around and doing stuff it fails and creates files and folders where the first GUI is located, im guessing because the original @ScriptDir is still in memory so it uses that.

 

Is there a way to make the second GUI use its own position of @ScriptDir not use the in memory one?

 

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>