[Solved] AD update from csv file

4 posts in this topic

31290 1

I'd like to write a piece of tool that would allow me to update a certain field in our Active Directory from a comma separated csv file composed like this:

This file, automatically generated, can hold more than 10k lines.
Thus, I need column A to be in one variable, column B in a second one and column C in a third one.

I'm really missing this part as updating the AD is fairly easy once the 3 variable are populated.

I see things like this:

Quote

Read line 1
Do AD update
Read line 2
Do AD update
...
End Of File

Here's my attempts at the moment:

#include <File.au3>#include <Array.au3>Global$csv_file=@DesktopDir&"\Book1.csv"Global$aRecordsIfNot_FileReadToArray($csv_file,$aRecords)ThenMsgBox(4096,"Error"," Error reading log to Array error:"&@error)ExitEndIfFor$x=1to$aRecords[0]Msgbox(0,'Record:'&$x,$aRecords[$x]); Shows the line that was read from file$csv_line_values=StringSplit($aRecords[$x],",",1); Splits the line into 2 or more variables and puts them in an array; _ArrayDisplay($csv_line_values) ; Shows what's in the array you just created.; $csv_line_values[0] holds the number of elements in array; $csv_line_values[1] holds the value; $csv_line_values[2] holds the value; etcMsgbox(0,0,$csv_line_values[1])Next

Similar Content

Hello all! I have had some issues reading text from different types of windows, occasionally, specifically with controlgettext.
**Before I begin, I know there are better ways to do what I attempt in the example below. That's not the point of this post. The point is my issues with controlgettext.
I am about to cite an example with an application you may be familiar with called SpeedFan (v4.52). My problem is not specific to speedfan, it is simply the most recent and easily reproducible example I can think of.
So, the goal of the script below is to get a string of text containing the current fan RPMs from the highlighted control in the screenshot below (see "speedfan_control_details.png").

Now, here's a simple script for grabbing the window handle and reading the text from that control:
$wintitle = "SpeedFan 4.52"
$controlID = "197934" ;will be reformatted as "[ID:######]"
$hwnd = wingethandle($wintitle)
if @error<>0 then
msgbox(0, "WinGetHandle", "FAILURE. @error="&@error)
Exit
EndIf
$text = ControlGetText($hwnd, "", "[ID:"&$controlID&"]")
if @error=1 then
msgbox(0, "ControlGetText", "FAILURE. @error="&@error) ;failure returns "" and @error=1
Exit
EndIf
msgbox (0, "ControlGetText", "SUCCESS. @error="&@error &@CRLF& "$text="&$text) ;success returns string and @error=0
You'll see that the ControlGetText operation runs without error, however it does not capture any text from the control. If you explore the other controls in this one window, you'll find mixed results across the board. Neither the temps nor voltages can be read, while the log field and some other elements can be read. Even when you read the text from the whole window, those elements are not included in the visible nor hidden texts.

I have run into this issue many times in the past- inconsistencies in the ability of autoit to interact with certain controls. What is it which makes this text different than any other readable texts? Is there an alternate method of reading the text in the window/control which could work? Any and all info to help me solve this mystery and satisfy my curiosity would be greatly appreciated.
Thanks -Rob C
PS: Running Autoit v3.3.14.2 on Win7 Ultimate x64

First, I want to give a huge shout-out to the community. I'm completely self-taught, and have never had to actually ask a question before because the forum is that good at answering questions and explaining things. However, I'm kind of stumped here, and I've been stuck on this problem for almost a full day.

I'm working on a script to populate drafts of deeds at work. I have the main GUI and a function (ctrl($n) and read()) for adding fields to find and data to replace it with to an array for later use with _word_docfindreplace. All of that works. However, due to the way I have the forms set up, I need to create additional fields and info based on the data that's there. Specifically, if there's only one buyer, I need to add the field [Buyer1&2] and the data in $aArray_Base for [Buyer 1]. I also need to add a field [Buyer 2] and have a blank data set in the next column over in the array, and I need to do the same for the Seller. To this end, the function parties() sets boolean variables $2buyers and $2sellers accordingly. Then, I have buyers() and sellers() to populate the data.

The problem that I'm running into is that each function works... when ONLY the buyer 1 name field is filled, and when ONLY the seller 1 field is filled.

So if I fill Buyer 1 Name and save it, the data is populated correctly. But when I fill Buyer 1 and Seller 1 name, only the buyer 1 data populates correctly. Worse, when I fill several fields, neither populate correctly. I have no idea why this happens. I've added messageboxes to debug throughout the entire process and can't pinpoint what's causing the issue. The entire script is below. The function(s) in question are buyers() and sellers(). Only Sellers() has messageboxes throughout.

Can someone help walk me through what might be causing this and help me find a solution? Thanks a ton in advance, and sorry for the wall of text.
-Anoig

_ArrayDisplay($aArray, "Window Title", "1:", 0, Default, "Column")
; Expected results are rows 1 to the end of the array, all columns. The result is rows 0-1, all columns.
The API reference is here:
https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayDisplay.htm