Jump to content
Sign in to follow this  
jezzjj

Help Me create showing log on editbox

Recommended Posts

jezzjj

Hello,

Im newbie in autoit.

Im confused how to show log of program in edit box...

this is the example :

Posted Image

and another one

Posted Image

Thanks before..

sorry for my bad english >_<

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jezzjj

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)?

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jezzjj

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

Share this post


Link to post
Share on other sites
water

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.

#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 by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jezzjj

Thank you man, that example help me, i will try to develop you script :thumbsup:

Share this post


Link to post
Share on other sites
jezzjj

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

Share this post


Link to post
Share on other sites
water

Does plink run at all? Run expects "The full path of the program".


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jezzjj

edit box just show the verbose until the login screen..

any script can help me solve this problem?

Share this post


Link to post
Share on other sites
jezzjj

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

#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

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jezzjj

ok i will try :thumbsup:

Share this post


Link to post
Share on other sites
jezzjj

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 by jezzjj

Share this post


Link to post
Share on other sites
water

Is this a message from AutoIt or PLINK?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jezzjj

Hello,

im fixing that problem with give this

$STDIN_CHILD + $STDERR_MERGED

but when i successfully log in, the text on editbox blinking and can't scrolling down..

Posted Image

How to stop this blinking, so its can show the forwaded connection

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jezzjj

i have try your script, but its, still auto scroll to top and blinking

this is my full script :

#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

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jezzjj

oh man, its great..its work perfectly!

Thank you for helping me...

this is my full script now ,

#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

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  

×