jezzjj Posted May 4, 2013 Share Posted May 4, 2013 Hello,Im newbie in autoit.Im confused how to show log of program in edit box...this is the example :and another oneThanks before..sorry for my bad english >_< Link to comment Share on other sites More sharing options...
water Posted May 4, 2013 Share Posted May 4, 2013 Have a look in the help file for function GUICtrlCreateEdit. The first example shows how to add data. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jezzjj Posted May 4, 2013 Author Share Posted May 4, 2013 hello, im using this code $read=FileRead("C:\Program Files\OpenVPN\log\tes.log") GUICtrlSetData($mylist,$read) and my edit box show the log, but not directly.. i must close the software, and reopen it to see if the log change How to make edit box write the log directly (live)? Link to comment Share on other sites More sharing options...
water Posted May 4, 2013 Share Posted May 4, 2013 What you do is like opening the log file in notepad. You won't see lines added after you opened the file. Does your script start the program that writes to the log file? If yes, is there a way to redirect the log entries to StdOut and read them by your AutoIt script? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jezzjj Posted May 4, 2013 Author Share Posted May 4, 2013 If yes, is there a way to redirect the log entries to StdOut and read them by your AutoIt script?Yes, this is what i mean,so, i need to find the way to redirect it to my script?ok, i will search for it and try Link to comment Share on other sites More sharing options...
water Posted May 4, 2013 Share Posted May 4, 2013 (edited) Here is an example how to do it by running command "Ping". Ping is repeated 20 times when you click on "Start". When you click on "Stop" the output is no longer displayed but the process still runs in the background till it ends. expandcollapse popup#include <GUIConstantsEx.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 434, 192, 124) $Start = GUICtrlCreateButton("Start", 16, 8, 65, 17) $Stop = GUICtrlCreateButton("Stop", 16, 40, 65, 17) $Exit = GUICtrlCreateButton("Exit", 16, 72, 65, 17) $Output = GUICtrlCreateEdit("", 96, 8, 513, 417) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### AdlibRegister("_CheckStop", 50) Global $bRunning = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start If $bRunning = False Then $Pid = Run(@ComSpec & " /c " & 'Ping -n 20 127.0.0.1', "", Default, 2) GUICtrlSetData($Output, "") ; Clear Output $bRunning = True While ProcessExists($Pid) If $bRunning = False Then ExitLoop $Line = StdoutRead($Pid) If StringstripWS($Line, 3) <> "" Then GUICtrlSetData($Output, $Line, 1) Sleep(10) Wend $bRunning = False EndIf Case $Exit Exit EndSwitch WEnd Func _CheckStop() If GUIGetMsg() = $Stop Then $bRunning = False EndFunc Edited May 4, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jezzjj Posted May 4, 2013 Author Share Posted May 4, 2013 Thank you man, that example help me, i will try to develop you script Link to comment Share on other sites More sharing options...
jezzjj Posted May 5, 2013 Author Share Posted May 5, 2013 Hello, i have develop a little of your script, like this While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Start If $bRunning = False Then $Pid = Run(@comspec & ' /c plink -ssh MYSERVER HERE -v -D 1080 ','',@SW_HIDE,7) ;i put -v because it will show verbose, $username = InputBox("username","Enter username") $password = InputBox("password","Enter password",'','*') GUICtrlSetData($Output, "") ; Clear Output $bRunning = True While ProcessExists($Pid) If $bRunning = False Then ExitLoop $Line = StdoutRead($Pid) If StringstripWS($Line, 3) <> "" Then GUICtrlSetData($Output, $Line, 1) Sleep(10) Wend $bRunning = False EndIf Case $Exit Exit EndSwitch WEnd Func _CheckStop() If GUIGetMsg() = $Stop Then $bRunning = False EndFunc but it show nothing on my edit box, please teach me the right script to show the verbose on edit box Thank you before Link to comment Share on other sites More sharing options...
water Posted May 5, 2013 Share Posted May 5, 2013 Does plink run at all? Run expects "The full path of the program". My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jezzjj Posted May 5, 2013 Author Share Posted May 5, 2013 edit box just show the verbose until the login screen.. any script can help me solve this problem? Link to comment Share on other sites More sharing options...
jezzjj Posted May 5, 2013 Author Share Posted May 5, 2013 I found this script and its work, but how to make an authentication prompt like username password before the ssh start login... here the script expandcollapse popup#include #include #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 443, 192, 124) $Edit1 = GUICtrlCreateEdit("", 88, 80, 409, 273) GUICtrlSetData(-1, "Edit1") $Button1 = GUICtrlCreateButton("Button1", 504, 32, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $foo = Run(@ComSpec & " /c plink -ssh MyServerIP -v -D 1080", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line="" While 1 $line &= StdoutRead($foo) If @error Then ExitLoop ;MsgBox(0, "STDOUT read:", $line) GUICtrlSetData($Edit1, $line) Wend While 1 $line &= StderrRead($foo) If @error Then ExitLoop ; MsgBox(0, "STDERR read:", $line) GUICtrlSetData($Edit1, $line) Wend While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
water Posted May 5, 2013 Share Posted May 5, 2013 You can provide userid and passwort by using the "-l user" and "-pw passw" parameters. Add input fields for the userid/password to your GUI or add the InputBox commands before you run Plink. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jezzjj Posted May 5, 2013 Author Share Posted May 5, 2013 ok i will try Link to comment Share on other sites More sharing options...
jezzjj Posted May 5, 2013 Author Share Posted May 5, 2013 (edited) Hello, i found another problem after success connect here is my script $username = InputBox("username","Enter username") $password = InputBox("password","Enter password",'','*') $Port = InputBox ("Port","Enter your port") Local $foo = Run(@ComSpec & " /c plink -ssh MyIP -v -l "&$username&" -pw "&$password&" -P "&$Port&" -D 1080", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) its success to me but in the last line it show Unable to read from standard input: The handle is invalid. How to remove this problem ? Edited May 5, 2013 by jezzjj Link to comment Share on other sites More sharing options...
water Posted May 5, 2013 Share Posted May 5, 2013 Is this a message from AutoIt or PLINK? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jezzjj Posted May 5, 2013 Author Share Posted May 5, 2013 Hello,im fixing that problem with give this$STDIN_CHILD + $STDERR_MERGEDbut when i successfully log in, the text on editbox blinking and can't scrolling down..How to stop this blinking, so its can show the forwaded connection Link to comment Share on other sites More sharing options...
water Posted May 5, 2013 Share Posted May 5, 2013 Remove this line GUICtrlSetState(-1, $GUI_DISABLE)and give it a try. It disables the Edit control but might inhibit scrolling. Or set the edit control to Autoscrolling: $Output = GUICtrlCreateEdit("", 96, 8, 513, 417, BitOr($ES_AUTOVSCROLL, $WS_VSCROLL)) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jezzjj Posted May 6, 2013 Author Share Posted May 6, 2013 i have try your script, but its, still auto scroll to top and blinking this is my full script : expandcollapse popup#include #include #include #include #include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 443, 192, 124) $Edit1 = GUICtrlCreateEdit("", 88, 80, 409, 273, BitOr($ES_READONLY, $WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE)) GUICtrlSetData(-1, "Edit1") $Button1 = GUICtrlCreateButton("Button1", 504, 32, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $username = InputBox("username","Enter username") $password = InputBox("password","Enter password",'','*') $Port = InputBox ("Port","Enter your port") Local $foo = Run(@ComSpec & " /c plink -ssh MYIP -v -l "&$username&" -pw "&$password&" -P "&$Port&" -D 1080", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED) Local $line="" While 1 $line &= StdoutRead($foo) If @error Then ExitLoop ;MsgBox(0, "STDOUT read:", $line) GUICtrlSetData($Edit1, $line) Wend While 1 $line &= StderrRead($foo) If @error Then ExitLoop ; MsgBox(0, "STDERR read:", $line) GUICtrlSetData($Edit1, $line) Wend While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
water Posted May 6, 2013 Share Posted May 6, 2013 Please compare my code with your latest version. For every new line you get from Plink you rewrite the complete output to the edit control. I just add the new line to the already existing text in the control. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jezzjj Posted May 6, 2013 Author Share Posted May 6, 2013 oh man, its great..its work perfectly! Thank you for helping me... this is my full script now , expandcollapse popup#include #include #include #include #include #Include #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 625, 443, 192, 124) $Edit1 = GUICtrlCreateEdit("", 88, 80, 409, 273) GUICtrlSetData(-1, "Edit1") $Button1 = GUICtrlCreateButton("Button1", 504, 32, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $bRunning = False $username = InputBox("username","Enter username") $password = InputBox("password","Enter password",'','*') $Port = InputBox ("Port","Enter your port") If $bRunning = False Then Local $foo = Run(@ComSpec & " /c plink -ssh myip -v -l "&$username&" -pw "&$password&" -P "&$Port&" -D 1080", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED) GUICtrlSetData($Edit1, "") $bRunning = True While ProcessExists($foo) If $bRunning = False Then ExitLoop $Line = StdoutRead($foo) If StringstripWS($Line, 3) <> "" Then GUICtrlSetData($Edit1, $Line, 1) Sleep(10) Wend $bRunning = False EndIf Local $line="" While 1 $line &= StdoutRead($foo) If @error Then ExitLoop ;MsgBox(0, "STDOUT read:", $line) GUICtrlSetData($Edit1, $line) Wend While 1 $line &= StderrRead($foo) If @error Then ExitLoop ; MsgBox(0, "STDERR read:", $line) GUICtrlSetData($Edit1, $line) Wend While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd but now, the editbox not showing the verbose 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