nitekram Posted March 6, 2007 Posted March 6, 2007 Can someone direct me to where I can find info (or just tell me how) on how to move the list box down to the last item. Example - I have lines of text and I would like the last line and those few above to have focus (may not be right word or term) and show - I do not want to have to move the scroll bar down to the bottom to read the newest text - thanks for your help. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
quaizywabbit Posted March 6, 2007 Posted March 6, 2007 _GUICtrlListSelectIndex Select a string and scroll it into view, if necessary#Include <GuiList.au3>_GUICtrlListSelectIndex ( $h_listbox, $i_index ) [u]Do more with pre-existing apps![/u]ANYGUIv2.8
smashly Posted March 6, 2007 Posted March 6, 2007 (edited) Probly a few ways to do it.. Maybe do _GUICtrlListCount and then use the return in _GUICtrlListSelectIndex Edit: I'm always to slow to answer..lol Edited March 6, 2007 by smashly
nitekram Posted March 6, 2007 Author Posted March 6, 2007 (edited) Maybe do _GUICtrlListCount and then use the return in _GUICtrlListSelectIndexI tried this and still no luck - rather than have everyone guess what I am doing wrong, I am pasting all my code...I am sure that I have the code right (maybe) but in the wrong place :"> If anyone has any thoughts as to how to make this better (coding that is) or if you see I am doing something wrong - PLEASE POINT IT OUT I am here to learn and this came out of someone elses post that I was trying to help with - just the opening and receiving the text, I put the chat together. I know what you are saying - why invent the wheel - To learn. Anyway I have tried the code in a few areas and still the list does not drop down to the most resent line - I want to have the last line of text the sender sent to be at show after having too many lines - I will let the code talk. Here is the code that I am having trouble placing - lines 203 - 206 MsgBox('', 'Calling _GUICtrlListSelectIndex with', _GUICtrlListCount($mylistSERVER)) _GUICtrlListSelectIndex($mylistSERVER, _GUICtrlListCount($mylistSERVER) + 1) ;GUICtrlSetState - does nothing GUICtrlSetState($mylistsend, $GUI_FOCUS) NOTE - if you try to run the Server and Client via Scite you will have to have one (either one) compiled. You must type 'server' or 'client' to operate - 'post' was used for testing. _linenums:0'>expandcollapse popup;nitekrams chat server ;this program can be used in either a LAN or on a local PC (for testing functionality - make sure you set up server and client) #include <GUIConstants.au3> #include <GuiList.au3> #include <Array.au3> Dim $MESSAGE = "", $socket, $socketOPEN, $maxChars = 320, $UDPserver = 666, $UDPclient = 665, $boardCast = "192.168.0.255" Dim $setInsert = -1 ; 0 = insert at top -1 = append $inputString = "1234567890123456789012345678901234****401234567890123456789012345678901234****801234567890123456789012345678901234***1201234567890123456789012345678901234***1601234567890123456789012345678901234***2001234567890123456789012345678901234***2401234567890123456789012345678901234***2801234567890123456789012345678901234***320" Dim $test = 0 ; used for splitting windows - not sure which way to go Dim $todo = 1 ; sets test for making the connection ;check for server or client Do $typeText = InputBox("Check type of install", "For LAN settings just press enter on keyboard or click OK" & _ @LF & "If you are testing the application, type 'server' the first time and type 'client' ", "server") If @error Then Exit Until $typeText = 'server' Or $typeText = 'client' Or $typeText = "port" If $typeText <> "port" Then If $typeText = 'server' Then $type = 1 ElseIf $typeText = 'client' Then $type = 0 Else MsgBox(0, 'Restart Application', "Missing type - either server or client", 1) Exit EndIf $MESSAGE = $typeText $usernameText = InputBox("Enter username", "Please enter a name that will show when you post", "UserName") If @error Then Exit Else ;InputBox("Enter sending port", "Port that server is listening on", "65532") $UDPserver = 65532 $UDPclient = 65531 $type = 0 EndIf ;;This is the UDP Server/Client - I think it will run like all are servers and different IP's and Server|Client on same IP. ; Start The UDP Services ;============================================== UDPStartup() If @error <> 0 Then MsgBox(0, "UDPStartup ERROR", @error, 1) Exit EndIf ; Bind to a SOCKET - USED TO LISTEN ON PORT ;============================================== If $type = 1 Then ;server $socket = UDPBind(@IPAddress1, $UDPserver) If @error <> 0 Then MsgBox(0, "UDPBind ERROR", @error, 1) Exit EndIf Else ;client $socket = UDPBind(@IPAddress1, $UDPclient) If @error <> 0 Then MsgBox(0, "UDPBind ERROR", @error, 1) Exit EndIf EndIf If $type = 1 Then ;server $mainGUI = GUICreate("SERVER nitekram chat") ; will create a dialog box that when displayed is centered $font = "Comic Sans MS" If $test = 0 Then GUICtrlCreateLabel("History: ", 5, 12, 390, 50) $mylistSERVER = GUICtrlCreateList("", 5, 32, 390, 97) ;, BitOR($LBS_DISABLENOSCROLL, $WS_VSCROLL, $WS_BORDER, $LBS_NOTIFY)) ;,$LBS_MULTIPLESEL GUICtrlSetData($mylistSERVER, "Post|Started " & @MON & "/" & @MDAY & "/" & @YEAR & " (" & @YDAY & ") " & @HOUR & ":" & @MIN & "|") ;GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetFont($mylistSERVER, 9, 400, 2, $font) ; will display italic characters ;GUICtrlSetData(-1, $MESSAGE & " Started " & @MON & "/" & @MDAY & "/" & @YEAR & " (" & @YDAY & ") " & @HOUR & ":" & @MIN & "|") EndIf Else ;client $mainGUI = GUICreate("CLIENT nitekram chat") ; will create a dialog box that when displayed is centered $font = "Arial" If $test = 0 Then GUICtrlCreateLabel("History: ", 5, 12, 390, 50) $mylistCLIENT = GUICtrlCreateList("", 5, 32, 390, 97) ;, BitOR($LBS_DISABLENOSCROLL, $WS_VSCROLL)) GUICtrlSetData($mylistCLIENT, "Post|Started " & @MON & "/" & @MDAY & "/" & @YEAR & " (" & @YDAY & ") " & @HOUR & ":" & @MIN & "|") ;GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetFont($mylistCLIENT, 9, 400, 2, $font) ; will display italic characters ;GUICtrlSetData(-1, $MESSAGE & " Started " & @MON & "/" & @MDAY & "/" & @YEAR & " (" & @YDAY & ") " & @HOUR & ":" & @MIN & "|") EndIf EndIf If $test = 1 Then GUICtrlCreateLabel("History: ", 5, 12, 390, 50) $mylist = GUICtrlCreateList("", 5, 32, 390, 97, BitOR($LBS_DISABLENOSCROLL, $WS_VSCROLL)) GUICtrlSetData($mylist, "Post|Started " & @MON & "/" & @MDAY & "/" & @YEAR & " (" & @YDAY & ") " & @HOUR & ":" & @MIN & "|") ;GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetFont($mylist, 9, 400, 2, $font) ; will display italic characters ;GUICtrlSetData(-1, $MESSAGE & " Started " & @MON & "/" & @MDAY & "/" & @YEAR & " (" & @YDAY & ") " & @HOUR & ":" & @MIN & "|") EndIf $dummy = GUICtrlCreateLabel("Last Post: ", 5, 125, 390, 15) $post = GUICtrlCreateLabel('', 5, 140, 390, 75) $history = GUICtrlCreateEdit($inputString, 5, 210, 390, 150, BitAND($ES_MULTILINE, $ES_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_FOCUS) $send = GUICtrlCreateButton("Send", 5, 370, 390, 25) GUISetState() ; main loop - checks for send or a UDP receive message from sender. $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() $data = UDPRecv($socket, $maxChars + 500) Select Case $msg = $send ; Open a "SOCKET" - USED FOR SENDING TO PORT ;============================================== If $type = 1 Then ;server $socketOPEN = UDPOpen($boardCast, $UDPclient) If @error <> 0 Then MsgBox(0, "UDPOpen ERROR", @error, 1) Exit EndIf Else ;client $socketOPEN = UDPOpen($boardCast, $UDPserver) If @error <> 0 Then MsgBox(0, "UDPOpen ERROR", @error, 1) Exit EndIf EndIf ;are you there ;TODO: set up a call to see who is listening - maybe call it from above asking = whos there? If $todo = 1 Then $returnSEND = UDPSend($socketOPEN, "~~~>>>") If @error Then MsgBox(0, "ERROR", 'UDPSend($socketOPEN, "~~~>>>")') Else MsgBox(0, "bytes sent:", $returnSEND) EndIf EndIf $sendText = GUICtrlRead($history) If StringLen(GUICtrlRead($history)) > $maxChars Then MsgBox(0, 'EXCEEDED TOTAL LENGTH', StringLen($sendText) & " > " & $maxChars & @LF & "Please check the length") Else If $test = 0 Then If $type = 1 Then $mylistsend = $mylistSERVER Else $mylistsend = $mylistCLIENT EndIf Else $mylistsend = $mylist EndIf $ret = _GUICtrlListInsertItem($mylistsend, $MESSAGE & " Stamp " & @MON & "/" & @MDAY & "/" & @YEAR & " (" & @YDAY & ") " & @HOUR & ":" & @MIN & ":" & @SEC & "< : >" & @IPAddress1, $setInsert) If ($ret < 0) Then MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem") EndIf ;;; need to work on this as it does not show the last line - it needs to scroll down If StringLen($sendText) > 40 Then ; 40 is the total amount that will show in history on first line with user name ;:TODO make the first line only say username MsgBox(0, 'StringLen($sendText)', StringLen($sendText)) Dim $newString[9] For $i = 1 To StringLen($sendText) / 40 ;+ 1 $newString[0] = $i ;MsgBox(0, '$i', $i) $newString[$i] = StringLeft($sendText, 40) $sendText = StringTrimLeft($sendText, 40) ;MsgBox(0,'Taking first 40',StringTrimLeft ( $sendText, 30 )) ;MsgBox(0, '$newString[0]', $newString[0]) If $i = (UBound($newString)) Then MsgBox(0, '', 'exceeded = ' & $i) ExitLoop EndIf $ret = _GUICtrlListInsertItem($mylistsend, $usernameText & " said: " & $newString[$i], $setInsert) If ($ret < 0) Then MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem") EndIf UDPSend($socketOPEN, $usernameText & " said: " & $newString[$i]) Next ;_ArrayDisplay($newString,"Post") MsgBox('', 'Calling _GUICtrlListSelectIndex with', _GUICtrlListCount($mylistSERVER)) _GUICtrlListSelectIndex($mylistSERVER, _GUICtrlListCount($mylistSERVER) + 1) ;GUICtrlSetState - does nothing GUICtrlSetState($mylistsend, $GUI_FOCUS) Else $ret = _GUICtrlListInsertItem($mylistsend, $usernameText & " said: " & GUICtrlRead($history), $setInsert) If ($ret < 0) Then MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem") EndIf UDPSend($socketOPEN, $usernameText & " said: " & GUICtrlRead($history)) EndIf ;UDPSend($socketOPEN, $usernameText & " said: " & GUICtrlRead($history)) ;;; TESTING $newString[$i] GUICtrlSetData($history, '') GUICtrlSetState($history, $GUI_FOCUS) Sleep(10) EndIf UDPCloseSocket($socketOPEN) Case $data <> "" If $test = 0 Then If $type = 1 Then $mylistRecv = $mylistSERVER Else $mylistRecv = $mylistCLIENT EndIf Else $mylistRecv = $mylist EndIf If $data <> "" Then ;SoundPlay("C:\Program Files\Messenger\type.wav", 1) ;C:\Program Files\Messenger\type.wav ;@WindowsDir & "\media\tada.wav" MsgBox(0, '$data', $data) ;SoundPlay("C:\Program Files\Messenger\type.wav", 1) ;Beep(500,2) If $data = "~~~>>>" Then $ret = _GUICtrlListInsertItem($mylistRecv, $MESSAGE & " Stamp " & @MON & "/" & @MDAY & "/" & @YEAR & " (" & @YDAY & ") " & @HOUR & ":" & @MIN & ":" & @SEC & "< : >" & @IPAddress1, $setInsert) If ($ret < 0) Then MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem") EndIf Else ;Sleep(100) ;For $x = 1 To StringLen($data)/40 $ret = _GUICtrlListInsertItem($mylistRecv, $data, $setInsert) If ($ret < 0) Then MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem") EndIf EndIf #cs ; was using below testing new feature array $ret = _GUICtrlListInsertItem($mylistRecv, $data, 0) If ($ret < 0) Then MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem") EndIf #ce ;Next ;GUICtrlSetState - this does nothing GUICtrlSetState($mylistRecv, $GUI_FOCUS) ;Posts Last said in blank area GUICtrlSetData($post, $data) EndIf MsgBox('', 'Calling', "_GUICtrlListSelectIndex ( $mylistRecv, $data )") _GUICtrlListSelectIndex($mylistRecv, $data) EndSelect ;Sleep(100) WEnd Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() MsgBox(0, 'Thanks. Come back again', 'Contact information', 1) EndFunc ;==>OnAutoItExit edit - as requested - changed tags Edited March 7, 2007 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
Moderators SmOke_N Posted March 6, 2007 Moderators Posted March 6, 2007 [ codebox][ AutoIt] Script [ /AutoIt][ /codebox] Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
MrCreatoR Posted March 7, 2007 Posted March 7, 2007 If you want just set focus on the last item in list, then try this: #include <GuiList.au3> $Gui = GUICreate("List Focus on last item", 300, 300) $ListID = GUICtrlCreateList("", 10, 20, 270, 270) GUICtrlSetData(-1, "Item1|Item2") GUISetState() $LastItem = _GUICtrlListCount($ListID) - 1 ControlCommand($Gui, "", "ListBox1", "SetCurrentSelection", $LastItem) While GUIGetMsg() <> -3 Sleep(10) WEnd Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
nitekram Posted March 7, 2007 Author Posted March 7, 2007 (edited) If you want just set focus on the last item in list, then try this: #include <GuiList.au3> $Gui = GUICreate("List Focus on last item", 300, 300) $ListID = GUICtrlCreateList("", 10, 20, 270, 270) GUICtrlSetData(-1, "Item1|Item2") GUISetState() $LastItem = _GUICtrlListCount($ListID) - 1 ControlCommand($Gui, "", "ListBox1", "SetCurrentSelection", $LastItem) While GUIGetMsg() <> -3 Sleep(10) WEnd That seemed to do the trick - I wish there were a few more examples of using that command (ControlCommand). Thanks for your help... Edit - made reference to the command Edited March 7, 2007 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
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