Jump to content
Sign in to follow this  
TonyP

GUICtrlSetData Question

Recommended Posts

TonyP

I'm trying my hand at my first GUI script but I'm having some trouble... What I'm trying to do is use GUICtrlSetData to change the value of a Input field based on a FileOpenDialog selection and also a FileSelect Folder. But I can't seem to get it to work right because it always returns numbers...

Its probably some stupid error on my part, but I've scoured the forums, the help file, and some other user's scripts who use GUICtrlSetData.

Any ideas?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$boxy = GUICreate("Mount WIM file", 411, 141, 192, 124)
$Label1 = GUICtrlCreateLabel("Select the location of the WIM file you would like to mount:", 8, 8, 400, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$FileLocation = GUICtrlCreateInput("C:\", 8, 32, 321, 21)
$Browse = GUICtrlCreateButton("Browse", 336, 30, 57, 23, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Select the folder to mount the file to:", 8, 62, 250, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$FileLocation2 = GUICtrlCreateInput("C:\", 8, 86, 321, 21)
$Browse2 = GUICtrlCreateButton("Browse", 336, 84, 57, 23, $WS_GROUP)
$Mount = GUICtrlCreateButton("Mount", 8, 112, 90, 25, $WS_GROUP)
$Unmount = GUICtrlCreateButton("Unmount", 100, 112, 90, 25, $WS_GROUP)
$Test = GUICtrlCreateButton("Test", 200, 112, 90, 25, $WS_GROUP)
$exit = GUICtrlCreateButton("Exit", 336, 112, 57, 25, $WS_GROUP)
GUISetState(@SW_SHOW)


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Browse
    $WIMFile = FileOpenDialog("Select WIM File", "C:\", "Images (*.wim)", 1 )
    GUICtrlSetData($FileLocation, $WIMFile)
    GUICtrlSetBkColor($FileLocation, 0x00ff00)
Case $Browse2
    $MountFolder = FileSelectFolder("Select Mount Location", "C:\",1 + 4)
    GUICtrlSetData($FileLocation2, $MountFolder)
    GUICtrlSetBkColor($FileLocation2, 0x00ff00)
Case $Test
    MsgBox(0,"Variable Contents","WIMFile has a value of: " & $FileLocation & @LF & "MountFolder has a value of: " & $FileLocation2)
    
Case $Mount
    ShellExecuteWait("C:\temp\ImageX\imagex.exe", "/mountrw " & $FileLocation & " 1 " & $FileLocation2)
    
Case $Unmount
    $Unmountfolder = FileSelectFolder("Select Folder to Unmount", "C:\",1 + 4)
    
Case $exit
    Exit
EndSwitch
WEnd
Edited by xenon2050

Share this post


Link to post
Share on other sites
Valuater

The folder selection works for me Win Xp sp3, Autoit 3.3.0.0

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Yashied
TonyP

Yeah the folder selection works fine and the data in the input shows up fine. However, if you look towards the end of the script:

Case $Test

MsgBox(0,"Variable Contents","WIMFile has a value of: " & $FileLocation & @LF & "MountFolder has a value of: " & $FileLocation2)

Case $Mount

ShellExecuteWait("C:\temp\ImageX\imagex.exe", "/mountrw " & $FileLocation & " 1 " & $FileLocation2)

When I run it those two variables have numerical values instead of the location they are suppose to have.

This is what the message box shows. So the parameters for imagex.exe don't work since it doesn't appear to be returning the correct information...

Posted Image

Share this post


Link to post
Share on other sites
Yashied

Yeah the folder selection works fine and the data in the input shows up fine. However, if you look towards the end of the script:

Case $Test

MsgBox(0,"Variable Contents","WIMFile has a value of: " & $FileLocation & @LF & "MountFolder has a value of: " & $FileLocation2)

Case $Mount

ShellExecuteWait("C:\temp\ImageX\imagex.exe", "/mountrw " & $FileLocation & " 1 " & $FileLocation2)

When I run it those two variables have numerical values instead of the location they are suppose to have.

This is what the message box shows. So the parameters for imagex.exe don't work since it doesn't appear to be returning the correct information...

Posted Image

What are you doing? Look carefully at this lines.

$FileLocation = GUICtrlCreateInput("C:\", 8, 32, 321, 21)

$FileLocation2 = GUICtrlCreateInput("C:\", 8, 86, 321, 21)

Then at this.

ShellExecuteWait("C:\temp\ImageX\imagex.exe", "/mountrw " & $FileLocation & " 1 " & $FileLocation2)

$FileLocation and $FileLocation2 is identifiers (controlID)!

Use GUICtrlRead($FileLocation) and GUICtrlRead($FileLocation2).

Edited by Yashied

Share this post


Link to post
Share on other sites
TonyP

What are you doing? Look carefully at this lines.

$FileLocation = GUICtrlCreateInput("C:\", 8, 32, 321, 21)

$FileLocation2 = GUICtrlCreateInput("C:\", 8, 86, 321, 21)

Then at this.

ShellExecuteWait("C:\temp\ImageX\imagex.exe", "/mountrw " & $FileLocation & " 1 " & $FileLocation2)

$FileLocation and $FileLocation2 is identifiers (controlID)!

Use GUICtrlRead($FileLocation) and GUICtrlRead($FileLocation2).

Ahhh, I see. That did it! Thanks for your help!

Funny thing is, I had just seen some usage of the GUICtrlRead and was trying to figure out if I could use that in this script somehow.

As to what am I doing, I really don't know... ;) Which is why I wanted help... Like I said, first GUI ever... Well besides some C#... ^_^

Edit: For documentation purposes I changed this line:

Case $Mount
    ShellExecuteWait("C:\temp\ImageX\imagex.exe", "/mountrw " & GUICtrlRead($FileLocation) & " 1 " & GUICtrlRead($FileLocation2))
Edited by xenon2050

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  

×