Jump to content

Console transpert in my GUI


Go to solution Solved by Melba23,

Recommended Posts

  • Moderators
Posted

HiNoTora,

This thread shows how to do it - but you need to use a RichEdit control. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 1/1/2014 at 5:50 PM, Melba23 said:

HiNoTora,

This thread shows how to do it - but you need to use a RichEdit control. :)

M23

 

This is my full script

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIEdit.au3>
#include <ScrollBarConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WindowsConstants.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)


Global $hGUI = GUICreate("HiNoTora", 300, 300, -1, -1, -1, $WS_EX_TOPMOST)
$pic = GUICtrlCreatePic('D:\lolol.jpg', 0, 0, 450, 300)
GUICtrlSetState( -1, $GUI_DISABLE)
Global $hEdit = GUICtrlCreateEdit("", 0, 0, 150, 145, BitOR($ES_READONLY, $ES_AUTOVSCROLL))



Global $hButton = GUICtrlCreateButton("Start", 0, 250, 120, 50)
GUICtrlSetColor(-1, 0xFF68000)
GUICtrlSetFont(-1, 20, 800, 0, "Comic Sans Ms")
GUICtrlSetOnEvent($hButton, "_StartProgram")
Global $hButton2 = GUICtrlCreateButton("Pause", 120, 250, 120, 50)
GUICtrlSetColor(-1, 0xFF68000)
GUICtrlSetFont(-1, 20, 800, 0, "Comic Sans Ms")
GUICtrlSetOnEvent($hButton2, "_PauseProgram")

GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
GUISetState(@SW_SHOW, $hGUI)

Global $start = 0, $wait = 1

_WriteToEditBox("Console")

While 1
    If $start = 1 Then _MainProgram()
    Sleep(100)
wend

Func _StartProgram()
      _WriteToEditBox("Starting program")
    $wait = 1
    $start = 1
EndFunc   ;==>_StartProgram

Func _PauseProgram()
    _WriteToEditBox("Pausing program")
    $start = 0
EndFunc   ;==>_Pauserogram

Func _MainProgram()
          
  
      
      



EndFunc   ;==>_MainProgram

Func _WriteToEditBox($sText)
    $iEnd = StringLen(GUICtrlRead($hEdit))
    _GUICtrlEdit_SetSel($hEdit, $iEnd, $iEnd)
    _GUICtrlEdit_Scroll($hEdit, $SB_SCROLLCARET)
    If $iEnd = 0 Then
        GUICtrlSetData($hEdit, @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sText, 1)
    Else
        GUICtrlSetData($hEdit, @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sText, 1)
    EndIf
 EndFunc   ;==>_WriteToEditBox
 

Func Terminate()
    Exit
EndFunc   ;==>Terminate
  • Moderators
Posted

HiNoTora,

  Quote

This is my full script

Excellent. So all you have to do it adapt it as shown in the other thread. You know where we are if you run into problems - but no-one is going to do it all for you. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 1/1/2014 at 5:56 PM, Melba23 said:

HiNoTora,

Excellent. So all you have to do it adapt it as shown in the other thread. You know where we are if you run into problems - but no-one is going to do it all for you. ;)

M23

 

Git it transpert, but now Text wont appere... >.< im bad with autoit 

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIEdit.au3>
#include <ScrollBarConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)


Global $hGUI = GUICreate("HiNoTora", 300, 300, -1, -1, -1, $WS_EX_TOPMOST)
$pic = GUICtrlCreatePic('D:\jujuj.jpg', 0, 0, 450, 300)
GUICtrlSetState( -1, $GUI_DISABLE)


Global $hRichEdit = _GUICtrlRichEdit_Create($hGui, "." & @CRLF & _
"", 0, 0, 300, 100, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL), $WS_EX_TRANSPARENT)


Global $hButton = GUICtrlCreateButton("Start", 0, 250, 120, 50)
GUICtrlSetColor(-1, 0xFF68000)
GUICtrlSetFont(-1, 20, 800, 0, "Comic Sans Ms")
GUICtrlSetOnEvent($hButton, "_StartProgram")
Global $hButton2 = GUICtrlCreateButton("Pause", 120, 250, 120, 50)
GUICtrlSetColor(-1, 0xFF68000)
GUICtrlSetFont(-1, 20, 800, 0, "Comic Sans Ms")
GUICtrlSetOnEvent($hButton2, "_PauseProgram")

GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
GUISetState(@SW_SHOW, $hGUI)

Global $start = 0, $wait = 1

_WriteToEditBox("Console")

While 1
    If $start = 1 Then _MainProgram()
    Sleep(100)
wend

Func _StartProgram()
      _WriteToEditBox("Starting program")
    $wait = 1
    $start = 1
EndFunc   ;==>_StartProgram

Func _PauseProgram()
    _WriteToEditBox("Pausing program")
    $start = 0
EndFunc   ;==>_Pauserogram

Func _MainProgram()
          
  
      
      


EndFunc   ;==>_MainProgram

Func _WriteToEditBox($sText)
    $iEnd = StringLen(GUICtrlRead($hRichEdit))
    _GUICtrlEdit_SetSel($hRichEdit, $iEnd, $iEnd)
    _GUICtrlEdit_Scroll($hRichEdit, $SB_SCROLLCARET)
    If $iEnd = 0 Then
        GUICtrlSetData($hRichEdit, @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sText, 1)
    Else
        GUICtrlSetData($hRichEdit, @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sText, 1)
    EndIf
 EndFunc   ;==>_WriteToEditBox
 

Func Terminate()
    Exit
EndFunc   ;==>Terminate
  • Moderators
Posted

HiNoTora,

[i[GUICtrlSetData only works with controls created by a native function - for UDF create controls you need the UDF function: ;)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIEdit.au3>
#include <ScrollBarConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $start = 0, $wait = 1

Global $hGUI = GUICreate("HiNoTora", 300, 300, -1, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")

$pic = GUICtrlCreatePic('D:\jujuj.jpg', 0, 0, 450, 300)
GUICtrlSetState( -1, $GUI_DISABLE)
Global $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 0, 0, 300, 100, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL), $WS_EX_TRANSPARENT)

Global $hButton = GUICtrlCreateButton("Start", 0, 250, 120, 50)
GUICtrlSetOnEvent($hButton, "_StartProgram")
Global $hButton2 = GUICtrlCreateButton("Pause", 120, 250, 120, 50)
GUICtrlSetOnEvent($hButton2, "_PauseProgram")

GUISetState(@SW_SHOW, $hGUI)

_WriteToEditBox("Console")

While 1
    If $start = 1 Then _MainProgram()
    Sleep(10)
wend

Func _StartProgram()
    _WriteToEditBox("Starting program")
    $wait = 1
    $start = 1
EndFunc   ;==>_StartProgram

Func _PauseProgram()
    _WriteToEditBox("Pausing program")
    $start = 0
EndFunc   ;==>_Pauserogram

Func _MainProgram()
    
EndFunc   ;==>_MainProgram

Func _WriteToEditBox($sText)
    _GUICtrlEdit_AppendText($hRichEdit, @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sText & @CRLF)
EndFunc   ;==>_WriteToEditBox

Func Terminate()
    Exit
EndFunc   ;==>Terminate
All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 1/1/2014 at 6:29 PM, Melba23 said:

HiNoTora,

[i[GUICtrlSetData only works with controls created by a native function - for UDF create controls you need the UDF function: ;)

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <GUIEdit.au3>
#include <ScrollBarConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $start = 0, $wait = 1

Global $hGUI = GUICreate("HiNoTora", 300, 300, -1, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")

$pic = GUICtrlCreatePic('D:\jujuj.jpg', 0, 0, 450, 300)
GUICtrlSetState( -1, $GUI_DISABLE)
Global $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 0, 0, 300, 100, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL), $WS_EX_TRANSPARENT)

Global $hButton = GUICtrlCreateButton("Start", 0, 250, 120, 50)
GUICtrlSetOnEvent($hButton, "_StartProgram")
Global $hButton2 = GUICtrlCreateButton("Pause", 120, 250, 120, 50)
GUICtrlSetOnEvent($hButton2, "_PauseProgram")

GUISetState(@SW_SHOW, $hGUI)

_WriteToEditBox("Console")

While 1
    If $start = 1 Then _MainProgram()
    Sleep(10)
wend

Func _StartProgram()
    _WriteToEditBox("Starting program")
    $wait = 1
    $start = 1
EndFunc   ;==>_StartProgram

Func _PauseProgram()
    _WriteToEditBox("Pausing program")
    $start = 0
EndFunc   ;==>_Pauserogram

Func _MainProgram()
    
EndFunc   ;==>_MainProgram

Func _WriteToEditBox($sText)
    _GUICtrlEdit_AppendText($hRichEdit, @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sText & @CRLF)
EndFunc   ;==>_WriteToEditBox

Func Terminate()
    Exit
EndFunc   ;==>Terminate
All clear? :)

M23

 

 

 XD its good, But there is no mre autoscroll text

  • Moderators
Posted

HiNoTora,

So looking through the _GUICtrlEdit commands, which do you think might be the one to use to get the control to scroll down? And which of the parameters to that function might be the best suited to this case? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 1/1/2014 at 6:53 PM, Melba23 said:

HiNoTora,

So looking through the _GUICtrlEdit commands, which do you think might be the one to use to get the control to scroll down? And which of the parameters to that function might be the best suited to this case? ;)

M23

e.e i have no idea, $ES_AUTOVSCROLL  is only thing where i can read of autoscroll

  • Moderators
Posted

HiNoTora,

No, not the parameters for _GUICtrlEdit_Create - a whole new function: _GUICtrlRichEdit_******. There is one in the Help file specifically designed to scroll the control if you take the effort to look. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

  On 1/1/2014 at 7:03 PM, Melba23 said:

HiNoTora,

No, not the parameters for _GUICtrlEdit_Create - a whole new function: _GUICtrlRichEdit_******. There is one in the Help file specifically designed to scroll the control if you take the effort to look. ;)

M23

sry, but i dont get it :(

  • Moderators
Posted (edited)

HiNoTora,

I am not going to spoon-feed you this one. ;)

Open the Help file and put "_GUICtrlEdit" into the "Index" search box - a whole slew of _GUICtrlEdit_***** functions appear in the results pane. Look through them and see which of them might have something to do with scrolling. Let me know when you have done that and what function(s) you have found. :)

M23

Edit: And when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unneccessarily. ;)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

  • Moderators
  • Solution
Posted

HiNoTora,

Ah, but it is! :)

Use this function to scroll the edit after each line is written: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScrollbarConstants.au3>
#include <GuiRichEdit.au3>
#include <GuiEdit.au3>

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $start = 0, $wait = 1

Global $hGUI = GUICreate("HiNoTora", 300, 300, -1, -1, -1, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")

;$pic = GUICtrlCreatePic("M:\Program\Au3 Scripts\Images\Melba23.jpg", 0, 0, 450, 300)
;GUICtrlSetState( -1, $GUI_DISABLE)
Global $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 0, 0, 300, 100, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL), $WS_EX_TRANSPARENT)

Global $hButton = GUICtrlCreateButton("Start", 0, 250, 120, 50)
GUICtrlSetOnEvent($hButton, "_StartProgram")
Global $hButton2 = GUICtrlCreateButton("Pause", 120, 250, 120, 50)
GUICtrlSetOnEvent($hButton2, "_PauseProgram")

GUISetState(@SW_SHOW, $hGUI)

_WriteToEditBox("Console")

While 1
    If $start = 1 Then
        _MainProgram()
    EndIf
    Sleep(10)
wend

Func _StartProgram()
    _WriteToEditBox("Starting program")
    $wait = 1
    $start = 1
EndFunc   ;==>_StartProgram

Func _PauseProgram()
    _WriteToEditBox("Pausing program")
    $start = 0
EndFunc   ;==>_Pauserogram

Func _MainProgram()

EndFunc   ;==>_MainProgram

Func _WriteToEditBox($sText)
    _GUICtrlEdit_AppendText($hRichEdit, @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sText & @CRLF)
    _GUICtrlEdit_Scroll($hRichedit, $SB_LINEDOWN) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndFunc   ;==>_WriteToEditBox

Func Terminate()
    Exit
EndFunc   ;==>Terminate
M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted
Func _WriteToEditBox($sText)
   
 $iEnd = StringLen(GUICtrlRead($hRichEdit))
 _GUICtrlEdit_Scroll($hRichEdit, $SB_SCROLLCARET)    
 _GUICtrlEdit_AppendText($hRichEdit, @HOUR & ":" & @MIN & ":" & @SEC & " - " & $sText & @CRLF)
 If $iEnd = 0 Then
GUICtrlSetData($hRichEdit, @HOUR & ":" & @MIN & ":" & @SEC & " :-: " & $sText, 1)
    Else
        GUICtrlSetData($hRichEdit, @CRLF & @HOUR & ":" & @MIN & ":" & @SEC & " :-: " & $sText, 1)
    EndIf
 
EndFunc   ;==>_WriteToEditBox
 
 
 
Tahats what i did, nd didnt get to work, tryng to see what u did
Posted

Man ur genius thank you so much of your help and time =)

I've been messing with the font to, but thats another thing i cant find. im having bit to darck image on background and fontcolour is black..

Dunno if i can figure it out.

  • Moderators
Posted

HiNoTora,

So search in the Help file for a _GUICtrlRichEdit_***** function which changes the colour of the text - there is one there if you look. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted
Global $lblMsg, $hRichEdit
   GUICtrlRichEdit_SetCharColor($hRichEdit, "304050")
 
D:Autoit examplesGood UI.au3 (16) : ==> Variable used without being declared.:
 
:S
Posted (edited)

yey i did change font :D

And a colour 

_GUICtrlRichEdit_SetCharColor($hRichEdit, "304050")
Func _StartProgram()
    _GUICtrlRichEdit_SetFont($hRichEdit, 12, "Comic Sans Ms")
      _WriteToEditBox("Starting program")
     
    $wait = 1
    $start = 1
EndFunc   ;==>_StartProgram

Func _PauseProgram()
   _GUICtrlRichEdit_SetFont($hRichEdit, 12, "Comic Sans Ms")
    _WriteToEditBox("Pausing program")
        $start = 0
EndFunc   ;==>_Pauserogram
Edited by HiNoTora
  • Moderators
Posted

HiNoTora,

See - you can do it when you try. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

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