Jump to content

assigning information from a .txt to a disabled input box


LetsAuto
 Share

Recommended Posts

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?

Link to comment
Share on other sites

$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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

#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..

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
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
 Share

×
×
  • Create New...