Jump to content

Recommended Posts

Posted

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 >_<

  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

Posted (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.

#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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

Posted

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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
Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

Is this a message from AutoIt or PLINK?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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
Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...