Sign in to follow this  
Followers 0
Draygoes

guictrlread wont read a gui control

6 posts in this topic

I have tried everything that I can to get this to work. It Just wont. I have a file save function and I have it write to a gui control, an imput. Problem is, the text in the input box cant seem to be read unless its put in by the user!!!

Heres my code:

#include<GUIConstants.au3>
$gui = GUICreate("Build A Batch Workshop", 500,250)
GUISetState()



$stuff = GUICtrlCreateLabel( "Please save your compiled script. (Must end with .exe extention.)", 0, 0, 500, 18)

$path = GUICtrlCreateInput( "", 0, 50, 350, 18)

$button = GUICtrlCreateButton( "Select", 370, 50, 100, 18)  

$finish = GUICtrlCreateButton( "Finish", 190, 150, 125, 50)



While 1 
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $button
       $var = FileSaveDialog( "Save Compiled Exe as: ", @DesktopDir, "Executible Files (*.exe)", 16)
       GUICtrlSetData( $path, $var)
   Case $msg = $finish
     $data2 =  GUICtrlRead( $path, 0 )
       FileWrite( "path.lne", $data2)
       
       
       Exit
    EndSelect
WEnd
Exit

If the user enters text into the box, it works fine. It writes the text to file exactly like I tell it to. But, when I add text using guictrlsetdata, It wont read it.

Can anyone fix please???

thx


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites



Dude, that works...

Share this post


Link to post
Share on other sites

Nahuel is right - it works.

Maybe you can't find your saved file (path.lne) complete then the whole path - e.g. c:\path.lne


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Thats not what I want it to do though. I want it to create a file in the same directory that the scipt is in, then write into the file the exact path that the user selected when they hit select. The problem is, it creates the file in the path that the user selected.

I hope that I explained that right lol.


Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 

Share this post


Link to post
Share on other sites

But...it does what you want it to do... :)

you should do what enaiman said. Something like this:

#include<GUIConstants.au3>
$gui = GUICreate("Build A Batch Workshop", 500,250)
GUISetState()
$stuff = GUICtrlCreateLabel( "Please save your compiled script. (Must end with .exe extention.)", 0, 0, 500, 18)
$path = GUICtrlCreateInput( "", 0, 50, 350, 18)
$button = GUICtrlCreateButton( "Select", 370, 50, 100, 18)  
$finish = GUICtrlCreateButton( "Finish", 190, 150, 125, 50)
While 1 
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $button
       $var = FileSaveDialog( "Save Compiled Exe as: ", @DesktopDir, "Executible Files (*.exe)", 16)
       GUICtrlSetData( $path, $var)
   Case $msg = $finish
    $data2 =  GUICtrlRead( $path, 0 )
    FileWrite( @ScriptDir&"\path.lne", $data2)
    Exit
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok try this;

Case $msg = $finish
       $data2 =  GUICtrlRead($path)
       $file = FileOpen(@ScriptDir & "\path.lne", 2)
       FileWrite(@ScriptDir & "\path.lne", $data2)
       FileClose($file)
Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

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