benners Posted December 14, 2007 Share Posted December 14, 2007 I am having problems trying to get the desired text showing in an input box. My Aim is to get the currently selected index of a listview, read a string from the subitem of the selected index and display it as the default for the inputbox. When I specifically state the index # the text displays but when I use a variable nothing is displayed. #include <GUIListView.au3> Dim $CurIndex #Region ### START Koda GUI section ### Form=C:\Form2.kxf $Form2 = GUICreate("Form2", 413, 262, 366, 227) $ListView1 = GUICtrlCreateListView("Filename|Display|MST|CmdLine", 24, 24, 361, 169) GUICtrlSendMsg(-1, 0x101E, 0, 70) GUICtrlSendMsg(-1, 0x101E, 1, 50) GUICtrlSendMsg(-1, 0x101E, 2, 50) GUICtrlSendMsg(-1, 0x101E, 3, 187) $ListView1_0 = GUICtrlCreateListViewItem("wscript.exe|||//B ..\Office_2003\OTG\offverlog.vbs", $ListView1) _GUICtrlListView_SetItemSelected($ListView1, 0) $Button1 = GUICtrlCreateButton("Add CmdLine", 304, 208, 80, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 $CurIndex = _GUICtrlListView_GetSelectedIndices($ListView1) MsgBox(0, 'Currently Selected', 'Item Index = ' & $CurIndex) ; works. $var = InputBox('Command Line Parameters', 'This works and shows the text', _GUICtrlListView_GetItemText($ListView1, 0, 3)) ; Doesn't work. $var = InputBox('Command Line Parameters', 'This does not and string is blank', _GUICtrlListView_GetItemText($ListView1, $CurIndex, 3)) EndSwitch WEnd Is this: 1. A bug. 2. Intended 3. PICNIA error?. Thanks Link to comment Share on other sites More sharing options...
martin Posted December 14, 2007 Share Posted December 14, 2007 I am having problems trying to get the desired text showing in an input box. My Aim is to get the currently selected index of a listview, read a string from the subitem of the selected index and display it as the default for the inputbox. When I specifically state the index # the text displays but when I use a variable nothing is displayed. #include <GUIListView.au3> Dim $CurIndex #Region ### START Koda GUI section ### Form=C:\Form2.kxf $Form2 = GUICreate("Form2", 413, 262, 366, 227) $ListView1 = GUICtrlCreateListView("Filename|Display|MST|CmdLine", 24, 24, 361, 169) GUICtrlSendMsg(-1, 0x101E, 0, 70) GUICtrlSendMsg(-1, 0x101E, 1, 50) GUICtrlSendMsg(-1, 0x101E, 2, 50) GUICtrlSendMsg(-1, 0x101E, 3, 187) $ListView1_0 = GUICtrlCreateListViewItem("wscript.exe|||//B ..\Office_2003\OTG\offverlog.vbs", $ListView1) _GUICtrlListView_SetItemSelected($ListView1, 0) $Button1 = GUICtrlCreateButton("Add CmdLine", 304, 208, 80, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 $CurIndex = _GUICtrlListView_GetSelectedIndices($ListView1) MsgBox(0, 'Currently Selected', 'Item Index = ' & $CurIndex) ; works. $var = InputBox('Command Line Parameters', 'This works and shows the text', _GUICtrlListView_GetItemText($ListView1, 0, 3)) ; Doesn't work. $var = InputBox('Command Line Parameters', 'This does not and string is blank', _GUICtrlListView_GetItemText($ListView1, $CurIndex, 3)) EndSwitch WEnd Is this: 1. A bug. 2. Intended 3. PICNIA error?. Thanks You need to read the info heading the function _GUICtrlListView_GetSelectedIndices. The return is not an integer it's a string since you haven't given the second parameter. So instead of _GUICtrlListView_GetItemText($ListView1, $CurIndex, 3) you need $ItemArray = StringSplit($CurIndex,"|") _GUICtrlListView_GetItemText($ListView1, $ItemArray [1], 3);assuming $ItemArray [0] > 0 But then it would be easier to use $CurIndex = _GUICtrlListView_GetSelectedIndices($ListView1,true) and then _GUICtrlListView_GetItemText($ListView1, $CurIndex[1], 3);assuming $CurIndex [0] > 0 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
benners Posted December 14, 2007 Author Share Posted December 14, 2007 You need to read the info heading the function _GUICtrlListView_GetSelectedIndices. The return is not an integer it's a string since you haven't given the second parameter. So instead of _GUICtrlListView_GetItemText($ListView1, $CurIndex, 3) you need $ItemArray = StringSplit($CurIndex,"|") _GUICtrlListView_GetItemText($ListView1, $ItemArray [1], 3);assuming $ItemArray [0] > 0 But then it would be easier to use $CurIndex = _GUICtrlListView_GetSelectedIndices($ListView1,true) and then _GUICtrlListView_GetItemText($ListView1, $CurIndex[1], 3);assuming $CurIndex [0] > 0Because it's a string!!!, sheesh when you say it like that its simple :"> what this AutoIt thingy needs is a help file where people can look up these things .... wait there is one I honestly did RTFM but the penny didn't drop until you mentioned it. I kept seeing the 0 and thought, well its returning zero why wont it work?. Once again, because it's a string!! Thanks for the reply. 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