Jump to content

Double Gui @ScriptDir Problem?


Recommended Posts

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.

#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?

 

Link to comment
Share on other sites

You have the root directory of FileSelectFolderset set to @ScriptDir, is that what you want. You might also want to re-evaluate_FindDefault() as you're using StringTrimRight but not assigning it to anything. Could you prove a more stripped down example minus the file install and file move.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Yes this file bases where to send the file from @scriptdir

So does it not trim the off then if its not named?, it seems to work fine

Or is it bad coding to do it that way?

The only time it goes bad is after the file install because the file it installs seems to inherit the original @scriptdir folder position instead of the new one that it does for itself.

If you close the file thats copied and run it again without the first gui it works perfectly, its only when the two follow each other it misdirects @scriptdir

Link to comment
Share on other sites

No, see this line...

StringTrimRight($sDefault, 1);make sure backslash is NOT on the end

you're trimming it but not re-assigning it back to $sDefault. The reason it works is because by default the backslash isn't appended in the function FileSelectFolder. I'm not able to re-produce your problem. Could you perhaps whittle it down to a simpler example?

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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...