hispeed_mike Posted February 6, 2009 Posted February 6, 2009 Hi all, Below is my script. What I am basically doing is want to create a GUI that has a List of Registry settings from a specific Key. Dump that into a list view column and then Dump the values of the registry keys into the second column. I want to eventually make the value editable and then submit any changes back to the registry. The problem I am having is on the _GUICtrlListView_AddArray control. The array exists and can be displayed but when I get down to the Loop for the UBound I get this error: Line 390 (File "C:\Program Files\Autoit3\Include\GuiListView.au3"): DllStructSetData($tBuffer, "Text", #aItems[$iI][0]) DllStructSetData($tBuffer, "Text", ^ERROR Error:Array Variables has incorrect number of subscripts or subscript dimensions range exceeded. I thought this was to do with the naming convention change from the example in Help to the array names I had set up or that the number of rows were not being read from the array. Heads up appreciated. Excuse the layout of the code. expandcollapse popup#include "CompInfo.au3" #include "Array.au3" #include <GUIConstantsEx.au3> #Include <GuiListView.au3> ;Opt('MustDeclareVars', 1) Global $aReg[1] [1] [1] Global $aReg2 [1] [1] Global $aReg3 [1] [1] $RegKey = "HKEY_LOCAL_MACHINE\Software\Hispeed" $num = 0 For $i = 1 to 100 $var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Hispeed", $i) if @error <> 0 Then ExitLoop ;MsgBox(4096, "Value Name #" & $i & " under in AutoIt3 key", $var) _ArrayAdd ($aReg, $var) $add = $num + 1 $num = $add next $x = $num For $x = $num to 1 Step -1 $key = $aReg[$x] $val = RegRead ($RegKey, $key) ;MsgBox (4096, "Result", $RegKey & "\" & $key & "\" & $val) _ArrayAdd ($aReg2, $RegKey & "\" & $key) _ArrayAdd ($aReg3, $val) Next ; -------------------------------------------------------------------------------------- Example() Func Example() Local $add, $clear, $reglist, $close, $msg, $regtitle ; Create GUI GUICreate("ListView Add Array", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) ;_GUICtrlListView_SetUnicodeFormat($hListView, False) GUISetState() _GUICtrlListView_AddColumn($hListView, "Key Name", 100) _GUICtrlListView_AddColumn($hListView, "Value", 100) _GUICtrlListView_SetItemCount($hListView, $num) For $iI = 0 To UBound($aReg2) - 1 $aReg2[$num] = "Key Name" & $iI Next _GUICtrlListView_AddArray($hListView, $aReg2) $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) $close = GUICtrlCreateButton("Exit", 64, 350, 175, 25) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $close Exit EndSelect WEnd EndFunc ;==>Example
Zedna Posted February 6, 2009 Posted February 6, 2009 This works fine for me with AutoIt 3.2.12.1 expandcollapse popup#include "Array.au3" #include <GUIConstantsEx.au3> #Include <GuiListView.au3> Global $aReg[1][2] Global $num ;~ $RegKey = "HKEY_LOCAL_MACHINE\Software\Hispeed" $RegKey = "HKEY_LOCAL_MACHINE\Software\AutoIt v3\Autoit" $i = 1 While 1 $key = RegEnumVal($RegKey, $i) If @error <> 0 Then ExitLoop $val = RegRead ($RegKey, $key) ReDim $aReg[$i][2] $aReg[$i-1][0] = $key $aReg[$i-1][1] = $val $i += 1 WEnd $num = $i ; -------------------------------------------------------------------------------------- Example() Func Example() Local $add, $clear, $reglist, $close, $msg, $regtitle ; Create GUI GUICreate("ListView Add Array", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) ;_GUICtrlListView_SetUnicodeFormat($hListView, False) GUISetState() _GUICtrlListView_AddColumn($hListView, "Key Name", 100) _GUICtrlListView_AddColumn($hListView, "Value", 100) _GUICtrlListView_SetItemCount($hListView, $num) ;~ _ArrayDisplay ($aReg) _GUICtrlListView_AddArray($hListView, $aReg) $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) $close = GUICtrlCreateButton("Exit", 64, 350, 175, 25) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $close Exit EndSelect WEnd EndFunc ;==>Example What AutoIt version do you have? Also in your error message: DllStructSetData($tBuffer, "Text", #aItems[$iI][0]) should be $ instead of # DllStructSetData($tBuffer, "Text", $aItems[$iI][0]) Resources UDF ResourcesEx UDF AutoIt Forum Search
hispeed_mike Posted February 6, 2009 Author Posted February 6, 2009 Thanks for the reply, Reveiwing your changes to get what I did wrong. Thanks for your help. And Yep typo on the # thingy. Cheers This works fine for me with AutoIt 3.2.12.1 expandcollapse popup#include "Array.au3" #include <GUIConstantsEx.au3> #Include <GuiListView.au3> Global $aReg[1][2] Global $num ;~ $RegKey = "HKEY_LOCAL_MACHINE\Software\Hispeed" $RegKey = "HKEY_LOCAL_MACHINE\Software\AutoIt v3\Autoit" $i = 1 While 1 $key = RegEnumVal($RegKey, $i) If @error <> 0 Then ExitLoop $val = RegRead ($RegKey, $key) ReDim $aReg[$i][2] $aReg[$i-1][0] = $key $aReg[$i-1][1] = $val $i += 1 WEnd $num = $i ; -------------------------------------------------------------------------------------- Example() Func Example() Local $add, $clear, $reglist, $close, $msg, $regtitle ; Create GUI GUICreate("ListView Add Array", 400, 300) $hListView = GUICtrlCreateListView("", 2, 2, 394, 268) ;_GUICtrlListView_SetUnicodeFormat($hListView, False) GUISetState() _GUICtrlListView_AddColumn($hListView, "Key Name", 100) _GUICtrlListView_AddColumn($hListView, "Value", 100) _GUICtrlListView_SetItemCount($hListView, $num) ;~ _ArrayDisplay ($aReg) _GUICtrlListView_AddArray($hListView, $aReg) $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) $close = GUICtrlCreateButton("Exit", 64, 350, 175, 25) $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $close Exit EndSelect WEnd EndFunc ;==>Example What AutoIt version do you have? Also in your error message: should be $ instead of #
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