hezi Posted August 25, 2010 Share Posted August 25, 2010 hi, i'm trying write script that take lines from file and display them on read only editbox ( GUICtrlCreateEdit). the script is working for me but i have some issues: when i dont use delay (sleep) the gui flicks and if i use it i cant close the GUI unless i click the close button several times. what i'm doing wrong? any idea? any suggestions? any sample code you can provide? thanks in Advance. Link to comment Share on other sites More sharing options...
JohnOne Posted August 26, 2010 Share Posted August 26, 2010 Difficult to say without example code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
hezi Posted August 31, 2010 Author Share Posted August 31, 2010 Difficult to say without example code. thanks for the reply. #include <GuiEdit.au3> #include <GuiStatusBar.au3> #include <GuiConstantsEx.au3> ;Opt('MustDeclareVars', 1) ;$Debug_Ed = True ; Check ClassName being passed to Edit functions, set to True and use a handle to another control to see it work #include <Constants.au3> #Include <File.au3> #Include <Array.au3> FileDelete("c:\temp\session.txt") RunWait("c:\temp\plink.exe -pw q -ssh root@x.x.x.x find / -type f -size +2000k -exec ls -lh {} \; |grep xxx >c:\temp\session.txt") _Main() Func _Main() Local $hEdit, $hGUI Local $sFile = "C:\tmp\session.txt" ;Local $aPartRightSide[4] = [120, 248, 378, -1] ; Create GUI $hGUI = GUICreate("Edit Set Read Only", 600, 100) $hEdit = GUICtrlCreateEdit("", 1, 1, 599, 100) GUISetState() ; Set Margins _GUICtrlEdit_SetMargins($hEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10) While 1 if GUIGetMsg() = $GUI_EVENT_CLOSE then exit sleep(100) _GUICtrlEdit_SetText($hEdit, FileRead($sFile)) ; Set Read Only _GUICtrlEdit_SetReadOnly($hEdit, True) if GUIGetMsg() = $GUI_EVENT_CLOSE then exit ;sleep(100) WEnd GUIDelete() EndFunc ;==>_Main im very new in this so forgive me if the code is mess... basically i want to make gui that display the results i get from linux machine (it should update every 1-2 seconds). if you have better way to do that i will be glad to know. Thanks in advance. Link to comment Share on other sites More sharing options...
iamtheky Posted August 31, 2010 Share Posted August 31, 2010 (edited) since the only 'IF' you have is $GUI_EVENT_CLOSE make that the only item in the loop, set the text just prior _GUICtrlEdit_SetMargins($hEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10) _GUICtrlEdit_SetText($hEdit, FileRead($sFile)) ; Set Read Only _GUICtrlEdit_SetReadOnly($hEdit, True) While 1 if GUIGetMsg() = $GUI_EVENT_CLOSE then exit WEnd GUIDelete() EndFunc ;==>_Main Edited August 31, 2010 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
hezi Posted August 31, 2010 Author Share Posted August 31, 2010 since the only 'IF' you have is $GUI_EVENT_CLOSE make that the only item in the loop, set the text just prior _GUICtrlEdit_SetMargins($hEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10) _GUICtrlEdit_SetText($hEdit, FileRead($sFile)) ; Set Read Only _GUICtrlEdit_SetReadOnly($hEdit, True) While 1 if GUIGetMsg() = $GUI_EVENT_CLOSE then exit WEnd GUIDelete() EndFunc ;==>_Main thanks! but if i do what you suggested the gui will not updated with new data. i need him to display new data. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now