Sign in to follow this  
Followers 0
sandman

How to update but stop when user inputs?

4 posts in this topic

#1 ·  Posted (edited)

Okay, first I gotta get this out. 300th POST!!!!!!!!!!!!!! AHAHAHAH!!!

Alright.. ahem. I basically want to make an app in which you select a file to open, and once you click the Open button in the dialog, it sets the path to a variable and makes the textbox next to it show that variable it just set.

Now, I have the logic set up for this fine.. the selecting and everything works fine. The problem is, that with the way I have set this up, it will keep setting the variable as the data in the textbox. So if you try to type in a path, it just keeps deleting what you type, because the variables are originally "".

So I need some way for it to still update the textbox with that variable, but let the user type into it. The only way I can think of doing this is to somehow freeze the process of setting the text as soon as it detects the user inputting something, and updating the variable with the new value in the textbox. Is there any way to do this? If so, how?

Here's the code if you want to see my logic so far:

;unDUO by sandman
;requires unrar.exe (from winRAR) in the same folder as this program
;currently only features unDUO.. reDUO must be done manually. see http://sandman.789mb.com for instructions on manually creating a DUO archive.

#include <GUIConstants.au3>

;initial definitions
Global $unloc = ""
Global $undest = ""

$win = GUICreate("DUO", 476, 157, 193, 115)
$tabs = GUICtrlCreateTab(0, 0, 500, 200)
$duotab = GUICtrlCreateTabItem("reDUO (compress)")
$unduotab = GUICtrlCreateTabItem("unDUO (uncompress)")
GUICtrlSetState(-1,$GUI_SHOW)
$unlbl1 = GUICtrlCreateLabel("Archive file location:", 14, 34, 99, 17)
$unloctext = GUICtrlCreateInput("", 114, 34, 260, 21)
$unlocbrowse = GUICtrlCreateButton("Browse...", 384, 34, 75, 25, 0)
$unlbl2 = GUICtrlCreateLabel("Extract destination:", 14, 64, 94, 17)
$undesttext = GUICtrlCreateInput("", 114, 64, 260, 21)
$undestbrowse = GUICtrlCreateButton("Browse...", 384, 64, 75, 25, 0)
$unok = GUICtrlCreateButton("&OK!", 344, 114, 75, 25, 0)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $unlocbrowse
            $unloc = FileOpenDialog("Choose .DUO File", @DesktopDir, "Double-compressed files (*.duo)", 1)
        Case $undestbrowse
            $undest = FileSelectFolder("Please select a destination folder for the extracted .DUO archive.", "", 1)
        Case $unok
            ;TIME TO UNduo!
            ;check things
            
            Local $check1 = FileExists($unloc)
            If $check1 = 0 Then MsgBox(0, "Uh-oh!", "The archive file you chose does not exist. Please verify you entered the right path.")
            Local $check2 = DirGetSize($undest)
            If $check2 = -1 Then
                $nodir = MsgBox(4, "Uh-oh!", "The destination folder you chose does not exist. Would you like to create it?")
                If $nodir = 6 Then                      ;user clicked yes
                    DirCreate($undest)
                ElseIf $nodir = 7 Then
                    ;do nothing
                EndIf
            EndIf
    EndSwitch
    ;make sure the textboxes show the selected file, THIS IS WHERE IT SETS THE TEXTBOX'S VALUE!
    GUICtrlSetData($unloctext, $unloc)
    GUICtrlSetData($undesttext, $undest)
    Sleep(50)
WEnd

Thanks,

SANDMAN!

edit: added code.

My 300th!!! :)

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites



Like this maybe ?

#include <GUIConstants.au3>

;initial definitions
Global $unloc = ""
Global $undest = ""

$win = GUICreate("DUO", 476, 157, 193, 115)
$tabs = GUICtrlCreateTab(0, 0, 500, 200)
$duotab = GUICtrlCreateTabItem("reDUO (compress)")
$unduotab = GUICtrlCreateTabItem("unDUO (uncompress)")
GUICtrlSetState(-1,$GUI_SHOW)
$unlbl1 = GUICtrlCreateLabel("Archive file location:", 14, 34, 99, 17)
$unloctext = GUICtrlCreateInput("", 114, 34, 260, 21)
$unlocbrowse = GUICtrlCreateButton("Browse...", 384, 34, 75, 25, 0)
$unlbl2 = GUICtrlCreateLabel("Extract destination:", 14, 64, 94, 17)
$undesttext = GUICtrlCreateInput("", 114, 64, 260, 21)
$undestbrowse = GUICtrlCreateButton("Browse...", 384, 64, 75, 25, 0)
$unok = GUICtrlCreateButton("&OK!", 344, 114, 75, 25, 0)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $unlocbrowse
            $unloc = FileOpenDialog("Choose .DUO File", @DesktopDir, "Double-compressed files (*.duo)", 1)
            If @error <> 1 Then
                GUICtrlSetData($unloctext, $unloc)
            EndIf   
        Case $undestbrowse
            $undest = FileSelectFolder("Please select a destination folder for the extracted .DUO archive.", "", 1)
            If @error <> 1 Then
                GUICtrlSetData($undesttext, $undest)
            EndIf
        Case $unok
            ;TIME TO UNduo!
            ;check things
           
            Local $check1 = FileExists($unloc)
            If $check1 = 0 Then MsgBox(0, "Uh-oh!", "The archive file you chose does not exist. Please verify you entered the right path.")
            Local $check2 = DirGetSize($undest)
            If $check2 = -1 Then
                $nodir = MsgBox(4, "Uh-oh!", "The destination folder you chose does not exist. Would you like to create it?")
                If $nodir = 6 Then            ;user clicked yes
                    DirCreate($undest)
                ElseIf $nodir = 7 Then
                    ;do nothing
                EndIf
            EndIf
    EndSwitch
WEnd

Cheers

Share this post


Link to post
Share on other sites

Oh, that was bad logic of mine, sorry.. it works fine. Thanks!

:">


[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

We all have our moments .. :) lol

Suggestion for another thing to add to your interface maybe...

Drop a file/folder in the corresponding input box and the file and or path is filled in automatically.

eg:

;unDUO by sandman
;requires unrar.exe (from winRAR) in the same folder as this program
;currently only features unDUO.. reDUO must be done manually. see http://sandman.789mb.com for instructions on manually creating a DUO archive.

#include <GUIConstants.au3>
#include <file.au3>

;initial definitions
Global $unloc = ""
Global $undest = ""

$win = GUICreate("DUO", 476, 157, 193, 115, -1, $WS_EX_ACCEPTFILES)
WinSetOnTop($win,'', 1)
$tabs = GUICtrlCreateTab(0, 0, 500, 200)
$duotab = GUICtrlCreateTabItem("reDUO (compress)")
$unduotab = GUICtrlCreateTabItem("unDUO (uncompress)")
GUICtrlSetState(-1,$GUI_SHOW)
$unlbl1 = GUICtrlCreateLabel("Archive file location:", 14, 34, 99, 17)
$unloctext = GUICtrlCreateInput("", 114, 34, 260, 21)
$unlocbrowse = GUICtrlCreateButton("Browse...", 384, 34, 75, 25, 0)
$unlbl2 = GUICtrlCreateLabel("Extract destination:", 14, 64, 94, 17)
$undesttext = GUICtrlCreateInput("", 114, 64, 260, 21)
$undestbrowse = GUICtrlCreateButton("Browse...", 384, 64, 75, 25, 0)
$unok = GUICtrlCreateButton("&OK!", 344, 114, 75, 25, 0)
GUICtrlSetState(7, $GUI_DROPACCEPTED)
GUICtrlSetState(10, $GUI_DROPACCEPTED)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            Dim $szDrive, $szDir, $szFName, $szExt
            $ps =_PathSplit(@GUI_DragFile, $szDrive, $szDir, $szFName, $szExt)
            If @GUI_DropID = 7 Then
                If $ps[4] = '.duo' Then
                    GUICtrlSetData($unloctext, @GUI_DragFile)
                    If GuiCtrlRead($undesttext) = '' Or FileExists(GuiCtrlRead($undesttext)) <> 1 Then
                        GUICtrlSetData($undesttext, $ps[1] & $ps[2] & 'Uncompressed ' & $ps[3] & '\')
                    EndIf   
                Else
                    GUICtrlSetData($unloctext, '')
                    GUICtrlSetData($undesttext, '')
                Endif   
            ElseIf @GUI_DropID = 10 Then
                If $ps[4] = '' Then
                    GUICtrlSetData($undesttext, $ps[1] & $ps[2] & $ps[3])
                Else
                    GUICtrlSetData($undesttext, '')
                Endif               
            EndIf
        Case $unlocbrowse
            $unloc = FileOpenDialog("Choose .DUO File", @DesktopDir, "Double-compressed files (*.duo)", 1)
            If @error <> 1 Then
                GUICtrlSetData($unloctext, $unloc)
            EndIf   
        Case $undestbrowse
            $undest = FileSelectFolder("Please select a destination folder for the extracted .DUO archive.", "", 1)
            If @error <> 1 Then
                GUICtrlSetData($undesttext, $undest)
            EndIf
        Case $unok
            ;TIME TO UNduo!
            ;check things
           
            Local $check1 = FileExists($unloc)
            If $check1 = 0 Then MsgBox(0, "Uh-oh!", "The archive file you chose does not exist. Please verify you entered the right path.")
            Local $check2 = DirGetSize($undest)
            If $check2 = -1 Then
                $nodir = MsgBox(4, "Uh-oh!", "The destination folder you chose does not exist. Would you like to create it?")
                If $nodir = 6 Then            ;user clicked yes
                    DirCreate($undest)
                ElseIf $nodir = 7 Then
                    ;do nothing
                EndIf
            EndIf
    EndSwitch
WEnd

Cheers.

Edit: Typo's and added WinSetOnTop

Edited by smashly

Share this post


Link to post
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
Sign in to follow this  
Followers 0