Aassdd Posted March 18, 2008 Share Posted March 18, 2008 Here is my script. #include <Misc.au3> #include <GUIConstants.au3> Opt("SendKeyDelay", 100) Opt("GUICloseOnESC", 0) $Name = IniRead(@ScriptDir & "\Typer.ini", "Basic", "Name", "Error reading ini file") $Subject = IniRead(@ScriptDir & "\Typer.ini", "Basic", "Subject", "Error reading ini file") $Line = 1 $GuiTyper = GUICreate("[" & $Subject & "]" & " - " & "[" & $Name & "]", 300, 200) $Input = GUICtrlCreateInput("", 10, 10, 280, 140, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) GUICtrlSetFont(-1, 10, Default, "Arial") GUICtrlSetColor(-2, "0x000000") GUICtrlSetState(-3, $GUI_DISABLE) $Continue = GUICtrlCreateButton("Continue", 100, 160, 100, 30) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Continue Type(IniRead(@ScriptDir & "\Typer.ini", "Text", $Line, "Error reading ini file")) $Line = $Line + 1 Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Type($text) GUICtrlSetData($Input, GUICtrlRead($Input) & $text) EndFunc ;==>Type Problems: 1. Font: doesn't change (not size, the font (tried Arial, Verdana but it doesn't change)). 2. Color: neither this changes. 3. Data: how can I enter an empty line? @CRLF returns 2 squares (unkown chars) Link to comment Share on other sites More sharing options...
OldCoder Posted March 18, 2008 Share Posted March 18, 2008 (edited) Problems: 1. Font: doesn't change (not size, the font (tried Arial, Verdana but it doesn't change)). 2. Color: neither this changes. 3. Data: how can I enter an empty line? @CRLF returns 2 squares (unkown chars) 1. I'm not sure why your font style doesn't change, (Arial), it's working fine on my computer. Perhaps you need the latest AutoIt3 update. Or the other font you're use isn't available or you have named it wrong. 2. The color is easy enough. You have disabled the input control which always grays it out. If you don't want someone to be able to type in the input area, use an Edit control with the readonly style on. 3. See the Type function below, (GUICtrlSetData($Input, GUICtrlRead($Input) & $text & @CRLF)). Works fine with the Edit control. Here is the code that works on my computer: #include <Misc.au3> #include <GUIConstants.au3> Opt("SendKeyDelay", 100) Opt("GUICloseOnESC", 0) $Name = IniRead(@ScriptDir & "\Typer.ini", "Basic", "Name", "Error reading ini file") $Subject = IniRead(@ScriptDir & "\Typer.ini", "Basic", "Subject", "Error reading ini file") $Line = 1 $GuiTyper = GUICreate("[" & $Subject & "]" & " - " & "[" & $Name & "]", 300, 200) $Input = GUICtrlCreateEdit("", 10, 10, 280, 140, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) GUICtrlSetFont(-1, 16, Default, "Arial") ;GUICtrlSetFont(-1, 12, 400, 0, "Tahoma") GUICtrlSetColor(-2, "0x880000") ;GUICtrlSetState(-3, $GUI_DISABLE) $Continue = GUICtrlCreateButton("Continue", 100, 160, 100, 30) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Continue Type(IniRead(@ScriptDir & "\Typer.ini", "Text", $Line, "Error reading ini file")) $Line = $Line + 1 Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Type($text) GUICtrlSetData($Input, GUICtrlRead($Input) & $text & @CRLF) EndFunc ;==>Type Hope this helps you out. Cheers Edited March 18, 2008 by OldCoder "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
Aassdd Posted March 19, 2008 Author Share Posted March 19, 2008 (edited) Thank you. I still got a small problem. Autoscroll does n not work or am I doing something wrong? #include <Misc.au3> #include <GUIConstants.au3> Opt("SendKeyDelay", 100) Opt("GUICloseOnESC", 0) $Name = IniRead(@ScriptDir & "\Typer.ini", "Basic", "Name", "Error reading ini file") $Subject = IniRead(@ScriptDir & "\Typer.ini", "Basic", "Subject", "Error reading ini file") $Line = 1 $GuiTyper = GUICreate("[" & $Subject & "]" & " - " & "[" & $Name & "]", 300, 200) $Input = GUICtrlCreateEdit("", 10, 10, 280, 140, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) GUICtrlSetFont(-1, 10, 400, 0, "Verdana") GUICtrlSetColor(-2, "0x880000") $Continue = GUICtrlCreateButton("Continue", 100, 160, 100, 30) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Continue Type(IniRead(@ScriptDir & "\Typer.ini", "Text", $Line, "Unable to retrieve the next line.")) $Line = $Line + 1 Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Type($text) GUICtrlSetData($Input, GUICtrlRead($Input) & $text & @CRLF) EndFunc ;==>Type EDIT: Also, how can I SetData 1 character every x time? I tried different ways with string commands but couldn't get any to work. Edited March 19, 2008 by Aassdd Link to comment Share on other sites More sharing options...
Aassdd Posted March 19, 2008 Author Share Posted March 19, 2008 (edited) I almost got it. I can't manage to exit the loop. Func Type($text) $current = GUICtrlRead($Input) $count = 1 Do $string = StringLeft($text, $count) GUICtrlSetData($Input, $current & $string & @CRLF) Sleep(100) $count = $count + 1 Until (there are no more characters in the string :D) MsgBox(0, "", "") EndFunc ;==>Type EDIT: I tried: Until $string = "";If count is negative, an empty string is returned. Until StringLen($string) = 0;Returns the length of the string. But don't work. Shouldn't they work? Edited March 19, 2008 by Aassdd Link to comment Share on other sites More sharing options...
OldCoder Posted March 19, 2008 Share Posted March 19, 2008 I almost got it. I can't manage to exit the loop. Func Type($text) $current = GUICtrlRead($Input) $count = 1 Do $string = StringLeft($text, $count) GUICtrlSetData($Input, $current & $string & @CRLF) Sleep(100) $count = $count + 1 Until (there are no more characters in the string :D) MsgBox(0, "", "") EndFunc ;==>TypeoÝ÷ Ûú®¢×+,¥w +«¢+ÙÕ¹QåÁ ÀÌØíÑáФ($ÀÌØíÕÉɹÐôU% ÑɱI ÀÌØí%¹ÁÕФ($ÀÌØí½Õ¹ÐôÄ(%¼($$ÀÌØíÍÑÉ¥¹ôMÑÉ¥¹1Ð ÀÌØíÑáаÀÌØí½Õ¹Ð¤($%U% ÑɱMÑÑ ÀÌØí%¹ÁÕаÀÌØíÕÉɹеÀìÀÌØíÍÑÉ¥¹µÀì I1¤($%M±À ÄÀÀ¤($$ÀÌØí½Õ¹ÐôÀÌØí½Õ¹Ð¬Ä(%U¹Ñ¥°ÀÌØí½Õ¹ÐôMÑÉ¥¹1¸ ÀÌØíÑáФ¬Ä(%5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤)¹Õ¹ìôôÐíQåÁ Hope that'll help. Cheers "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
Aassdd Posted March 19, 2008 Author Share Posted March 19, 2008 (edited) What's +1? Look at my previous post edit. Can you explain me> EDIT: Works btw, thanks a lot. EDIT: Nvm, I got it. Edited March 19, 2008 by Aassdd Link to comment Share on other sites More sharing options...
OldCoder Posted March 19, 2008 Share Posted March 19, 2008 I almost got it. I can't manage to exit the loop. Func Type($text) $current = GUICtrlRead($Input) $count = 1 Do $string = StringLeft($text, $count) GUICtrlSetData($Input, $current & $string & @CRLF) Sleep(100) $count = $count + 1 Until (there are no more characters in the string :D) MsgBox(0, "", "") EndFunc ;==>TypeoÝ÷ Ûú®¢×+,¥w +«¢+ÙÕ¹QåÁ ÀÌØíÑáФ($ÀÌØíÕÉɹÐôU% ÑɱI ÀÌØí%¹ÁÕФ($ÀÌØí½Õ¹ÐôÄ(%¼($$ÀÌØíÍÑÉ¥¹ôMÑÉ¥¹1Ð ÀÌØíÑáаÀÌØí½Õ¹Ð¤($%U% ÑɱMÑÑ ÀÌØí%¹ÁÕаÀÌØíÕÉɹеÀìÀÌØíÍÑÉ¥¹µÀì I1¤($%M±À ÄÀÀ¤($$ÀÌØí½Õ¹ÐôÀÌØí½Õ¹Ð¬Ä(%U¹Ñ¥°ÀÌØí½Õ¹ÐôMÑÉ¥¹1¸ ÀÌØíÑáФ¬Ä(%5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤)¹Õ¹ìôôÐíQåÁ((ì=H()Õ¹QåÁ ÀÌØíÑáФ($ÀÌØíÕÉɹÐôU% ÑɱI ÀÌØí%¹ÁÕФ($ÀÌØí½Õ¹ÐôÄ(%½ÈÀÌØíÐôÄѼMÑÉ¥¹1¸ ÀÌØíÑáФ($$ÀÌØíÍÑÉ¥¹ôMÑÉ¥¹1Ð ÀÌØíÑáаÀÌØíФ($%U% ÑɱMÑÑ ÀÌØí%¹ÁÕаÀÌØíÕÉɹеÀìÀÌØíÍÑÉ¥¹µÀì I1¤($%M±À ÄÀÀ¤(9áÐ(%5Í ½à À°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤)¹Õ¹ìôôÐíQåÁ Hope that'll help. Cheers "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
OldCoder Posted March 19, 2008 Share Posted March 19, 2008 What's +1? Look at my previous post edit. Can you explain me>EDIT: Works btw, thanks a lot.EDIT: Nvm, I got it.The +1 was to get all parts of the $text string since the $count string was basically ahead when you do the Until. I think the For...Next example is better though.You are welcome. Glad to help. Happy coding.Cheers "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
Aassdd Posted March 19, 2008 Author Share Posted March 19, 2008 (edited) Lol, thank you AGAIN. Finally: Func Type($text) $current = GUICtrlRead($Input) $count = 1 For $letter = 1 To StringLen($text) $string = StringLeft($text, $letter) GUICtrlSetData($Input, $current & $string & @CRLF) Sleep(100) Next MsgBox(0, "", "") EndFunc ;==>Type EDIT: O.o I got a problem, for empty lines I used empty string in ini file (e.g "2="). Now it doesn't show any empty lines and goes to the next. EDIT: Solved it with If $text = "" Then GUICtrlSetData($Input, $current & @CRLF) Edited March 19, 2008 by Aassdd Link to comment Share on other sites More sharing options...
OldCoder Posted March 19, 2008 Share Posted March 19, 2008 (edited) EDIT: O.o I got a problem, for empty lines I used empty string in ini file (e.g "2="). Now it doesn't show any empty lines and goes to the next.EDIT: Solved it with If $text = "" Then GUICtrlSetData($Input, $current & @CRLF)Or you could put a @CRLF in the Default value of the INIRead. EDIT: BTW, did you ever update to the latest AutoIt3 version? Edited March 19, 2008 by OldCoder "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
Aassdd Posted March 19, 2008 Author Share Posted March 19, 2008 @#$% How do I auto scroll the text to the end?? I have always been using the latest version, why? Link to comment Share on other sites More sharing options...
OldCoder Posted March 19, 2008 Share Posted March 19, 2008 @#$% How do I auto scroll the text to the end?? Try using the $ES_AUTOVSCROLL style on your Edit control: $Input = GUICtrlCreateEdit("", 10, 10, 280, 140, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_AUTOVSCROLL, $ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) I have always been using the latest version, why? The help that people give you is usually based on the current version of AutoIt3. I was just trying to be thorough. "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
Aassdd Posted March 19, 2008 Author Share Posted March 19, 2008 I know.... I tried that style and it doesn't work. Is there a way to scroll to the end of the edit box? Link to comment Share on other sites More sharing options...
OldCoder Posted March 19, 2008 Share Posted March 19, 2008 (edited) I know.... I tried that style and it doesn't work. Is there a way to scroll to the end of the edit box? Try this. I am using GUIEdit.au3 to enhance this and make it smoother and to auto-scroll: expandcollapse popup#include <Misc.au3> #include <GUIConstants.au3> #include <GUIEdit.au3> Opt("SendKeyDelay", 100) Opt("GUICloseOnESC", 0) $Name = IniRead(@ScriptDir & "\Typer.ini", "Basic", "Name", "Error reading ini file") $Subject = IniRead(@ScriptDir & "\Typer.ini", "Basic", "Subject", "Error reading ini file") $Line = 1 $GuiTyper = GUICreate("[" & $Subject & "]" & " - " & "[" & $Name & "]", 300, 200) $Input = GUICtrlCreateEdit("", 10, 10, 280, 140, BitOR($ES_CENTER, $ES_AUTOHSCROLL, $ES_AUTOVSCROLL, $ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) GUICtrlSetFont(-1, 10, 400, 0, "Verdana") GUICtrlSetColor(-2, "0x880000") $Continue = GUICtrlCreateButton("Continue", 100, 160, 100, 30) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Continue Type(IniRead(@ScriptDir & "\Typer.ini", "Text", $Line, "Unable to retrieve the next line.")) $Line = $Line + 1 Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Type($text) If GUICtrlRead($Input)<>"" then _GUICtrlEdit_AppendText($Input, @CRLF) For $letter = 1 To StringLen($text) $string = StringMid($text, $letter, 1) _GUICtrlEdit_AppendText($Input, $string) Sleep(10) Next _GUICtrlEdit_LineScroll($Input, 0, _GUICtrlEdit_GetLineCount($Input)+1) MsgBox(0, "", "") EndFunc ;==>Type This should do it. Works nice on my computer. EDIT: Actually, the "_GUICtrlEdit_LineScroll($Input, 0, _GUICtrlEdit_GetLineCount($Input)+1)" line isn't necessary, but I put it in, in case you'd like to know how to do this in the future. Edited March 19, 2008 by OldCoder "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
Aassdd Posted March 19, 2008 Author Share Posted March 19, 2008 (edited) Doesn't work very well. It scrolls down after the text is typed. expandcollapse popup#NoTrayIcon #include <Misc.au3> #include <GUIConstants.au3> #include <GUIEdit.au3> Opt("SendKeyDelay", 100) Opt("GUICloseOnESC", 0) ; == INI Settings =============================== $Name = IniRead(@ScriptDir & "\Typer.ini", "Settings", "Name", "Error reading ini file") $Subject = IniRead(@ScriptDir & "\Typer.ini", "Settings", "Subject", "Error reading ini file") $Title = "[" & $Subject & "]" & " - " & "[" & $Name & "]" $Delay = IniRead(@ScriptDir & "\Typer.ini", "Settings", "Delay", 0) ; ----------------------------------------------- $Font = IniRead(@ScriptDir & "\Typer.ini", "Text", "Font", "Arial") $Size = IniRead(@ScriptDir & "\Typer.ini", "Text", "Size", 10) $Color = IniRead(@ScriptDir & "\Typer.ini", "Text", "Color", 0x000000) $Line = 1 ; =============================================== ; == GUI ======================================== $Typer = GUICreate($Title, 300, 200) $Input = GUICtrlCreateEdit("", 10, 10, 280, 140, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_AUTOVSCROLL, $ES_MULTILINE, $ES_READONLY, $WS_VSCROLL)) GUICtrlSetFont(-1, $Size, 400, 0, $Font) GUICtrlSetColor(-2, $Color) $Button = GUICtrlCreateButton("Start", 100, 160, 100, 30) GUISetState(@SW_SHOW) ; =============================================== While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button GUICtrlSetState($Button, $GUI_DISABLE) Type(IniRead(@ScriptDir & "\Typer.ini", "Lines", $Line, "Unable to retrieve the next line")) GUICtrlSetState($Button, $GUI_ENABLE) If GUICtrlRead($Button) = "Start" Then GUICtrlSetData($Button, "Continue") $Line = $Line + 1 Case $GUI_EVENT_CLOSE Quit() EndSwitch WEnd ; =============================================== Func Type($text) $current = GUICtrlRead($Input) If $text = "" Then GUICtrlSetData($Input, $current & @CRLF) For $letter = 1 To StringLen($text) $string = StringLeft($text, $letter) GUICtrlSetData($Input, $current & $string & @CRLF) Sleep($Delay) Next EndFunc ;==>Type ; =============================================== Func Quit() GUICtrlSetData($Button, "Bye bye!") GUICtrlSetState($Button, $GUI_DISABLE) GUICtrlSetData($Input, "Made by " & @CRLF & "Please wait...") Sleep(3000) Exit EndFunc ;==>Quit ; =============================================== Edited March 19, 2008 by Aassdd Link to comment Share on other sites More sharing options...
OldCoder Posted March 19, 2008 Share Posted March 19, 2008 (edited) Doesn't work very well. It scrolls down after the text is typed. Func Type($text) If GUICtrlRead($Input)<>"" then _GUICtrlEdit_AppendText($Input, @CRLF) For $letter = 1 To StringLen($text) $string = StringMid($text, $letter, 1) _GUICtrlEdit_AppendText($Input, $string) Sleep($Delay) Next EndFunc ;==>Type Maybe try this. Edited March 19, 2008 by OldCoder "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder Link to comment Share on other sites More sharing options...
Aassdd Posted March 19, 2008 Author Share Posted March 19, 2008 Works, I don't understood how you shorten it like that but thank you so much for your help. Link to comment Share on other sites More sharing options...
OldCoder Posted March 19, 2008 Share Posted March 19, 2008 Works, I don't understood how you shorten it like that but thank you so much for your help.Not a problem. I'm glad to be of service. Good luck.Cheers "Intelligence is the ability to adapt to change." - Stephen Hawking "...not the ability to exploit others." - OldCoder 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