Jump to content
Sign in to follow this  
LetsAuto

assigning information from a .txt to a disabled input box

Recommended Posts

LetsAuto

Hi! So im at a point where I can comfortably use the Koda interface, and i can manage my programs.. BUT..... i need information from a log file to be displayed in a disabled input box (so that way the user has no control over the content that is displayed)..... how does one do this?

Note: I already have the .txt file, with the user input.. that part was easy.. but i just dont know how to retrieve it.. its going to be something with FileReadLine(), yes?

Share this post


Link to post
Share on other sites
BrewManNH

$sText = FileRead("your text file")

GUICtrlSetData($yourEditControl, $sText)


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
LetsAuto

so this....

$sText = FileRead("C:IanLogTestbuildTester.log")
GUICtrlSetData($productDestination, $sText)

... should be displaying whatever is in that .log file, correct?

Share this post


Link to post
Share on other sites
BrewManNH

Yes, if there's something in the text file, and if $productDestination is the handle to your control it should display it in the control.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
JScript

Yes, if there's something in the text file, and if $productDestination is the handle to your control it should display it in the control.

I think you meant the control identifier (controlID), not handle, I'm right?

JS


http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
BrewManNH

Either is appropriate, depending on how the control was created.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
BrewManNH

Whatever, to me the 2 are practically interchangable. It's all semantics anyways. To be 100% correct, you'd be right, but I've seen most people rarely differentiate between the 2.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
LetsAuto

so either way, if that log file has the word "fish" on the first line.. the product destination label should be displaying the word "fish"?

Share this post


Link to post
Share on other sites
LetsAuto

In the au3 script that has the user input data this is my code...

$text = InputBox("Build Data", "Please input product build number.")

FileDelete("C:IanLogTestbuildTester.log")
$logdir = "C:IanLogTest"
$logfile = $logdir & "buildTester.log"
$screenshot = 0
$module = "Initial"
$file = FileOpen($logfile, 9)
;;;;works and saves variable to log;;;;
FileWriteLine($file, $text)
FileWriteLine($file, @CRLF)
FileClose($file)

... and then to call that text i use...

$sText = FileReadLine("C:IanLogTestbuildTester.log")
 GUICtrlSetData($productDestination, $sText)

... and nothing happens.. after running the code the label remains empty

Share this post


Link to post
Share on other sites
BrewManNH

What label? I don't see any label in that code. Perhaps you should post a working script that demonstrates the problem rather than bits and pieces that have nothing to do with the issue you're asking about.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
LetsAuto

#include 
#include 
#include 
#include 
#include 
#include 

; Force close with CTRL-Q
HotKeySet("^q", "stop")
Func stop()
Exit
EndFunc ;==>stop

#Region ### START Koda GUI section ### Form=
$Form = GUICreate("Finalizing Installation", 508, 488, -1245, 273)
$titleLabel = GUICtrlCreateLabel("Setup Information", 32, 40, 132, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$finishButton = GUICtrlCreateButton("&Finish", 208, 416, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$backButton = GUICtrlCreateButton("&Back", 304, 416, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$brandLabel = GUICtrlCreateLabel("Brand:", 48, 128, 51, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$brandDestination = GUICtrlCreateInput("", 152, 120, 81, 28)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$buildLabel = GUICtrlCreateLabel("Product Build:", 48, 88, 102, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$productDestination = GUICtrlCreateInput("", 152, 80, 81, 28)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetState(-1, $GUI_DISABLE)
$functionsList = GUICtrlCreateList("", 48, 192, 145, 149)
GUICtrlSetState(-1, $GUI_DISABLE)
$functionsLabel = GUICtrlCreateLabel("Selected Functions:", 48, 160, 145, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$ipList = GUICtrlCreateList("", 304, 192, 145, 149)
GUICtrlSetState(-1, $GUI_DISABLE)
$ipLabel = GUICtrlCreateLabel("Selected IPs:", 304, 160, 98, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$buildButton = GUICtrlCreateButton("Change Build and Brand", 256, 92, 193, 41)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$functionsButton = GUICtrlCreateButton("Change Functions", 48, 344, 145, 33)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$ipButton = GUICtrlCreateButton("Change IPs", 304, 344, 145, 33)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
$cancelButton = GUICtrlCreateButton("Cancel", 400, 416, 75, 33)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $buildButton
Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautoWizardstep1.au3")
$handle = WinGetHandle("Untitled - AutoIt", "")
WinClose($handle)
Case $functionsButton
Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautoWizardstep2.au3")
$handle = WinGetHandle("Untitled - AutoIt", "")
WinClose($handle)
Case $ipButton
Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautoWizardstep3.au3")
$handle = WinGetHandle("Untitled - AutoIt", "")
WinClose($handle)
Case $backButton
Run("C:Program FilesAutoIt3AutoIt3.exe F:AutoIt3testingsautoWizardstep3.au3")
$handle = WinGetHandle("Untitled - AutoIt", "")
WinClose($handle)
Case $finishButton
$handle = WinGetHandle("Untitled - AutoIt", "")
WinClose($handle)
Case $cancelButton
$handle = WinGetHandle("Untitled - AutoIt", "")
WinClose($handle)
EndSwitch
WEnd


$sText = FileReadLine("C:IanLogTestbuildTester.log")
GUICtrlSetData($productDestination, $sText)

.... sorry i used koda to make the interface. everything works (buttons are the only thing so far), they wont work because all of the file paths are set to my computer, as you could figure out..

Share this post


Link to post
Share on other sites
LetsAuto

Never mind guys, I figured it out after playing with a message box.. i just had to specify in the #Region stuff from koda where to put it... thanks for all your help!

Share this post


Link to post
Share on other sites
LetsAuto

here is what i did...

$text = FileReadLine("C:IanLogTestbuildTester.log")
MsgBox("text read", "Reads a log file", $text)

... intead of using the...

[color=#000000][font=monospace][size=2][background=rgb(248, 248, 248)] [/background][/size][/font][/color][url="http://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetData.htm"][color=#000090]GUICtrlSetData[/color][/url][color=#FF8000][font=monospace][size=2]([/size][/font][/color][color=#5A5A5A][font=monospace][size=2]$productDestination[/size][/font][/color][color=#FF8000][font=monospace][size=2],[/size][/font][/color][color=#000000][font=monospace][size=2][background=rgb(248, 248, 248)] [/background][/size][/font][/color][color=#5A5A5A][font=monospace][size=2]$sText[/size][/font][/color][color=#FF8000][font=monospace][size=2])[/size][/font][/color]

...line, I just made a practice program with a message box and just applied it to the actual GUI script i posted previously

Share this post


Link to post
Share on other sites
JScript

Whatever, to me the 2 are practically interchangable. It's all semantics anyways. To be 100% correct, you'd be right, but I've seen most people rarely differentiate between the 2.

Run this example:

#include <GUIConstantsEx.au3>

_Example()

Func _Example()
    Local $iCtrlID, $hCtrlHwnd

    GUICreate("My GUI Button", 320, 240) ; will create a dialog box that when displayed is centered

    $iCtrlID = GUICtrlCreateButton("Ctrl ID", 50, 100, 100)

    $hCtrlHwnd = GUICtrlCreateButton("Ctrl Hwnd", 170, 100, 100)
    $hCtrlHwnd = GUICtrlGetHandle($hCtrlHwnd)

    GUISetState() ; will display an  dialog box with 2 button

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $iCtrlID
                MsgBox(4096, "ControlID", "Control ID: " & $iCtrlID)
            Case $hCtrlHwnd
                MsgBox(4096, "Handle", "Control handle: " & $hCtrlHwnd)
        EndSwitch
    WEnd
EndFunc   ;==>Example

That's what I tell...

JS


http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites
BrewManNH

Look, I KNOW the difference between a handle and a control ID, I don't need your explanation. I explained what I meant and if you're determined to "win" this, then fine, you've won, you're the greatest programmer ever, now drop it.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
nitekram

OK - I will ask the question then, as I ran @JScript and nothing happened when I pressed the handle button. If I comment out this line

$hCtrlHwnd = GUICtrlGetHandle($hCtrlHwnd) it works fine. I guess I do not know the difference.

Not trying to add fuel to the fire - just want to know.


All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Share this post


Link to post
Share on other sites
BrewManNH

It's because the script, as written, doesn't work.

This works as it's supposed to.

#include <GUIConstantsEx.au3>

_Example()

Func _Example()
Local $iCtrlID, $hCtrlHwnd

GUICreate("My GUI Button", 320, 240) ; will create a dialog box that when displayed is centered

$iCtrlID = GUICtrlCreateButton("Ctrl ID", 50, 100, 100)

$CtrlHwnd = GUICtrlCreateButton("Ctrl Hwnd", 170, 100, 100)
$hCtrlHwnd = GUICtrlGetHandle($CtrlHwnd)

GUISetState() ; will display an dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $iCtrlID
MsgBox(4096, "ControlID", "Control ID: " & $iCtrlID)
Case $CtrlHwnd
MsgBox(4096, "Handle", "Control handle: " & $hCtrlHwnd)
EndSwitch
WEnd
EndFunc ;==>Example

p.s. It helps to know the difference in how functions work with control handles versus control IDs. The original script won't work because he wrote it trying to get it to action on a handle and that won't work with GUIGetMsg, you need the CID.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

  • Similar Content

    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
      I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
      #include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
      Thanks!
    • reida
      By reida
      Hello. On page there is mail address. How to keep in a text file this address? 
      It is page and email
      https://alpari.com/
      info@alpari.com
    • nacerbaaziz
      By nacerbaaziz
      hi dears, i have an question please if you can help me.
      i maked an program to do some functions
      and this program works with the global hot keys
      i added an option to the users to change the hot keys
      when i searched about how to do that i found this UDF
      GUIHotkey.au3
      http://www.autoitscript.com/forum/index.php?showtopic=107965
      but the problem here that this UDF cant be detect the win key.
      can you help me to add it, or if there are any others UDFSS wich do that work please give me some.
      i hope that my question is clear for you.
      thanks in advance
    • Silas
      By Silas
      Hello everyone,
      I have a radio button ($Radio1), which I want to disable as soon as another one get's checked (Radio5). (The system fails if the radio button i'm troubling with also gets checked).
      I know how to disable him:
      If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_DISABLE) Then GUICtrlSetState($Radio5, 128) But if i try to enable $Radio5 again, after $Radio1 isn't checked anymore, it fails:
      If GUICtrlRead($Radio1)=Not 1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_ENABLE) Then GUICtrlSetState($Radio5, 64)  
      Anyone knows why?
×