WilliamasKumeliukas Posted September 9, 2020 Share Posted September 9, 2020 (edited) Hi, I created a script to act like the Console of SciTE with an RichEdit control to see my ConsoleWrite and I haven't found anything in help file to block Tab key from selecting RichEdit control. My problem is that it will auto select whole text inside RichEdit and on next ConsoleWrite it will change the color for the whole text. How do I block TAB key from jumping on RichEdit and select whole text? Yes, I am aware of: many unused #include, i've set this as default when creating new .au3 file so I don't have to add #include to use some code (unused includes are removed before compiling script) there might be some code being repeated, feel free to suggest or add it in the code. here is my script: expandcollapse popup#include <EditConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Date.au3> #include <array.au3> #include <GuiRichEdit.au3> #include <misc.au3> #include <AutoItConstants.au3> #include <FontConstants.au3> Global $cw, $hConsole, $sTxt HotKeySet("{enter}", "capture") HotKeySet("{ESC}", "_Exit") gui() Func _Exit() Exit EndFunc Func GUI() Global $GUI = GUICreate("Console testing", 615, 436, 192, 124) Global $Console = _GUICtrlRichEdit_Create($GUI, "", 93, 216, 449, 169, BitOR($ES_MULTILINE,$WS_VSCROLL,$ES_AUTOVSCROLL)) _GUICtrlRichEdit_SetCharColor($Console, 0xFFFFFF) _GUICtrlRichEdit_SetBkColor($Console, 0x000000) _GUICtrlRichEdit_SetReadOnly($Console, True) _GUICtrlRichEdit_HideSelection($Console,True) _GUICtrlRichEdit_SetFont($Console, 12, "Consolas") Global $Label1 = GUICtrlCreateLabel("ConsoleWrite normal", 81, 32, 457, 21, $SS_CENTER) Global $cNormal = GUICtrlCreateInput("", 81, 64, 457, 21) Global $cWarning = GUICtrlCreateInput("", 81, 152, 457, 21) Global $Label2 = GUICtrlCreateLabel("ConsoleWrite Warning", 81, 120, 457, 21, $SS_CENTER) Global $button = GUICtrlCreateButton("test", 544, 64, 44, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cNormal Case $cWarning Case $button capture() EndSwitch WEnd EndFunc Func capture() If StringLen(GUICtrlRead($cNormal)) >= 1 Then _GUICtrlRichEdit_SetCharColor($Console, 0xFFFFFF) c(GUICtrlRead($cNormal)) GUICtrlSetData($cNormal,"") _GUICtrlRichEdit_HideSelection($Console,True) ControlFocus("", "", $cNormal) ElseIf StringLen(GUICtrlRead($cWarning)) >= 1 Then _GUICtrlRichEdit_SetCharColor($Console, 0x000FFF) cw(GUICtrlRead($cWarning)) GUICtrlSetData($cWarning,"") _GUICtrlRichEdit_HideSelection($Console,True) ControlFocus("", "", $cWarning) EndIf EndFunc Func ConsoleWriteGUI(Const ByRef $hConsole, Const $sTxt) _GUICtrlRichEdit_InsertText($Console, $sTxt) _GUICtrlRichEdit_SetFont($Console, 12, "Consolas") EndFunc Func c($cw) ; @@@@ CONSOLE NORMAL TEXT @@@@ ConsoleWrite(_NowTime() & " -=-> " & $cw & @CRLF) _GUICtrlRichEdit_SetCharColor($Console, 0xFFFFFF) ConsoleWriteGUI($Console, _NowTime() & " =-> " & $cw & @CRLF ) EndFunc Func cw($cw) ; @@@@ CONSOLE INTENDED FOR WARNING @@@@@ _GUICtrlRichEdit_SetCharColor($Console, 0x000FFF) ConsoleWrite(@CRLF & @CRLF & ">>>>>>>>>>>>@@@@@@ WARNING @@@@@@<<<<<<<<<<<<" & @CRLF & @CRLF & _NowTime() & " =-> " & $cw & @CRLF & @CRLF & _ ">>>>>>>>>>>>@@@@@@ WARNING @@@@@@<<<<<<<<<<<<" & @CRLF & @CRLF) ConsoleWriteGUI($GUI, @CRLF & @CRLF & ">>>>>>>>>>>>@@@@@@ WARNING @@@@@@<<<<<<<<<<<<" & @CRLF & @CRLF & _NowTime() & " =-> " & $cw & @CRLF & @CRLF & _ ">>>>>>>>>>>>@@@@@@ WARNING @@@@@@<<<<<<<<<<<<" & @CRLF & @CRLF) EndFunc Best regards, WilliamasKumeliukas Edited September 9, 2020 by WilliamasKumeliukas typos and question missing Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this: Spoiler #1. I am a native French speaker and learned English mainly from chatting with others players in online games. #2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor. ~WilliamasKumeliukas Link to comment Share on other sites More sharing options...
Dan_555 Posted September 9, 2020 Share Posted September 9, 2020 (edited) I have an idea, but i do not know if it will work. Why don't you just make another hotkey function assigned to the tab ? Then you could switch in between the wanted gui elements, by forcing a focus on them and skipping the RichEdit box. Each call of the function should change the focus. After a bit of testing, this seems to work: Func capture() _GUICtrlRichEdit_GotoCharPos($Console, -1) Edited September 9, 2020 by Dan_555 WilliamasKumeliukas 1 Some of my script sourcecode Link to comment Share on other sites More sharing options...
WilliamasKumeliukas Posted September 9, 2020 Author Share Posted September 9, 2020 (edited) 35 minutes ago, Dan_555 said: I have an idea, but i do not know if it will work. Why don't you just make another hotkey function assigned to the tab ? Then you could switch in between the wanted gui elements, by forcing a focus on them and skipping the RichEdit box. Each call of the function should change the focus. I've aldready think about this but I was hoping for a way to change its state like $GUI_DISABLE (GUICtrlSetState doesnt work on RichEdit) because I also have the problem to make RichEdit non clickable, I tried adding a label with topmost and $WS_EX_TRANSPARENT attribute and same dimension as RichEdit but still click through it 😕 Regards, ~WilliamasKumeliukas Edited September 9, 2020 by WilliamasKumeliukas Underline activated randomly Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this: Spoiler #1. I am a native French speaker and learned English mainly from chatting with others players in online games. #2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor. ~WilliamasKumeliukas Link to comment Share on other sites More sharing options...
pugh Posted September 10, 2020 Share Posted September 10, 2020 I am reading and writing from my Android phone, so I haven't compiled this or even fully viewed/understood it. What is the purpose of the richedit since you don't want to be able to tab to it or click on it? If you don't need to interact with it in that way, perhaps a label field would work better? I am no great programmer but I like to tinker and I've used autoit for quite some time now Link to comment Share on other sites More sharing options...
Dan_555 Posted September 10, 2020 Share Posted September 10, 2020 (edited) I see, you quoted the non strikethrough text, that may mean that you have missed the solution ? @WilliamasKumeliukas ? I had the last answer on editing mode, when i thought to try something ... Edited September 10, 2020 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
WilliamasKumeliukas Posted September 10, 2020 Author Share Posted September 10, 2020 5 hours ago, Dan_555 said: I see, you quoted the non strikethrough text, that may mean that you have missed the solution ? @WilliamasKumeliukas ? I had the last answer on editing mode, when i thought to try something ... @Dan_555, Yes I quoted your message before you edit it, I tried your solution and indeed it seems to work so far Thank you 8 hours ago, pugh said: I am reading and writing from my Android phone, so I haven't compiled this or even fully viewed/understood it. What is the purpose of the richedit since you don't want to be able to tab to it or click on it? If you don't need to interact with it in that way, perhaps a label field would work better? I am no great programmer but I like to tinker and I've used autoit for quite some time now @pugh I didnt use Label field because it cannot scroll up and down and have multi colored text without extra UDFs The purpose of it is only showing ConsoleWrite in white colored text inside RichEdit and another function ConsoleWrite intended for Errors/Warnings in red (for now). Regards, ~WilliamasKumeliukas pugh 1 Sorry if it's quite challenging to understand me sometimes, there is 2 possible reasons to this: Spoiler #1. I am a native French speaker and learned English mainly from chatting with others players in online games. #2. I have a developmental disorder mainly affecting my social abilities, way of thinking, understanding stuffs and explaining myself in which it can seem ironic of seeing me here, but I been working on getting better every days for an dozens of years now ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Do not like my dirty code? It's fine, but in my opinion, the dirty codes are unique and I believe it's a good glimpse of how the mind of the person who wrote it thinks, and that, that's what I call a psychological deduction step by step in all its splendor. ~WilliamasKumeliukas Link to comment Share on other sites More sharing options...
mikell Posted September 18, 2020 Share Posted September 18, 2020 On 9/9/2020 at 5:33 PM, WilliamasKumeliukas said: How do I block TAB key from jumping on RichEdit and select whole text ..... I also have the problem to make RichEdit non clickable You might try $ES_READONLY style (if compatible with the expectations) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now