Jump to content

Trouble Setting Index In _GUICtrlListSelectIndex


Recommended Posts

For some reason autoit wont allow me to have the indes section in _GUICtrlListSelectIndex to change before the GUI is loaded up.

_GUICtrlListSelectIndex ( $h_listbox,  IniRead (@ScriptDir & "\Settings.Ini", "General", "Start", "24"))oÝ÷ Øp¢{^½éð¢¹"~*n¶)Ú½ªâi¹^jëh×6$X = 27
_GUICtrlListSelectIndex ( $h_listbox, $X)
Link to comment
Share on other sites

For some reason autoit wont allow me to have the indes section in _GUICtrlListSelectIndex to change before the GUI is loaded up.

What version of AutoIt are you running? The current production version is 3.2.10.0 and has some major changes to the GUI control UDFs. GAFrost has been incorporating the functionallity of PaulIA's AU3 library while standardizing the functions and deconflicting all the CONST declarations. This has been a big change and breaks backward compatibility (there were a lot of warnings while all the Betas where tried out).

In this case your function has been replaced with _GUICtrlListBox_SetCurSel() in the new GuiListBox.au3 UDF. I don't know if there was an issue with the old function, but the new one performs selection before the GUI is displayed just fine:

#include <GuiListBox.au3>

; Create GUI
$hGUI = GUICreate("(Internal) List Box Set Cur Sel", 400, 296)
$hListBox = GUICtrlCreateList("", 2, 2, 396, 296)

; Add strings
_GUICtrlListBox_BeginUpdate($hListBox)
For $iI = 1 To 9
    _GUICtrlListBox_AddString($hListBox, StringFormat("%03d : Random string", Random(1, 100, 1)))
Next
_GUICtrlListBox_EndUpdate($hListBox)

; Select an item
_GUICtrlListBox_SetCurSel($hListBox, 4)

; Display GUI after selection
GUISetState()

; Get currently selected item
MsgBox(4160, "Information", "Current selction: " & _GUICtrlListBox_GetCurSel($hListBox))

; Loop until user exits
Do
Until GUIGetMsg() = -3

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...