Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   AutoIt (http://forum.oszone.net/forumdisplay.php?f=103)
-   -   [решено] Элемент EDIT (http://forum.oszone.net/showthread.php?t=135026)

morgan1991 17-03-2009 20:38 1066612

Элемент EDIT
 
Скажите пожалуйста как можно считать самую нижнюю строчку элемента Edit?

proxy 17-03-2009 21:02 1066629

Код:

ControlCommand('название окна', 'текст окна', controlID, 'GetLine', ControlCommand('название окна', 'текст окна', controlID, 'GetLineCount'))
Код:

#region: - Option
    Opt('MustDeclareVars',      1)
    Opt('TrayIconDebug',        1)
    Opt('TrayIconHide',        0)
    Opt('SendKeyDelay',        1)
#endregion

#region: - Global

    Global  $iPid, $hHwd
    Global  $sGetEditLine
#endregion

$iPid = Run('notepad.exe')
While 1
    $hHwd = _ProcessGetWindow($iPid, 1)
    If IsHWnd($hHwd) Then ExitLoop
WEnd


ControlSetText($hHwd, '', '[CLASS:Edit; INSTANCE:1]', 'Строка 1' & @CRLF & 'Строка 2' & @CRLF & 'Строка 3')
Sleep(5)
$sGetEditLine = ControlCommand($hHwd, '', '[CLASS:Edit; INSTANCE:1]', 'GetLine', ControlCommand($hHwd, '', '[CLASS:Edit; INSTANCE:1]', 'GetLineCount'))

MsgBox(64, 'Результат', 'Последняя строчка: ' & @CRLF & @CRLF & $sGetEditLine)

ProcessClose($iPid)

Func _ProcessGetWindow($iPID, $iRet=-1)
    Local $aWinList = WinList()
    Local $aRet[2]

    If IsString($iPID) Then $iPID = ProcessExists($iPID)

    For $i = 1 To UBound($aWinList)-1
        If WinGetProcess($aWinList[$i][1]) = $iPID Then
            $aRet[0] = $aWinList[$i][0] ;Title
            $aRet[1] = $aWinList[$i][1] ;WinHandle

            If $iRet = 0 Then Return $aRet[0]
            If $iRet = 1 Then Return $aRet[1]

            Return $aRet
        EndIf
    Next

    Return
SetError(1, 0, $aRet)
EndFunc


morgan1991 17-03-2009 21:32 1066651

proxy, спасибо конечно, но я имел ввиду считать отсюда:
Код:

GUICtrlCreateEdit ( "text", left, top [,width [,height [,style [,exStyle]]] )

proxy 17-03-2009 22:03 1066676

практически так же:

Код:

#region: - Include
    #include <GUIConstantsEx.au3>
    #Include <GuiEdit.au3>
    #include <WindowsConstants.au3>
#endregion

#region: - Option

    Opt('GUIOnEventMode',      1)
    Opt('MustDeclareVars',      1)
    Opt('TrayIconDebug',        1)
    Opt('TrayIconHide',        0)
#endregion

#region: - Global

    Global  $hWinMain, $hEdit
#endregion

#region: GUI

    $hWinMain = GUICreate('Test', 400, 400, -1, -1)
        GUISetOnEvent($GUI_EVENT_CLOSE,    '_Pro_Exit')

    $hEdit = GUICtrlCreateEdit('Строка 1' & @CRLF & 'Строка 2' & @CRLF & 'Строка 3', 10, 10, 200, 200)

    GUICtrlCreateButton('Получить последную строчку', 10, 250, 200, 25)
        GUICtrlSetState(-1, $GUI_FOCUS+$GUI_DEFBUTTON)
            GUICtrlSetOnEvent(-1, '_Get_Edit_String')
#endregion

#region: - После создания всех GUI

    GUISetState(@SW_SHOW, $hWinMain)
#endregion

#region: - Sleep, Exit

While 1
    Sleep(10)
WEnd

Func
_Pro_Exit()
    Exit
EndFunc

#endregion

Func _Get_Edit_String()
    MsgBox(64, 'Результат', 'Последняя строчка: ' & @CRLF & @CRLF &  _GUICtrlEdit_GetLine($hEdit, _GUICtrlEdit_GetLineCount($hEdit)-1))
EndFunc


morgan1991 17-03-2009 23:52 1066767

спасибо


Время: 14:42.

Время: 14:42.
© OSzone.net 2001-