Jump to content
Sign in to follow this  
imani

_GUICtrlEditGetLine does not get the entire line

Recommended Posts

imani

Run the following code and you will see that _GUICtrleditGetLine does not get the entire line. I need to find why. Any solution to display the whole line

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET
Dim $s_text = "AutoIt v3 is a freeware BASIC-like scripting language" & @CRLF & _
          "designed for automating the Windows GUI." & @CRLF & _
          "It uses a combination of simulated keystrokes," & @CRLF & _
          "mouse movement and window/control manipulation" & @CRLF & _
          "in order to automate tasks in a way not possible" & @CRLF & _
          "or reliable with other languages (e.g. VBScript and SendKeys)."
          
          
Run("Notepad")
WinWait("Untitled - Notepad")
$myedit = ControlGetHandle("Untitled - Notepad", "", "Edit1")
ControlSetText("Untitled - Notepad","", "Edit1", $s_Text)
MsgBox(0,"Line 6", _GUICtrlEditGetLine($myedit, 6))

Share this post


Link to post
Share on other sites
imani

Run the code and if any one knows please tell me how to get the whole line using the _GUIctrlEditGetLine command. The whole line should be like this

Starting the process to remove Virus

but it is getting only

Starting the process to re

why?

#include<GUIEDIT.au3>
#include<GUIConstants.au3>
Global $mainwin,$edit
$mainwin= GUICreate("Ravmon Removal Tool", 270,275)
GuiSetIcon(@WorkingDir & "\TemporaryFiles\readme_files\icon.ico", 0)
GUISwitch($mainwin)
$Button_1 = GuiCtrlCreateButton("Remove Virus From Hard disk", 40, 20, 170, 30)
GUICtrlSetState($Button_1,$GUI_FOCUS)
$Button_2 = GuiCtrlCreateButton("Remove Virus From USB Drive", 40, 60, 170, 30)
$Button_3 = GuiCtrlCreateButton("Restore Windows Default Settings", 40, 100, 170, 30)
$exit = GuiCtrlCreateMenu ("File")
$exititem = GUICtrlCreateMenuitem ("Exit",$exit)
$helpmenu = GuiCtrlCreateMenu ("Help")
$readmeitem = GuiCtrlCreateMenuitem ("Readme",$helpmenu)
$aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu)
$edit = GUICtrlCreateEdit("",0,150,270,80,BitOR($ES_READONLY,$WS_VSCROLL),$WS_EX_STATICEDGE)
$b2 = GUICtrlCreateButton("Save Log to file", 150, 232, 100, 20)
    $vtime = @HOUR
    $date = String(@MON & '/' & @MDAY & '/' & @YEAR)
GUISetState ()     
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            GUICtrlSetData($edit, "Starting Date " & $date & @CRLF, "append")
            GUICtrlSetData($edit, ftime($vtime)&"Starting the process to remove Virus" & @CRLF, "append")
            GUICtrlSetData($edit, ftime($vtime)&"Virus Removed successfully" & @CRLF, "append")
            GUICtrlSetData($edit, "Time Taken to Remove Virus  Milliseconds" & @CRLF, "append")
            GUICtrlSetData($edit,ftime($vtime)&"Deleted the SVHOST.exe file from Windows Directory"&@CRLF,"append")
            GUICtrlSetData($edit,ftime($vtime)&"Deleted the mdm.exe file from Windows Directory"&@CRLF,"append")
            GUICtrlSetData($edit,ftime($vtime)&"Enabled Command Prompt"&@CRLF,"append")
        Case $msg = $Button_2   

        Case $msg = $Button_3

        Case $msg = $exititem

            ExitLoop
        Case $msg = $aboutitem

        Case $msg = $readmeitem
        Case $msg = $b2
                MsgBox(0,'', _GUICtrlEditGetLine($edit, 2))         

    EndSelect
Wend

Func ftime($vtime)
    If $vtime < 12 Then
        Return String($vtime & ':' & @MIN & ' AM ')
    ElseIf $vtime = 12 Then
        Return String($vtime&':' & @MIN&' PM ')
    ElseIf $vtime > 12 Then
        Return String($vtime-12&':' & @MIN&' PM ')
    EndIf
EndFunc   ;==>ftime
Edited by imani

Share this post


Link to post
Share on other sites
BrettF

Using the example in the helpfile (edited)

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET
Dim $vtime = @HOUR
Dim $date = String(@MON & '/' & @MDAY & '/' & @YEAR)
Dim $s_text = "Starting Date " & $date & @CRLF & _
            ftime($vtime)&"Starting the process to remove Virus" & @CRLF & _
            ftime($vtime)&"Virus Removed successfully" & @CRLF & _
            "Time Taken to Remove Virus  Milliseconds" & @CRLF & _
            ftime($vtime)&"Deleted the SVHOST.exe file from Windows Directory"& @CRLF & _
            ftime($vtime)&"Deleted the mdm.exe file from Windows Directory"& @CRLF & _
            ftime($vtime)&"Enabled Command Prompt"&@CRLF

;================================================================
; Example 1 - Get Line using AutoIt Control
;================================================================
GUICreate("Edit Get Line", 392, 254)

$myedit = GUICtrlCreateEdit($s_text, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $WS_VSCROLL, $WS_HSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$Btn_GET = GUICtrlCreateButton("Get Line 3", 150, 130, 90, 40, $BS_MULTILINE)

GUISetState()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Btn_GET
            Local $line = _GUICtrlEditGetLine($myedit, 3)
                If @error == $EC_ERR Then
                GUICtrlSetData($Status, "Line: Invalid")
            Else
                GUICtrlSetData($Status, "Line: " & $line)
            EndIf
    EndSelect
WEnd
GUIDelete()

Func ftime($vtime)
    If $vtime < 12 Then
        Return String($vtime & ':' & @MIN & ' AM ')
    ElseIf $vtime = 12 Then
        Return String($vtime&':' & @MIN&' PM ')
    ElseIf $vtime > 12 Then
        Return String($vtime-12&':' & @MIN&' PM ')
    EndIf
EndFunc ;==>ftime

EDIT: Also it might be better to use _GUICtrlEdit_AppendText (Its in the beta)

Edited by Bert

Share this post


Link to post
Share on other sites
GaryFrost

There is a bug in the realease, most people didn't notice it, it has been fixed in the beta "_GUICtrlEdit_GetLine"


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
BrettF

This is weird. It seems to only return 53 bytes (I assume it is bytes)?

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET, $total
Dim $s_text = "AutoIt v3 is a freeware BASIC-like scripting language" & @CRLF & _
          "designed for automating the Windows GUI." & @CRLF & _
          "It uses a combination of simulated keystrokes," & @CRLF & _
          "mouse movement and window/control manipulation" & @CRLF & _
          "in order to automate tasks in a way not possible" & @CRLF & _
          "or reliable with other languages (e.g. VBScript and SendKeys)."
Run("Notepad")
WinWait("Untitled - Notepad")
$myedit = ControlGetHandle("Untitled - Notepad", "", "Edit1")
ControlSetText("Untitled - Notepad","", "Edit1", $s_Text)

For $i = 1 to 6
    $total = StringSplit ( _GUICtrlEditGetLine($myedit, $i), "")
    MsgBox(0,"Line " & $i, "Line Text: "& _GUICtrlEditGetLine($myedit, $i) & @CRLF & "Bytes: " & _GUICtrlEditLineLength ($myedit, $i) & @CRLF & "Line Size: " & $total[0])
Next

@Garry (if you are reading)- Has something been changed in the Beta to make it do this? Is there a know limit?

EDIT: On Gary's advice in your other thread, use _GUICtrlEdit_GetLine

Edited by Bert

Share this post


Link to post
Share on other sites
BrettF

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  

×