Jump to content
Sign in to follow this  
radboi22

Showing a Notepad (Etc..) File in the GUI?

Recommended Posts

radboi22

Hi, Im new to AUTOIT obviously, I was wondering if anyone would Depart some information on how to put a Text file into the GUI, And will it update in REAL TIME as information is added to this file?

Also the program im working with has A Remote option, IP/PORT, how do I Manipulate this, and how can I draw information from this? (Parsing, etc...)

THANK YOU =D

Share this post


Link to post
Share on other sites
SxyfrG

Hi, Im new to AUTOIT obviously, I was wondering if anyone would Depart some information on how to put a Text file into the GUI, And will it update in REAL TIME as information is added to this file?

Also the program im working with has A Remote option, IP/PORT, how do I Manipulate this, and how can I draw information from this? (Parsing, etc...)

THANK YOU =D

Not too sure about the IP/PORT stuff and remote options etc, but i can certainly help with your text file problem :)

This little snippet of code below will create a GUI with an edit control in it (like notepads) and update it every second with the contents of the file you want to read

#NoTrayIcon ;Don't show an icon in the system tray
#include <GUIConstants.au3> ;include the GUI constants so we can create a GUI
Opt("OnEventMode",1) ;Set the 'OnEventMode' to 1 so we can use functions such as GUICtrlSetOnEvent ( $Control , "Function" )

$GUI = GUICreate ( "File Read" , 500 , 500 ) ;Create the initial GUI, 500 pixels wide by 500 pixels high

$Edit = GUICtrlCreateEdit ( "" , 0 , 0 , 500 , 500 ) ;Create our edit control to hold the text

GUISetOnEvent ( $GUI_EVENT_CLOSE , "ExitFunc" ) ;Set the function for the close button

GUISetState ( @SW_SHOW ) ;Show the GUI with the control we've just created

;----------------------
;This is what YOU need to edit. Just change the variables data to the filepath of the file you want to read and you're set to go :)
$FileDir = "Path here" ;Set the variable to hold the path of the file to be read
;----------------------

;====
While 1 ;while the program is idle, do whatever is in this loop

      Sleep ( 1000 ) ;sleep for 1 second (1000 milliseconds = 1 second). You can change this to anything above 10 milliseconds, anything less will cause the CPU usage to spike to 50%+
      $File = FileOpen ( $FileDir , 0 ) ;Open the file for reading
      GUICtrlSetData ( $Edit , FileRead ( $File ) ) ;Read contents of the file and set the edit control's data as that
      FileClose ( $File ) ;close the file

      ;Anything else you want to do in this loop goes in here

Wend
;====

Func ExitFunc()
      ;Any stuff you want to do before the program exits
      Exit ;Exit the program, DUH :P
EndFunc ;==> ExitFunc

My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

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  

×