Voici le code:
► Afficher le texte
Code : Tout sélectionner
#cs ----------------------------------------------------------------------------
AutoIt Version : 3.3.6.0
Auteur: MonNom
Fonction du Script :
Modèle de Script AutoIt.
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>
#Include <GuiRichEdit.au3>
#include <Constants.au3>
$Form1 = GUICreate("Test",640,340)
GUISetState(@SW_SHOW)
$Console_Edit = _GUICtrlConsole_Create($Form1, 20,20)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
_GUICtrlConsole_Update($Console_Edit)
Sleep(20)
WEnd
; #FUNCTION# ====================================================================================================================
; Name...........: _GUICtrlConsole_Create
; Description ...: Create a Console control
; Syntax.........: _GUICtrlConsole_Create($hWnd ,$iLeft = 0, $iTop = 0, $iWidth = 600, $iHeight = 300, $iBKColor = 0x000000, $iCharColor = 0xC0C0C0, $iStyle = -1, $iExStyle = -1 )
; Parameters ....: $hWnd - Handle to parent or owner window
; $iLeft - Horizontal position of the control
; $iTop - Vertical position of the control
; $iWidth - Control width
; $iHeight - Control height
; $iBKColor - Background color
; $iCharColor - Character color
; $iStyle - Control styles:
; |$ES_AUTOHSCROLL - Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line.
; |$ES_AUTOVSCROLL - Automatically scrolls text up one page when the user presses the ENTER key on the last line.
; |$WS_HSCROLL - Control has horizontal scroll bar
; |$WS_VSCROLL - Control has vertical scroll bar
; |$ES_CENTER - Centers text in a edit control.
; |$ES_LEFT - Aligns text with the left margin.
; |$ES_MULTILINE - Generates a multi-line control (Default)
; |$ES_NOHIDESEL - The selected text is inverted, even if the control does not have the focus.
; |$ES_NUMBER - Allows only digits to be entered into the edit control.
; |$ES_READONLY - Prevents the user from typing or editing text in the edit control.
; |$ES_RIGHT - Right-aligns text edit control.
; |$ES_WANTRETURN - Specifies that a carriage return be inserted when the user presses the ENTER key. (Default)
; |$ES_PASSWORD - Displays an asterisk (*) for each character that is typed into the edit control
;
; |Default: 0
; |Forced : WS_CHILD, $WS_VISIBLE, $WS_TABSTOP unless $ES_READONLY
; $iExStyle - Control extended style. These correspond to the standard $WS_EX_ constants.
; Return values .: Success - Handle to the Console Edit control
; Failure - 0 and sets @error:
; |1 - $hWnd is not a window handle
; |103 - $iLeft is neither a positive number nor zero
; |104 - $iTop is is neither a positive number nor zero
; |105 - $iWidth is neither a positive number nor -1
; |106 - $iHeight is neither a positive number nor -1
; |107 - $iBKColor is not between 0x000000 and 0xFFFFFF (black and white)
; |108 - $iCharColor is not between 0x000000 and 0xFFFFFF (black and white)
; |109 - $iStyle is is neither a positive number nor zero nor -1
; |110 - $iExStyle is is neither a positive number nor zero nor -1
; Author ........: Zehir
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GUICtrlConsole_Create($hWnd, $iLeft = 0, $iTop = 0, $iWidth = 600, $iHeight = 300, $iBKColor = 0x000000, $iCharColor = 0xC0C0C0, $iStyle = -1, $iExStyle = -1 )
If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0)
If Not __GCC_IsNumeric($iLeft, ">=0") Then Return SetError(103, 0, 0)
If Not __GCC_IsNumeric($iTop, ">=0") Then Return SetError(104, 0, 0)
If Not __GCC_IsNumeric($iWidth, ">0,-1") Then Return SetError(105, 0, 0)
If Not __GCC_IsNumeric($iHeight, ">0,-1") Then Return SetError(106, 0, 0)
If Not __GCC_IsNumeric($iBKColor, ">=0,FFFFFF") Then Return SetError(107, 0, 0)
If Not __GCC_IsNumeric($iCharColor, ">=0,FFFFFF") Then Return SetError(108, 0, 0)
If Not __GCC_IsNumeric($iStyle, ">=0,-1") Then Return SetError(109, 0, 0)
If Not __GCC_IsNumeric($iExStyle, ">=0,-1") Then Return SetError(110, 0, 0)
$RichEdit = _GUICtrlRichEdit_Create($hWnd, "", $iLeft, $iTop, $iWidth, $iHeight, $iStyle, $iExStyle)
_GUICtrlRichEdit_SetBkColor($RichEdit, $iBKColor)
_GUICtrlRichEdit_SetCharColor($RichEdit, $iCharColor)
_GUICtrlRichEdit_SetFont($RichEdit, 10, "Courier")
$CMD = Run("cmd.exe", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Return(String($RichEdit) & "|" & String($CMD))
EndFunc
Func _GUICtrlConsole_Update($Console_Edit)
$hWnd = StringSplit($Console_Edit, "|")
$Text = StdoutRead($hWnd[2], False, True)
$Text = BinaryToString($Text, 1)
_GUICtrlRichEdit_InsertText(HWnd($hWnd[1]), $Text)
EndFunc
; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name...........: __GCC_IsNumeric
; Description ...: Does a variable contain a numeric value?
; Syntax.........: __GCC_IsNumeric($vN)
; Parameters ....: $VN - the variable
; $SRange - ">0", ">=0", ">0,-1", ">=0,-1"
; Return values .: Success - True or False
; Failure - can't fail
; Author ........: Chris Haslam (c.haslam)
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func __GCC_IsNumeric($vN, $sRange = "")
If Not (IsNumber($vN) Or StringIsInt($vN) Or StringIsFloat($vN)) Then Return False
Switch $sRange
Case ">0"
If $vN <= 0 Then Return False
Case ">=0"
If $vN < 0 Then Return False
Case ">0,-1"
If Not ($vN > 0 Or $vN = -1) Then Return False
Case ">=0,-1"
If Not ($vN >= 0 Or $vN = -1) Then Return False
Case ">0,FFFFFF"
If Not ($vN > 0 Or $vN < 0xFFFFFF) Then Return False
Case ">=0,FFFFFF"
If Not ($vN >= 0 Or $vN < 0xFFFFFF) Then Return False
EndSwitch
Return True
EndFunc ;==>__GCC_IsNumeric



