yucatan Posted April 16, 2008 Author Share Posted April 16, 2008 (edited) Global $avAdapters[$iNetworkChildCount] $avAdapters[0] = _GUICtrlTreeView_GetFirstChild($hSTV, $hChildNetwork) For $n = 1 To $iNetworkChildCount - 1 $avAdapters[$n] = _GUICtrlTreeView_GetNextChild($hSTV, $avAdapters[$n - 1]) Next For $n = 0 To UBound($avAdapters) - 1 ConsoleWrite("Debug: Adapter " & $n & ": Text: " & _GUICtrlTreeView_GetText($hSTV, $avAdapters[$n]) & @LF) Next just explane relaxt en slowly what this does.. i just dont understand pleas. Edited April 16, 2008 by yucatan Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 16, 2008 Share Posted April 16, 2008 i'm living in The Nederlands.. so ; Globlal $sItemName = "Netwerkadapters", $sDevMgmt = "Apparaatbeheer" ; Uhmm... not English this are the names in my computers if you windows in english then its Global $sItemName = "Network adapters", $sDevMgmt = "Device Manager" ; English so thats why... your first rule dont work @ my pc the secend doesAs intended. what are the variable now ? soz i dont understand the last part where u get the names its so complacated i cant read id:D i DONT need the names you may leave it i want that the when there are four network devices that i have 4 differen viarable that i can use so then i can say follow this steps then go to the next variable and do the same stepsThe handles to the adapters are contained in an array ($avAdapters). If you are not familiar with arrays, it's time learn. As a demonstration of how to access the array, I included the For/Next loop at the end, which uses each handle in turn to display the text for that item. The Global declaration of the array "Global $avAdapters[$iNetworkChildCount]" causes it to have exactly the number of elements required, and the For/Next loop below that fills the array. 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 More sharing options...
yucatan Posted April 16, 2008 Author Share Posted April 16, 2008 (edited) As intended. The handles to the adapters are contained in an array ($avAdapters). If you are not familiar with arrays, it's time learn. As a demonstration of how to access the array, I included the For/Next loop at the end, which uses each handle in turn to display the text for that item. The Global declaration of the array "Global $avAdapters[$iNetworkChildCount]" causes it to have exactly the number of elements required, and the For/Next loop below that fills the array. ok... i have readed your post 7 times and i still dont understand(not engels is normale good nog supergood so srry i cant folow you:$ ) soz just grab a couple or command and explane there fucion example For $n = 1 To $iNetworkChildCount - 1 wtf does that means i dont understand the structure, Edited April 16, 2008 by yucatan Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 16, 2008 Share Posted April 16, 2008 ok... i have readed your post 7 times and i still dont understand(not engels is normale good nog supergood so srry i cant folow you:$ ) soz just grab a couple or command and explane there fucion example For $n = 1 To $iNetworkChildCount - 1 wtf does that means i dont understand the structure, Any native Dutch speakers wanna' jump in here, feel free! An array is just a list. Like a grocery list, except it's a geek's grocery list because it is numbered from 0. The items are only numbered from 0, they cannot be itemized by letters (i.e. A, B, C). Allowed geek's grocery list: 0 = Milk 1 = Eggs 2 = Bread Not allowed: A = Milk B = Eggs C = Bread In AutoIt: Global $avGroceries[3] ; Declare the array with three elements $avGroceries[0] = "Milk" $avGroceries[1] = "Eggs" $avGroceries[2] = "Bread" Notice that we Declared the array with three elements, but there is no actual element called $avGroceries[3] because they are numbered from 0. So if I want to display all the items in a loop it would look like this: For $n = 0 To 2 ConsoleWrite("Grocery item no." & $n & " = " & $avGroceries[$n] & @LF) Next What if you didn't know ahead of time how big the array was? AutoIt has a command for that, Ubound() which returns the count of elements in the array. So If I do $x = Ubound($avGroceries); I get $x = 3. But that's the count, and elements are numbered from 0, so the real range of elements is not 1 thru 3, but instead is 0 thru 2. Here is one way to script that: $x = Ubound($avGroceries) $x = $x - 1 For $n = 0 To $x ConsoleWrite("Grocery item no." & $n & " = " & $avGroceries[$n] & @LF) Next But it is more efficient to skip the use of the extra variable $x, and just do this: For $n = 0 To Ubound($avGroceries) - 1 ConsoleWrite("Grocery item no." & $n & " = " & $avGroceries[$n] & @LF) Next Getting back to our acutal demo: The variable $iNetworkChildCount is already set to the number of adapters listed under "Network adapters (Netwerkadapters)". So we use that variable to declare the array: Global $avAdapters[$iNetworkChildCount] If there were two adapters, then $avAdapters has two elements (0 and 1), or if four adapters then four elements (0 thru 3). Next we set the first element to the handle of the first child element. Here $hChildNetwork is the parent item's handle (the "Network adapters" item), and we get back the handle of the first adapter under it: $avAdapters[0] = _GUICtrlTreeView_GetFirstChild($hSTV, $hChildNetwork) After getting the first child, we use that child item's handle as the starting point to get the NEXT child item handles for all the rest. There are some gimicks here with the element numbers in the array. Since we already set the first element [0], we are starting this loop with the second element $n = 1. To stop the loop at the last element, we used $iNetworkChildCount - 1, but Ubound($avAdapters) - 1 would have worked just as well there (and maybe been clearer). Remember the second parameter for the GetNextChild function is the handle of the child BEFORE it, which is why we get the second parameter from the array element BEFORE the current one with $avAdapters[$n - 1]. When this code is done, you have an array that contains the handles of the TreeView items for all the adapters: For $n = 1 To $iNetworkChildCount - 1 $avAdapters[$n] = _GUICtrlTreeView_GetNextChild($hSTV, $avAdapters[$n - 1]) Next Now that we have this array of item handles, we can use it to display the text on each one. You should understand how this part works now: For $n = 0 To UBound($avAdapters) - 1 ConsoleWrite("Debug: Adapter " & $n & ": Text: " & _GUICtrlTreeView_GetText($hSTV, $avAdapters[$n]) & @LF) Next Instead of listing the text from the item, you could click on it with _GuiCtrlTreeView_ClickItem() and then open properties and make changes, etc. Whatever you put there will be done for each adapter whose TreeView item handle is listed in the array. You are now on your own for a Dutch translation! 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 More sharing options...
yucatan Posted April 19, 2008 Author Share Posted April 19, 2008 Any native Dutch speakers wanna' jump in here, feel free! An array is just a list. Like a grocery list, except it's a geek's grocery list because it is numbered from 0. The items are only numbered from 0, they cannot be itemized by letters (i.e. A, B, C). Allowed geek's grocery list: 0 = Milk 1 = Eggs 2 = Bread Not allowed: A = Milk B = Eggs C = Bread In AutoIt: Global $avGroceries[3] ; Declare the array with three elements $avGroceries[0] = "Milk" $avGroceries[1] = "Eggs" $avGroceries[2] = "Bread" Notice that we Declared the array with three elements, but there is no actual element called $avGroceries[3] because they are numbered from 0. So if I want to display all the items in a loop it would look like this: For $n = 0 To 2 ConsoleWrite("Grocery item no." & $n & " = " & $avGroceries[$n] & @LF) Next What if you didn't know ahead of time how big the array was? AutoIt has a command for that, Ubound() which returns the count of elements in the array. So If I do $x = Ubound($avGroceries); I get $x = 3. But that's the count, and elements are numbered from 0, so the real range of elements is not 1 thru 3, but instead is 0 thru 2. Here is one way to script that: $x = Ubound($avGroceries) $x = $x - 1 For $n = 0 To $x ConsoleWrite("Grocery item no." & $n & " = " & $avGroceries[$n] & @LF) Next But it is more efficient to skip the use of the extra variable $x, and just do this: For $n = 0 To Ubound($avGroceries) - 1 ConsoleWrite("Grocery item no." & $n & " = " & $avGroceries[$n] & @LF) Next Getting back to our acutal demo: The variable $iNetworkChildCount is already set to the number of adapters listed under "Network adapters (Netwerkadapters)". So we use that variable to declare the array: Global $avAdapters[$iNetworkChildCount] If there were two adapters, then $avAdapters has two elements (0 and 1), or if four adapters then four elements (0 thru 3). Next we set the first element to the handle of the first child element. Here $hChildNetwork is the parent item's handle (the "Network adapters" item), and we get back the handle of the first adapter under it: $avAdapters[0] = _GUICtrlTreeView_GetFirstChild($hSTV, $hChildNetwork) After getting the first child, we use that child item's handle as the starting point to get the NEXT child item handles for all the rest. There are some gimicks here with the element numbers in the array. Since we already set the first element [0], we are starting this loop with the second element $n = 1. To stop the loop at the last element, we used $iNetworkChildCount - 1, but Ubound($avAdapters) - 1 would have worked just as well there (and maybe been clearer). Remember the second parameter for the GetNextChild function is the handle of the child BEFORE it, which is why we get the second parameter from the array element BEFORE the current one with $avAdapters[$n - 1]. When this code is done, you have an array that contains the handles of the TreeView items for all the adapters: For $n = 1 To $iNetworkChildCount - 1 $avAdapters[$n] = _GUICtrlTreeView_GetNextChild($hSTV, $avAdapters[$n - 1]) Next Now that we have this array of item handles, we can use it to display the text on each one. You should understand how this part works now: For $n = 0 To UBound($avAdapters) - 1 ConsoleWrite("Debug: Adapter " & $n & ": Text: " & _GUICtrlTreeView_GetText($hSTV, $avAdapters[$n]) & @LF) Next Instead of listing the text from the item, you could click on it with _GuiCtrlTreeView_ClickItem() and then open properties and make changes, etc. Whatever you put there will be done for each adapter whose TreeView item handle is listed in the array. You are now on your own for a Dutch translation! hmm realy thx most peopel dont do this for somebody i realy needs to take a couple of hours to explane things so good Link to comment Share on other sites More sharing options...
Dizzy Posted July 6, 2008 Share Posted July 6, 2008 (edited) Hi! I've tried to migrate your script to work with secpol.msc but i get an error: _WinAPI_ReadProcessMemory: Access is denied. Do you have an idea? I need to save the settings from some policies like - Log on as a batch job - log on as a service and 4-5 more. My idea is to save the settings to a file and to read them with a second script. expandcollapse popup#include <GuiTreeView.au3> Opt("WinTitleMatchMode", 4) ShellExecute("secpol.msc") WinWait("[CLASS:MMCMainFrame; TITLE:Local Security Settings]") $hWin = WinGetHandle("[CLASS:MMCMainFrame; TITLE:Local Security Settings]") WinActivate($hWin) WinWaitActive($hWin) $hSTV = ControlGetHandle($hWin, "", "SysTreeView321") $iCount = _GUICtrlTreeView_GetCount($hSTV) ConsoleWrite("Debug: STV Total Items $iCount = " & $iCount & @LF) $hSTV_Item = _GUICtrlTreeView_GetFirstItem($hSTV) $sItemText = _GUICtrlTreeView_GetText($hSTV, $hSTV_Item) ConsoleWrite("Debug: Top item $sItemText = " & $sItemText & @LF) $iChildCount = _GUICtrlTreeView_GetChildCount($hSTV, $hSTV_Item) ConsoleWrite("Debug: Item Child $iChildCount = " & $iChildCount & @LF) $hChildLPolicies = _GUICtrlTreeView_FindItem($hSTV, "Local Policies", True, $hSTV_Item) If $hChildLPolicies = 0 Then MsgBox(16, "Error", "Failed to find Local Policies child handle.") Exit EndIf ConsoleWrite("Debug: Found Local Policies child item = " & $hChildLPolicies & @LF) _GUICtrlTreeView_Expand($hSTV, $hChildLPolicies, True) $hUserRA = _GUICtrlTreeView_FindItem($hSTV, "User Rights Assignment", True, $hChildLPolicies) If $hUserRA = 0 Then MsgBox(16, "Error", "Failed to find User Rights Assignment child handle.") Exit EndIf ConsoleWrite("Debug: Found Local Rights Assignment child item = " & $hUserRA & @LF) _GUICtrlTreeView_SelectItem($hSTV, $hUserRA, True) ConsoleWrite("Debug: Current selection: " & _GUICtrlTreeView_GetSelection($hSTV) & @LF) Sleep(5000) _GUICtrlTreeView_ClickItem($hSTV, $hUserRA) Any help is really welcome! muttley CU DIzzy Edited July 6, 2008 by Dizzy Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 7, 2008 Share Posted July 7, 2008 Hi!I've tried to migrate your script to work with secpol.msc but i get an error:_WinAPI_ReadProcessMemory: Access is denied.Any help is really welcome! CUDIzzyYou have your own topic for this, no need to hijack this one... muttley 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 More sharing options...
Dizzy Posted July 7, 2008 Share Posted July 7, 2008 You have your own topic for this, no need to hijack this one... You're right ... sorry! muttley 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