Sign in to follow this  
Followers 0
iverson_est

Variable into GUICtrlCreateEdit text field

9 posts in this topic

Hey!

Can i make somehow the GUICtrlCreateEdit text field read a variable.

I want to make it read from an ini file or txt file.

Basically an idea would be smthing like that

$file = FileOpen("test.txt", 0)

$chars = FileRead($file)

GUICtrlCreateEdit ( $chars, etc... )

But the text field reads the $ as a normal letter. I am quick learner, if you help me ;D The helpfile was quite chinese for me.

Share this post


Link to post
Share on other sites



iverson_est,

You were pretty close, but you also need a GUI to display the edit control:

#include <GUIConstantsEx.au3>

$sString = FileRead(@ScriptFullPath)

GUICreate("Test", 500, 500)

GUICtrlCreateEdit($sString, 10, 10, 300, 300)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously - it is not that difficult, certainly easier than Chinese (unless you are Chinese of course!). You might also want look at the excellent tutorials that you will find here and here.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thank you!

I am not a total noobie, tho :( I had the GUI and everything. My original script was like that:

GuiCreate("Sample GUI", 400, 400)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)
Local $vari= FileRead( "test.txt")
GuiCtrlCreateEdit("$vari", 10, 110, 150, 70)


GuiCtrlCreateDate("", 5, 280, 200, 20)
GuiCtrlCreateLabel("(Date control expands into a calendar)", 10, 305, 200, 20)

GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)


GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

I had not included the <GUIConstantsEx.au3> and variable was in "". Got it solved for now, thank you >_<

Share this post


Link to post
Share on other sites

I got a question kind of related to this... Is there anyway to 'GuiCtrlRead($EditLINE)'.... What I mean by that, read line by line in an Edit (Or even better, I would like to read line by line in a List, but seems as though you have to click on the item in there to get its value).... But yea, kinda like FileReadLine, but somehow read each line in the Edit? O.O

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I got a question kind of related to this... Is there anyway to 'GuiCtrlRead($EditLINE)'.... What I mean by that, read line by line in an Edit (Or even better, I would like to read line by line in a List, but seems as though you have to click on the item in there to get its value).... But yea, kinda like FileReadLine, but somehow read each line in the Edit? O.O

$iCount = ControlCommand($title, "", $myedit, "GetLineCount", "")
For $i = 0 to $iCount ;; This might have to be 1 To $iCount
    $sResult = ControlCommand($title, "", $myedit, "GetLine", $i)
    MsgBox(0, "Result", $sResult, 3)
Next

EDIT: Or

#Include <GuiEdit.au3>
$iCount = _GUICtrlEdit_GetLineCount($myedit)
For $i = 0 to $iCount ;; This might have to be 1 To $iCount
    $sResult = _GUICtrlEdit_GetLine($myedit, $i)
    MsgBox(0, "Result", $sResult, 3)
Next

EDIT 2: Corrected above code.

If you need it, getting the text for a list is just as simple.

#include<GUIListBox.au3>
$iCount = _GUICtrlListBox_GetCount($myedit)
For $i = 0 To $icount
   $sResult = _GUICtrlListBox_GetText($myEdit, $i)
   MsgBox(0, "Result", $sResult, 3)
Next
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

$iCount = ControlCommand($title, "", $myedit, "GetLineCount", "")
For $i = 0 to $iCount ;; This might have to be 1 To $iCount
    $sResult = ControlCommand($title, "", $myedit, "GetLine", $i)
    MsgBox(0, "Result", $sResult, 3)
Next

EDIT: Or

#Include <GuiEdit.au3>
$iCount = _GUICtrlEdit_GetLineCount($myedit)
For $i = 0 to $iCount ;; This might have to be 1 To $iCount
    $sResult = _GUICtrlEdit_GetLine($myedit, $i)
    MsgBox(0, "Result", $sResult, 3)
Next

EDIT 2: Corrected above code.

If you need it, getting the text for a list is just as simple.

#include<GUIListBox.au3>
$iCount = _GUICtrlListBox_GetCount($myedit)
For $i = 0 To $icount
   $sResult = _GUICtrlListBox_GetText($myEdit, $i)
   MsgBox(0, "Result", $sResult, 3)
Next

Aha, did not see that functions, thank you very much >_<. I suppose theres no hiding function (from me xD) that reads lines of a List? :S

Share this post


Link to post
Share on other sites

Aha, did not see that functions, thank you very much >_< . I suppose theres no hiding function (from me xD) that reads lines of a List? :S

Well if you are talking about a list control as in GUICtrlCreateList(), that's what the 3rd block of code does. If you are talking about a list as in GUICtrlCreateListView() there is a ListView UDF in the help file too.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Well if you are talking about a list control as in GUICtrlCreateList(), that's what the 3rd block of code does. If you are talking about a list as in GUICtrlCreateListView() there is a ListView UDF in the help file too.

LOL... my bad, I overlooked your 3rd block of code, and thought it was the same thing (I thought it was odd that it looked exactly the same as the other one lol xD).

Thanks, sorry for my noobess >_<.

Share this post


Link to post
Share on other sites

LOL... my bad, I overlooked your 3rd block of code, and thought it was the same thing (I thought it was odd that it looked exactly the same as the other one lol xD).

Thanks, sorry for my noobess >_< .

No problem.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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