Leaderboard
Popular Content
Showing content with the highest reputation on 02/04/2020 in all areas
-
Notepad++ offers an installation using commandline parameters. Have a look at the help for Run or RunWait. The command string reads : Run("npp.7.8.1.Installer.x64.exe /S", "", @SW_HIDE) /S means silent. With /D= you can specify an alternative target directory (if desired). You probably have to put #RequireAdmin at the beginning of the script.2 points
-
OutlookEX
seadoggie01 and one other reacted to Skysnake for a file
I have been using this UDF for about two years. It is deployed on a variety of Windows PCs running Windows 7, 8x and 10. It is an incredibly powerful MS Outlook automation tool, which allows for all the basics (and some advances activities) while using Outlook. To use, you will obviously need this UDF included in an AutoIt script and Outlook installed and activated on your computer. This UDF does not replace Outlook, it merely automates it. If you have repetitive tasks concerning Outlook, this is probably the solution to your problem.2 points -
This is a UDF called EzMySql for using a MySql database with autoit, it uses similar syntax as SQLite but for MySql, for a more comprehensive MySql UDF see MySQL UDF by ProgAndy. Credit goes to ProgAndy as i used his UDF to be able to create this standalone UDF. I have only been able to test it on windowsXP x32 Download EzMySql_Dll.au3 There are two scripts, EzMySql.au3 which contains the functions and EzMySql_Dll.au3 which has an embeded 32 and 64 dll. The required dll will be created if it does not exist in the path given when calling _EzMySql_Startup, if no path is given the dll will be created in the script directory. Please give it a try and let me know of any problems/improvements:) Example Script #include "EzMySql.au3" #include <Array.au3> If Not _EzMySql_Startup() Then MsgBox(0, "Error Starting MySql", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf $Pass = "Your password here" If Not _EzMySql_Open("", "root", $Pass, "", "3306") Then MsgBox(0, "Error opening Database", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf If Not _EzMySql_Exec("CREATE DATABASE IF NOT EXISTS EzMySqlTest") Then MsgBox(0, "Error opening Database", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf If Not _EzMySql_SelectDB("EzMySqlTest") Then MsgBox(0, "Error setting Database to use", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf $sMySqlStatement = "CREATE TABLE IF NOT EXISTS TestTable (" & _ "RowID INT NOT NULL AUTO_INCREMENT," & _ "Name TEXT NOT NULL ," & _ "Age INT NOT NULL ," & _ "EyeColour TEXT NOT NULL ," & _ "HairColour TEXT NOT NULL ," & _ "PRIMARY KEY (`RowID`) ," & _ "UNIQUE INDEX RowID_UNIQUE (`RowID` ASC) );" If Not _EzMySql_Exec($sMySqlStatement) Then MsgBox(0, "Error Creating Database Table", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf Local $aEyeColours[7] = ["Amber","Blue","Brown","Grey","Green","Hazel","Red"] Local $aHairColours[6] = ["Brown","Black","Blond","Grey","Green","Pink"] Local $sMySqlStatement = "" For $i = 1 To 50 Step 1 $sMySqlStatement &= "INSERT INTO TestTable (Name,Age,EyeColour,HairColour) VALUES (" & _ "'Person" & $i & "'," & _ "'" & Random(1, 100, 1) & "'," & _ "'" & $aEyeColours[Random(0, 6, 1)] & "'," & _ "'" & $aHairColours[Random(0, 5, 1)] & "');" Next If Not _EzMySql_Exec($sMySqlStatement) Then MsgBox(0, "Error inserting data to Table", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf MsgBox(0, "Last AUTO_INCREMENT columnID2", _EzMySql_InsertID()) $aOk = _EzMySql_GetTable2d("SELECT Name,EyeColour FROM TestTable WHERE EyeColour = '"& $aEyeColours[Random(0, 6, 1)] & "';") $error = @error If Not IsArray($aOk) Then MsgBox(0, $sMySqlStatement & " error", $error) _ArrayDisplay($aOk, "2d Array Names of certain eyecolour") MsgBox(0, "", "Following is how to get a row at a time of a query as a 1d array") If Not _EzMYSql_Query("SELECT * FROM TestTable WHERE HairColour = '"& $aHairColours[Random(0, 5, 1)] & "' LIMIT 5;") Then MsgBox(0, "Query Error", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf For $i = 1 To _EzMySql_Rows() Step 1 $a1Row = _EzMySql_FetchData() _ArrayDisplay($a1Row, "Result: " & $i) Next _EzMySql_Exec("DROP TABLE TestTable") _EzMySql_Close() _EzMySql_ShutDown() Exit EzMySql.au3 #include-once #include <EzMySql_Dll.au3> ; #INDEX# ======================================================================================================================= ; Title .........: EzMySql ; AutoIt Version : 3.3.6.1 ; Language ......: English ; Description ...: Functions that assist access to an MySql database. ; Author(s) .....: Yoriz ; Based on ......: MySQL UDFs working with libmysql.dll by Prog@ndy and the autoit built in Sqlite functionality ; Dll ...........: libmysql.dll or libmySQL_x64.dll ; #CURRENT# ===================================================================================================================== ; _EzMySql_Startup ; _EzMySql_ShutDown ; _EzMySql_Open ; _EzMySql_Close ; _EzMySql_Exec ; _EzMySql_GetTable2d ; _EzMySql_AddTable2d ; _EzMySql_Changes ; _EzMySql_ErrMsg ; _EzMySql_FetchData() ; _EzMySql_Query ; _EzMySql_QueryFinalize ; _EzMySql_FetchNames ; _EzMySql_Rows ; _EzMySql_Columns ; _EzMySql_ChangeUser ; _EzMySql_InsertID ; _EzMySql_SelectDB ; =============================================================================================================================== ; #VARIABLES# =================================================================================================================== Global $hEzMySql_Dll = -1, $hEzMySql_Ptr, $sEzMySql_Result, $sEzMySql_Mutltiline = 1 ; struct from MySQL UDFs working with libmysql.dll by Prog@ndy Global Const $hEzMySql_Field = _ "ptr name;" & _ ;/* Name of column */ [[char * "ptr orgName;" & _ ;/* Original column name, if an alias */ [[char * "ptr table;" & _ ;/* Table of column if column was a field */ [[char * "ptr orgTable;" & _ ;/* Org table name, if table was an alias */ [[char * "ptr db;" & _ ;/* Database for table */ [[char * "ptr catalog;" & _ ;/* Catalog for table */ [[char * "ptr def;" & _ ;/* Default value (set by mysql_list_fields) */ [[char * "ulong length;" & _ ;/* Width of column (create length) */ "ulong maxLength;" & _ ;/* Max width for selected set */ "uint nameLength;" & _ "uint orgNameLength;" & _ "uint tableLength;" & _ "uint orgTableLength;" & _ "uint dbLength;" & _ "uint catalogLength;" & _ "uint defLength;" & _ "uint flags;" & _ ;/* Div flags */ "uint decimals;" & _ ;/* Number of decimals in field */ "uint charsetnr;" & _ ;/* Character set */ "int type;" & _ ;/* Type of field. See mysql_com.h for types */ "ptr extension;" ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Startup ; Description ...: Locates or creates the libmysql.dll and creates a MySQL struct ; Syntax.........: _EzMySql_Startup($hEzMySql_DllLoc = "") ; Parameters ....: $hEzMySql_DllLoc - Path to libmysql.dllor libmySQL_x64.dll, if path = "" @scripdir used ; | if a path is given and no dll exists it will be created ; Return values .: On Success - 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - Failed to write dll file ; 2 - Failed to open DLL ; 3 - Failed to create MySql struct ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Startup($hEzMySql_DllLoc = "") Local $sDll_Filename, $hFileCreate, $hFileWriteOk If @AutoItX64 = 0 Then $sDll_Filename = "libmysql.dll" Else $sDll_Filename = "libmySQL_x64.dll" EndIf If $hEzMySql_DllLoc Then If StringRight($hEzMySql_DllLoc, StringLen($sDll_Filename)) <> $sDll_Filename Then $hEzMySql_DllLoc = StringRegExpReplace($hEzMySql_DllLoc, "[\\/]+\z", "") & "\" $hEzMySql_DllLoc &= $sDll_Filename EndIf Else $hEzMySql_DllLoc = @ScriptDir & "\" & $sDll_Filename EndIf If Not FileExists($hEzMySql_DllLoc) Then $hFileCreate = FileOpen($hEzMySql_DllLoc, 10) $hFileWriteOk = FileWrite($hFileCreate, _EzMySql_Dll()) FileClose($hFileCreate) If Not $hFileWriteOk Then Return SetError(1, 0, 0) EndIf $hEzMySql_Dll = DllOpen($hEzMySql_DllLoc) If $hEzMySql_Dll = -1 Then Return SetError(2, 0, 0) Local $hPtr = DllCall($hEzMySql_Dll, "ptr", "mysql_init", "ptr", 0) If @error Then Return SetError(3, 0, 0) $hEzMySql_Ptr = $hPtr[0] Return 1 EndFunc ;==>_EzMySql_Startup ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Open ; Description ...: Open a MySql Database ; Syntax.........: _EzMySql_Open($Host, $User, $Pass, $Database = "", $Port = 0, $unix_socket = "", $Client_Flag = 0) ; Parameters ....: $Host - hostname or an IP address ; $User - MySQL login ID ; $Pass - password for user (no password: "" (empty string)) ; $Database - default database (no default db: "" (empty string)) ; $Port - If port is not 0, the value is used as the port number for the TCP/IP connection. ; $unix_socket - specifies the socket or named pipe that should be used. (no pipe: "" (empty string)) ; $Client_Flag - flags to enable features ; Return values .: On Success - 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Open Call failed ; 3 - Database error - check _EzMySql_ErrMsg() for error ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Open($Host, $User, $Pass, $Database = "", $Port = 0, $unix_socket = "", $Client_Flag = 0) If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) Local $PWType = "str", $DBType = "str", $UXSType = "str" If $Pass = "" Then $PWType = "ptr" If $Database = "" Then $DBType = "ptr" If $unix_socket = "" Then $UXSType = "ptr" Local $conn = DllCall($hEzMySql_Dll, "ptr", "mysql_real_connect", "ptr", $hEzMySql_Ptr, "str", $Host, "str", $User, $PWType, $Pass, $DBType, $Database, "uint", $Port, $UXSType, $unix_socket, "ulong", $Client_Flag) If @error Then Return SetError(2, 0, 0) If _EzMySql_ErrMsg() Then Return SetError(3, 0, 0) Return 1 EndFunc ;==>_EzMySql_Open ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_ChangeUser ; Description ...: Changes the user and causes the database specified by db to become the default (current) database. ; Syntax.........: _EzMySql_ChangeUser($User, $Pass, $Database = "") ; Parameters ....: $User - MySQL login ID ; $Pass - password for user (no password: "" (empty string)) ; $Database - default database (no default db: "" (empty string)) ; Return values .: On Success - 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Open Call failed ; 3 - Database error - check _EzMySql_ErrMsg() for error ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_ChangeUser($User, $Pass, $Database = "") If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) Local $PWType = "str", $DBType = "str" If $Pass = "" Then $PWType = "ptr" If $Database = "" Then $DBType = "ptr" Local $conn = DllCall($hEzMySql_Dll, "int", "mysql_change_user", "ptr", $hEzMySql_Ptr, "str", $User, $PWType, $Pass, $DBType, $Database) If @error Then Return SetError(2, 0, 1) If _EzMySql_ErrMsg() Then Return SetError(3, 0, 0) Return 1 EndFunc ;==>_EzMySql_ChangeUser ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_SelectDB ; Description ...: Causes the database specified by db to become the default ; Syntax.........: _EzMySql_SelectDB($Database) ; Parameters ....: $Database - The new default database name ; Return values .: On Success - 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Open Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_SelectDB($Database) If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) Local $conn = DllCall($hEzMySql_Dll, "int", "mysql_select_db", "ptr", $hEzMySql_Ptr, "str", $Database) If @error Then Return SetError(2, 0, 1) Return 1 EndFunc ;==>_EzMySql_SelectDB ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Query ; Description ...: Query a single line MySql statement ; Syntax.........: _EzMySql_Query($querystring) ; Parameters ....: $querystring - MySql Statement ; Return values .: On Success - Returns 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Query Call failed ; 3 - Database error - check _EzMySql_ErrMsg() for error ; 4 - Dll Store result call failed ; 5 - Empty $querystring parameter passed to function ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Query($querystring) If Not $sEzMySql_Mutltiline Then _EzMySql_MultiLine(False) If $sEzMySql_Result Then _EzMySql_QueryFinalize() If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) If Not $querystring Then Return SetError(5, 0, 0) $querystringlength = StringLen($querystring) Local $query = DllCall($hEzMySql_Dll, "int", "mysql_real_query", "ptr", $hEzMySql_Ptr, "str", $querystring, "ulong", $querystringlength) If @error Then Return SetError(2, 0, 0) Local $result = DllCall($hEzMySql_Dll, "ptr", "mysql_store_result", "ptr", $hEzMySql_Ptr) If @error Then Return SetError(4, 0, 0) If _EzMySql_ErrMsg() Then Return SetError(3, 0, 0) $sEzMySql_Result = $result[0] Return 1 EndFunc ;==>_EzMySql_Query ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_QueryFinalize ; Description ...: Finalizes the last query, freeing the allocated memory ; Syntax.........: _EzMySql_QueryFinalize() ; Parameters ....: None ; Return values .: On Success - None ; Return values .: On Failure - returns 0 and @error value ; 2 - Dll Query Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_QueryFinalize() DllCall($hEzMySql_Dll, "none", "mysql_free_result", "ptr", $sEzMySql_Result) If @error Then Return SetError(2, 0, 0) $iEzMySql_Rows = 0 $iEzMySql_Columns = 0 $sEzMySql_Result = 0 EndFunc ;==>_EzMySql_QueryFinalize ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Exec ; Description ...: Executes a MySql query. Can be multi line . does not handle result ; Syntax.........: _EzMySql_Exec($querystring) ; Parameters ....: $querystring - MySql Statement ; Return values .: On Success - Returns 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Query Call failed ; 3 - Database error - check _EzMySql_ErrMsg() for error ; 4 - Dll Store result call failed ; 5 - Empty $querystring parameter passed to function ; Author ........: Yoriz Func _EzMySql_Exec($querystring) Local $execError, $iNextResult If $sEzMySql_Result Then _EzMySql_QueryFinalize() If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) If Not $querystring Then Return SetError(5, 0, 0) $querystringlength = StringLen($querystring) _EzMySql_MultiLine() Local $query = DllCall($hEzMySql_Dll, "int", "mysql_real_query", "ptr", $hEzMySql_Ptr, "str", $querystring, "ulong", $querystringlength) If @error Then $execError = 2 If _EzMySql_ErrMsg() Then Return SetError(3, 0, 0) Do Local $result = DllCall($hEzMySql_Dll, "ptr", "mysql_store_result", "ptr", $hEzMySql_Ptr) $sEzMySql_Result = $result[0] _EzMySql_QueryFinalize() $iNextResult = DllCall($hEzMySql_Dll, "int", "mysql_next_result", "ptr", $hEzMySql_Ptr) Until $iNextResult[0] <> 0 _EzMySql_MultiLine(False) If $execError Then Return SetError($execError, 0, 0) Return 1 EndFunc ;==>_EzMySql_Exec ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Rows ; Description ...: Returns row qty of the last MySql Query ; Syntax.........: _EzMySql_Rows() ; Parameters ....: None ; Return values .: On Success - Returns amount of rows ; Return values .: On Failure - returns -1 and @error value ; 1 - Dll Rows Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Rows() Local $aRows = DllCall($hEzMySql_Dll, "uint64", "mysql_num_rows", "ptr", $sEzMySql_Result) If @error Then Return SetError(1, 0, -1) $iEzMySql_Rows = $aRows[0] Return $iEzMySql_Rows EndFunc ;==>_EzMySql_Rows ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Columns ; Description ...: Returns column qty of the last MySql Query ; Syntax.........: _EzMySql_Columns() ; Parameters ....: None ; Return values .: On Success - Returns amount of columns ; Return values .: On Failure - returns -1 and @error value ; 1 - Dll column Call failed ; 2 - No result querry to check against ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Columns() If Not $sEzMySql_Result Then Return SetError(2, 0, 0) Local $aColumns = DllCall($hEzMySql_Dll, "uint", "mysql_num_fields", "ptr", $sEzMySql_Result) If @error Then Return SetError(1, 0, -1) $iEzMySql_Columns = $aColumns[0] Return $iEzMySql_Columns EndFunc ;==>_EzMySql_Columns ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_FetchNames ; Description ...: Returns column names of the last MySql Query ; Syntax.........: _EzMySql_FetchNames() ; Parameters ....: None ; Return values .: On Success - Returns 1d array of column names ; Return values .: On Failure - returns 0 and @error value ; 1 - Dll column Call failed or Coloumns = 0 ; 2 - Dll column names Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_FetchNames() Local $numberOfFields = _EzMySql_Columns() If $numberOfFields < 1 Then Return SetError(1, 0, $numberOfFields) Local $fields = DllCall($hEzMySql_Dll, "ptr", "mysql_fetch_fields", "ptr", $sEzMySql_Result) If @error Then Return SetError(2, 0, 0) $fields = $fields[0] Local $struct = DllStructCreate($hEzMySql_Field, $fields) Local $arFields[$numberOfFields] For $i = 1 To $numberOfFields $arFields[$i - 1] = _EzMySql_PtrStringRead(DllStructGetData($struct, 1)) If $i = $numberOfFields Then ExitLoop $struct = DllStructCreate($hEzMySql_Field, $fields + (DllStructGetSize($struct) * $i)) Next Return $arFields EndFunc ;==>_EzMySql_FetchNames ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_FetchData ; Description ...: Fetches 1 row of data from the last MySql Query ; Syntax.........: _EzMySql_FetchData() ; Parameters ....: None ; Return values .: On Success - Returns 1d array of row data ; Return values .: On Failure - returns 0 and @error value ; 1 - no columns found ; 2 - no rows found ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_FetchData() Local $NULLasPtr0 = False $fields = _EzMySql_Columns() If $fields <= 0 Or $sEzMySql_Result = 0 Then Return SetError(1, 0, 0) Local $RowArr[$fields] Local $mysqlrow = _EzMySql_Fetch_Row() If Not IsDllStruct($mysqlrow) Then Return SetError(2, 0, 0) Local $lenthsStruct = _EzMySql_Fetch_Lengths() Local $length, $fieldPtr For $i = 1 To $fields $length = DllStructGetData($lenthsStruct, 1, $i) $fieldPtr = DllStructGetData($mysqlrow, 1, $i) Select Case $length ; if there is data $RowArr[$i - 1] = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1) Case $NULLasPtr0 And Not $fieldPtr ; is NULL and return NULL as Ptr(0) $RowArr[$i - 1] = Ptr(0) ;~ Case Else ; Empty String or NULL as empty string ; Nothing needs to be done, since array entries are default empty string ;~ $RowArr[$i - 1] = "" EndSelect Next Return $RowArr EndFunc ;==>_EzMySql_FetchData ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_GetTable2d ; Description ...: Passes out a 2Dimensional array containing Column names and Data of executed Query ; Syntax.........: _EzMySql_GetTable2d($querystring) ; Parameters ....: $querystring - MySql Statement ; Return values .: On Success - Returns 2d array with Column names in index[0] and rows of data ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Query Call failed ; 3 - Database error - check _EzMySql_ErrMsg() for error ; 4 - Dll Store result call failed ; 5 - Empty $querystring parameter passed to function ; 6 - Fetch column names failed ; 7 - Fetch row qty failed ; 8 - Fetch column qty failed ; Author ........: Yoriz ; =============================================================================================================================== Func _EzMySql_GetTable2d($querystring) Local $aResult Local $QueryResult = _EzMySql_Query($querystring) If Not $QueryResult Then Return SetError($QueryResult, 0, 0) Local $FetchNameResult = _EzMySql_FetchNames() If Not IsArray($FetchNameResult) Then Return SetError(6, 0, 0) Local $iRows = _EzMySql_Rows() If $iRows = -1 Then Return SetError(7, 0, 0) Local $iColumns = _EzMySql_Columns() If $iColumns = -1 Then Return SetError(8, 0, 0) Local $aResult[$iRows + 1][$iColumns] For $i = 0 To $iColumns - 1 Step 1 $aResult[0][$i] = $FetchNameResult[$i] Next If $iRows Then For $iRowNo = 1 To $iRows $aResultFetched = _EzMySql_FetchData() For $iColumnNo = 0 To $iColumns - 1 Step 1 $aResult[$iRowNo][$iColumnNo] = $aResultFetched[$iColumnNo] Next Next EndIf Return $aResult EndFunc ;==>_EzMySql_GetTable2d ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_AddTable2d ; Description ...: Add an array of data to a speicifed table ; Syntax.........: _EzMySql_AddTable2d($sTableName, $aData, $sDelimeter) ; Parameters ....: $sTableName - Name of the table to add data to ; Parameters ....: $aData - An array of data to add with the column names in index 0 ; Return values .: On Success - Returns 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Query Call failed ; 3 - Database error - check _EzMySql_ErrMsg() for error ; 4 - Dll Store result call failed ; 5 - Empty $querystring parameter passed to function ; 6 - Emprty $sTableName parameter passed to function ; 7 - $aData is not an array ; 9 - $aData is not a 2d array ; Author ........: Yoriz Func _EzMySql_AddTable2d($sTableName, $aData) Local $querystring, $iResult If Not $sTableName Then Return SetError(6, 0, 0) If Not IsArray($aData) Then Return SetError(7, 0, 0) If Not UBound($aData) > 1 Then Return SetError(8, 0, 0) If Not UBound($aData, 2) Then Return SetError(9, 0, 0) Local $iColumns = UBound($aData,2)-1 For $iRow = 1 To UBound($aData)-1 $querystring &= "INSERT INTO " & $sTableName & " (" For $i = 0 To $iColumns Step 1 $querystring &= $aData[0][$i] & "," Next $querystring = StringTrimRight($querystring, 1) $querystring &= ") VALUES ('" For $i = 0 To $iColumns Step 1 $querystring &= $aData[$iRow][$i] & "','" Next $querystring = StringTrimRight($querystring, 2) $querystring &= ");" Next If Not _EzMySql_Exec($querystring) Then Return SetError(@error, 0, 0) Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Changes ; Description ...: After executing a statement returns the number of rows changed ; Syntax.........: _EzMySql_FetchNames() ; Parameters ....: None ; Return values .: On Success - Returns the number of rows changed ; Return values .: On Failure - returns -1 and @error value ; 1 - Dll column Call failed ; 2 - A MySQL struct does not exist ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Changes() If Not $hEzMySql_Ptr Then Return SetError(2, 0, -1) Local $row = DllCall($hEzMySql_Dll, "uint64", "mysql_affected_rows", "ptr", $hEzMySql_Ptr) If @error Then Return SetError(1, 0, -1) Return $row[0] ;~ Return __MySQL_ReOrderULONGLONG($row[0]) EndFunc ;==>_EzMySql_Changes ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_ErrMsg ; Description ...: returns a null-terminated string containing the error message for the most recen function that failed. ; Syntax.........: _EzMySql_ErrMsg() ; Parameters ....: None ; Return values .: On Success - A null-terminated character string that describes the error. An empty string if no error occurred ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_ErrMsg() If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) Local $errors = DllCall($hEzMySql_Dll, "str", "mysql_error", "ptr", $hEzMySql_Ptr) If @error Then Return SetError(2, 0, 0) If $errors[0] Then Return $errors[0] Return 0 EndFunc ;==>_EzMySql_ErrMsg ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_InsertID ; Description ...: Returns the value generated for an AUTO_INCREMENT column by the previous INSERT or UPDATE statement. ; Syntax.........: _EzMySql_InsertID() ; Parameters ....: None ; Return values .: On Success - AUTO_INCREMENT columnID ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_InsertID() If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) Local $row = DllCall($hEzMySql_Dll, "uint64", "mysql_insert_id", "ptr", $hEzMySql_Ptr) If @error Then Return SetError(2, 0, 0) Return $row[0] EndFunc ;==>_EzMySql_InsertID ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Close ; Description ...: Closes MySql Database ; Syntax.........: _EzMySql_Close() ; Parameters ....: None ; Return values .: On Success - 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Close() If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) If $sEzMySql_Result Then _EzMySql_QueryFinalize() DllCall($hEzMySql_Dll, "none", "mysql_close", "ptr", $hEzMySql_Ptr) If @error Then Return SetError(2, 0, 0) Return 1 EndFunc ;==>_EzMySql_Close ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_ShutDown ; Description ...: Closes MySQL DLL to free memory used by MySQL and closes Dll ; Syntax.........: _EzMySql_ShutDown() ; Parameters ....: None ; Return values .: None ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_ShutDown() DllCall($hEzMySql_Dll, "none", "mysql_server_end") DllClose($hEzMySql_Dll) $hEzMySql_Ptr = 0 $hEzMySql_Dll = 0 EndFunc ;==>_EzMySql_ShutDown ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_MultiLine ; Description ...: Allow multiple statements in a single string (separated by “;”). ; Syntax.........: _EzMySql_MultiLine($fBol = True) ; Parameters ....: $fBol - True = on, False = off ; Return values .: On Success - 1 ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_MultiLine($fBol = True) $sEzMySql_Mutltiline = 1 If $fBol Then $sEzMySql_Mutltiline = 0 If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) Local $mysql = DllCall($hEzMySql_Dll, "int", "mysql_set_server_option", "ptr", $hEzMySql_Ptr, "dword", $sEzMySql_Mutltiline) If @error Then Return SetError(2, 0, 0) Return 1 EndFunc ;==>_EzMySql_MultiLine ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Fetch_Row ; Description ...: Retrieves the next row of a result set. ; Syntax.........: _EzMySql_Fetch_Row() ; Parameters ....: None ; Return values .: On Success - DLLStruct with pointers to data fields ; Return values .: On Failure - returns 0 and @error value ; 1 - Dll column Call failed or Coloumns = 0 ; 2 - Dll fetch row Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Fetch_Row() Local $numberOfFields = _EzMySql_Columns() If $numberOfFields <= 0 Then Return SetError(2, 0, 0) Local $row = DllCall($hEzMySql_Dll, "ptr", "mysql_fetch_row", "ptr", $sEzMySql_Result) If @error Then Return SetError(1, 0, 0) Return DllStructCreate("ptr[" & $numberOfFields & "]", $row[0]) EndFunc ;==>_EzMySql_Fetch_Row ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_Fetch_Lengths ; Description ...: Returns the lengths of the columns of the current row within a result set. ; Syntax.........: _EzMySql_Fetch_Lengths() ; Parameters ....: None ; Return values .: On Success - DLLStruct with ulong Array get data [ DLLStructGetData($struct,1, $n ) ] ; Return values .: On Failure - returns 0 and @error value ; 1 - Dll column Call failed or Coloumns = 0 ; 2 - Dll fetch length Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_Fetch_Lengths() Local $numberOfFields = _EzMySql_Columns() If $numberOfFields <= 0 Then Return SetError(1, 0, 0) Local $lengths = DllCall($hEzMySql_Dll, "ptr", "mysql_fetch_lengths", "ptr", $sEzMySql_Result) If @error Then Return SetError(2, 0, 0) Return DllStructCreate("ulong lengths[" & $numberOfFields & "]", $lengths[0]) EndFunc ;==>_EzMySql_Fetch_Lengths ;=============================================================================== ; Function Name: _EzMySql_PtrStringRead ; Description:: Reads a string by pointer ; Parameter(s): $ptr - Pointer to String ; $IsUniCode - Is a unicode string default. False ; Requirement(s): libmysql.dll ; Return Value(s): read string ; Author(s): Prog@ndy ;=============================================================================== Func _EzMySql_PtrStringRead($ptr, $IsUniCode = False, $StringLen = -1) Local $UniCodeString = "" If $IsUniCode Then $UniCodeString = "W" If $StringLen < 1 Then $StringLen = _EzMySql_PtrStringLen($ptr, $IsUniCode) If $StringLen < 1 Then Return SetError(1, 0, "") Local $struct = DllStructCreate($UniCodeString & "char[" & ($StringLen + 1) & "]", $ptr) Return DllStructGetData($struct, 1) EndFunc ;==>_EzMySql_PtrStringRead ;=============================================================================== ; Function Name: _EzMySql_PtrStringLen ; Description:: Gets length for a string by pointer ; Parameter(s): $ptr - Pointer to String ; $IsUniCode - Is a unicode string default. False ; Requirement(s): libmysql.dll ; Return Value(s): Length of the string ; Author(s): Prog@ndy ;=============================================================================== Func _EzMySql_PtrStringLen($ptr, $IsUniCode = False) Local $UniCodeFunc = "" If $IsUniCode Then $UniCodeFunc = "W" Local $Ret = DllCall("kernel32.dll", "int", "lstrlen" & $UniCodeFunc, "ptr", $ptr) If @error Then Return SetError(1, 0, -1) Return $Ret[0] EndFunc ;==>_EzMySql_PtrStringLen Edit 20/6/2010 added _EzMySql_AddTable2d1 point
-
MySQL UDFs using libmysql.dll functions: most functions from MySQL API all are prefixed with an underscore: _MySql... e.g.: _MySQL_Real_Query( sometimes parameters are chaged - read function descriptions in include file MySQL.au3 If you do not need the power of these UDFs and you simple want to use basic SQL commands, then have a look at not included: MySQL_Connect - This function is deprecated. Use _MySQL_Real_Connect instead. MySQL_Create_DB - This function is deprecated. Use mysql_query() to issue an SQL CREATE DATABASE statement instead. MySQL_Drop_DB - This function is deprecated. Use mysql_query() to issue an SQL DROP DATABASE statement instead. MySQL_Escape_String - You should use _mysql_real_escape_string() instead! MySQL_Kill - This function is deprecated. Use mysql_real_query() to issue an SQL KILL statement instead mysql_library_end - Called by _MySQL_EndLibrary. mysql_library_init - Called by _MySQL_InitLibrary. I included a fallback-libmysql.dll: yoou can include libMySQLDLL.au3 and set $Use_EmbeddedDLL=True when calling _MySQL_InitLibrary an example for XAMPP / cdcol is also included in ZIP. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.8.1 (beta) Author: Prog@ndy Script Function: MySQL-Plugin Demo Script #ce ---------------------------------------------------------------------------- #include <array.au3> #include "mysql.au3" ; MYSQL starten, DLL im PATH (enthält auch @ScriptDir), sont Pfad zur DLL angeben. DLL muss libmysql.dll heißen. _MySQL_InitLibrary() If @error Then Exit MsgBox(0, '', "could nit init MySQL") MsgBox(0, "DLL Version:",_MySQL_Get_Client_Version()&@CRLF& _MySQL_Get_Client_Info()) $MysqlConn = _MySQL_Init() ;Fehler Demo: MsgBox(0,"Error-demo","Error-Demo") $connected = _MySQL_Real_Connect($MysqlConn,"localhostdfdf","droot","","cdcol") If $connected = 0 Then $errno = _MySQL_errno($MysqlConn) MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn)) If $errno = $CR_UNKNOWN_HOST Then MsgBox(0,"Error:","$CR_UNKNOWN_HOST" & @LF & $CR_UNKNOWN_HOST) Endif ; XAMPP cdcol MsgBox(0, "XAMPP-Cdcol-demo", "XAMPP-Cdcol-demo") $connected = _MySQL_Real_Connect($MysqlConn, "localhost", "root", "", "cdcol") If $connected = 0 Then Exit MsgBox(16, 'Connection Error', _MySQL_Error($MysqlConn)) $query = "SELECT * FROM cds" $mysql_bool = _MySQL_Real_Query($MysqlConn, $query) If $mysql_bool = $MYSQL_SUCCESS Then MsgBox(0, '', "Query OK") Else $errno = _MySQL_errno($MysqlConn) MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn)) EndIf $res = _MySQL_Store_Result($MysqlConn) $fields = _MySQL_Num_Fields($res) $rows = _MySQL_Num_Rows($res) MsgBox(0, "", $rows & "-" & $fields) ; Access2 1 MsgBox(0, '', "Access method 1- manual") Dim $array[$rows][$fields] For $k = 1 To $rows $mysqlrow = _MySQL_Fetch_Row($res,$fields) $lenthsStruct = _MySQL_Fetch_Lengths($res) For $i = 1 To $fields $length = DllStructGetData($lenthsStruct, 1, $i) $fieldPtr = DllStructGetData($mysqlrow, 1, $i) $data = DllStructGetData(DllStructCreate("char[" & $length & "]", $fieldPtr), 1) $array[$k - 1][$i - 1] = $data Next Next _ArrayDisplay($array) ; Access 2 MsgBox(0, '', "Access method 2 - row for row") _MySQL_Data_Seek($res, 0) ; just reset the pointer to the beginning of the result set Do $row1 = _MySQL_Fetch_Row_StringArray($res) If @error Then ExitLoop _ArrayDisplay($row1) Until @error ; Access 3 MsgBox(0, '', "Access method 3 - read whole result in 2D-Array") $array = _MySQL_Fetch_Result_StringArray($res) _ArrayDisplay($array) ; fieldinfomation MsgBox(0, '', "Access fieldinformation") Dim $arFields[$fields][3] For $i = 0 To $fields - 1 $field = _MySQL_Fetch_Field_Direct($res, $i) $arFields[$i][0] = _MySQL_Field_ReadValue($field, "name") $arFields[$i][1] = _MySQL_Field_ReadValue($field, "table") $arFields[$i][2] = _MySQL_Field_ReadValue($field, "db") Next _ArrayDisplay($arFields) ; free result _MySQL_Free_Result($res) ; Close connection _MySQL_Close($MysqlConn) ; exit MYSQL _MySQL_EndLibrary() MySQL UDf Downloads: (including x86 and x64)</array.au3>1 point
-
UI Automation Events In standard Windows GUI code, you can respond to Windows messages by registering and implementing a message handler function. A WM_NOTIFY message handler is registered and implemented in this way: ; Registration GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Implementation Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) ; Code EndFunc The WM_NOTIFY function is a callback function. In UI Automation code, you can respond to UI Automation events by registering and implementing an event handler object. A FocusChangedEventHandler object is registered and implemented in this way: ; Registration UIAEH_FocusChangedEventHandlerCreate() $oUIAutomation.AddFocusChangedEventHandler( 0, $oUIAEH_FocusChangedEventHandler ) ; Implementation ; This is the function that receives events Func UIAEH_FocusChangedEventHandler_HandleFocusChangedEvent( $pSelf, $pSender ) ; Code EndFunc $oUIAEH_FocusChangedEventHandler is the event handler object. It's a callback object. This thread is about how to respond to UI Automation events by registering, implementing and using event handler objects. User Defined Functions Registering and implementing the event handler object in the code above is very simple. To make it that simple, it's necessary to include a few functions in a UDF. The zip-file at bottom of post contains a UIAEH_FocusChangedEventHandler.au3 UDF that allows the registration and implementation of the event handler object as simple as shown above. UIAEH_FocusChangedEventHandlerCreate() is a function in this UDF. The function creates the $oUIAEH_FocusChangedEventHandler object. Because this is a callback object it must be implemented through ObjectFromTag() (coded in ObjectFromTag.au3 in zip-file) function by trancexx and not through the usual ObjCreateInterface() which is used to create other UI Automation objects. (The warning at top of the help text is much more an error in the help text than an error in the function. Thousands of examples show that ObjCreateInterface() works flawlessly.) You don't need to use ObjectFromTag() in your own code. This function is completely handled in the UDFs. UIAEH_FocusChangedEventHandler_HandleFocusChangedEvent() is the function that receives events. This function is coded but commented out in UIAEH_FocusChangedEventHandler.au3. Copy this function to your own code. See FocusChangedEventHandler example below. UIA Event Handlers The first version of Microsoft's UI Automation code (the Windows 7 version that works on Windows XP, Windows Vista, Windows 7 and all later versions) implements four different event handler objects. In addition to the FocusChangedEventHandler object, it's the AutomationEventHandler, PropertyChangedEventHandler and StructureChangedEventHandler objects. The zip-file at the bottom contains the corresponding three event handler UDFs. By the way, these four event handlers are implemented in AutoIt several years ago in this and the following posts. FocusChangedEventHandler exposes a method to handle events that are raised when the keyboard focus moves to another UI Automation element. AutomationEventHandler exposes a method to handle Microsoft UI Automation events. These events include MenuOpened ($UIA_MenuOpenedEventId) and Window_WindowOpened ($UIA_Window_WindowOpenedEventId) events. See module UIA_EventIds in UIA_Constants.au3 for a complete list. Note that EventIds that belong to Windows 8 or later cannot be used in this version of the event handler. But they can be used after code updates over the coming weeks. 2019-12-15 If you select Desktop, AutomationEvent and all Events (Event Ids) in UI Automation Event Monitor below and click Start, you'll see the following output in SciTE console: $oUIAEH_AutomationEventHandler OK Desktop: AddAutomationEventHandler() = AsyncContentLoaded OK Desktop: AddAutomationEventHandler() = AutomationFocusChanged ERR Desktop: AddAutomationEventHandler() = AutomationPropertyChanged OK Desktop: AddAutomationEventHandler() = InputDiscarded OK Desktop: AddAutomationEventHandler() = InputReachedOtherElement OK Desktop: AddAutomationEventHandler() = InputReachedTarget OK Desktop: AddAutomationEventHandler() = Invoke_Invoked OK Desktop: AddAutomationEventHandler() = LayoutInvalidated OK Desktop: AddAutomationEventHandler() = MenuClosed OK Desktop: AddAutomationEventHandler() = MenuModeEnd OK Desktop: AddAutomationEventHandler() = MenuModeStart OK Desktop: AddAutomationEventHandler() = MenuOpened OK Desktop: AddAutomationEventHandler() = Selection_Invalidated OK Desktop: AddAutomationEventHandler() = SelectionItem_ElementAddedToSelection OK Desktop: AddAutomationEventHandler() = SelectionItem_ElementRemovedFromSelection OK Desktop: AddAutomationEventHandler() = SelectionItem_ElementSelected OK Desktop: AddAutomationEventHandler() = StructureChanged OK Desktop: AddAutomationEventHandler() = Text_TextChanged OK Desktop: AddAutomationEventHandler() = Text_TextSelectionChanged OK Desktop: AddAutomationEventHandler() = ToolTipClosed OK Desktop: AddAutomationEventHandler() = ToolTipOpened OK Desktop: AddAutomationEventHandler() = Window_WindowClosed OK Desktop: AddAutomationEventHandler() = Window_WindowOpened OK Note the error for the AutomationFocusChanged event handler (at the top of the list). I've found that there is an error, but so far have no explanation for it. PropertyChangedEventHandler exposes a method to handle Microsoft UI Automation events that occur when a property is changed. These events include Name ($UIA_NamePropertyId) and ValueValue ($UIA_ValueValuePropertyId) changes. See module UIA_PropertyIds in UIA_Constants.au3 for a complete list. Note that PropertyIds that belong to Windows 8 or later cannot be used in this version of the event handler. But they can be used after code updates over the coming weeks. StructureChangedEventHandler exposes a method to handle events that occur when the Microsoft UI Automation tree structure is changed. This event handler seems to be more valuable in eg. screen readers than in usual UI Automation code. NotificationEventHandler exposes a method to handle Microsoft UI Automation notification events. See this post. FocusChangedEventHandler example This is full code in Examples\FocusChangedEventHandlerEx.au3. Run the code in SciTE with F5. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include "..\Includes\UIAEH_FocusChangedEventHandler.au3" Example() Func Example() UIAEH_FocusChangedEventHandlerCreate() If Not IsObj( $oUIAEH_FocusChangedEventHandler ) Then Return ConsoleWrite( "$oUIAEH_FocusChangedEventHandler ERR" & @CRLF ) ConsoleWrite( "$oUIAEH_FocusChangedEventHandler OK" & @CRLF ) Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) Local $iError = $oUIAutomation.AddFocusChangedEventHandler( 0, $oUIAEH_FocusChangedEventHandler ) If $iError Then Return ConsoleWrite( "AddFocusChangedEventHandler() ERR" & @CRLF ) ConsoleWrite( "AddFocusChangedEventHandler() OK" & @CRLF ) HotKeySet( "{ESC}", "Quit" ) While Sleep(10) WEnd EndFunc Func Quit() UIAEH_FocusChangedEventHandlerDelete() Exit EndFunc ; This is the function that receives events Func UIAEH_FocusChangedEventHandler_HandleFocusChangedEvent( $pSelf, $pSender ) ; Ret: long Par: ptr ConsoleWrite( @CRLF & "UIAEH_FocusChangedEventHandler_HandleFocusChangedEvent: " & $pSender & @CRLF ) Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) $oSender.AddRef() ConsoleWrite( "Title = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _ "Class = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _ "Ctrl type = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _ "Ctrl name = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ "Handle = " & "0x" & Hex( UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & _ "Value = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ValueValuePropertyId ) & @CRLF ) Return 0x00000000 ; $S_OK #forceref $pSelf EndFunc ; Auxiliary function (for simple properties only) ; There must be only one instance of this function Func UIAEH_GetCurrentPropertyValue( $oSender, $iPropertyId ) Local $vPropertyValue $oSender.GetCurrentPropertyValue( $iPropertyId, $vPropertyValue ) Return $vPropertyValue EndFunc Test the code by opening the Desktop context menu and move the mouse over the menu items. When the mouse hovers over a menu item it gets focus. Exit with Esc. AutomationEventHandlerEx.au3 Test the example by opening some windows, menus and tooltips. PropertyChangedEventHandlerEx.au3 Open Windows Task Manager (Ctrl+Shift+Esc) and you'll get a whole bunch of property changed events. Note that to access Windows Task Manager (and other programs) on Windows 10, use #RequireAdmin in the script and run SciTE as administrator. StructureChangedEventHandlerEx.au3 Clicking on a folder in File/Windows Explorer treeview generates a lot of structure changed events. New examples will be added over the coming weeks. UI Automation Event Monitor UI Automation Event Monitor is a tool to detect UI Automation events. The first group of toolbar buttons is used to set up the UI Automation event handler. The images have a PropertyChangedEventHandler set up to monitor Name ($UIA_NamePropertyId) and ValueValue ($UIA_ValueValuePropertyId) property changes in Windows Task Manager. Note that to access Windows Task Manager (and other programs) on Windows 10, use #RequireAdmin in the script (UIAEHEvents.au3) and run SciTE as administrator. These four toolbar buttons are hot-track enabled with the technique used in this example. The buttons open four listviews to set up the event handler. All listviews have multiple selections enabled. Select multiple items at once and check a single item in/out to check all selected items in/out. Use mouse or Space key to check an item in/out. In the first image, the mouse hovers over the Top Windows button so that it's selected. In the second image, the Top Windows button is clicked so that the listview is opened. Moving the mouse over the next three buttons automatically opens the corresponding listviews due to hot-tracking. Click the toolbar button again to close the listview or move the mouse above the title bar. Windows Task Manager is checked in the Top Windows listview. The Event Handlers listview is enabled when a Top Window is checked. The Event Ids listview is enabled when the AutomationEvent event handler is checked. The Property Ids listview is enabled when the PropertyChanged event handler is checked. In Event Ids and Property Ids listview you can select an item by pressing the first letter on the keyboard. The second group of toolbar buttons is used to Start/Stop the event handler (or multiple event handlers), Pause/Continue updating the Events listview, and Clear the listview. Note that the Pause button only stops updating the listview. Events are still detected and stored in $aEvents array. All new events are added at the bottom of the listview when you click Continue or Stop. The Pause Main Loop button is used to stop the GUI main loop, which significantly increases the performance of the Events listview. When the GUI main loop is paused you can only click the Continue Main Loop button (same button as Pause Main Loop) and you can close the GUI. Events listview The Events listview is a virtual listview because of performance and to make it easy to constantly add new rows to the bottom of the listview. Nevertheless, there can still be performance issues when a lot of events are generated. To remedy these issues, it's possible to stop the GUI main loop with the Pause Main Loop button. This significantly increases the performance of the Events listview. When there are a large number of events (when many new rows are added quickly at the bottom of the listview), this procedure must be followed to stop the event handler (or multiple event handlers): Make sure the GUI main loop isn't paused. Click the Pause button (second toolbar group) to pause Events listview updates. Click the Stop button to stop the event handler. When there are a small number of events you can immediately click the Stop button. To test the UI Automation Event Monitor, try performing the four examples (in Examples\, briefly described above) through the monitor GUI. There'll probably be some GUI updates in the coming weeks. UIA Menu, Tooltip and Window Events Monitor is a simpler version of UI Automation Event Monitor that detects only MenuOpened, ToolTipOpened and Window_WindowOpened events (AutomationEvents). Updates Windows 8, Windows 8.1 and Windows 10 updates Threads UI Automation UDFs contains all include files. UIASpy - UI Automation Spy Tool is a GUI tool that provides information about windows and controls and their interconnection and provides functionality to generate sample code. UIASpy is essential for creating UI Automation code. In Using UI Automation Code in AutoIt you can find and download examples and read information about using UIA code. IUIAutomation MS framework automate chrome, FF, IE, .... created by junkew August 2013 is the first AutoIt thread on UIA code. Zip-file The zip contains source files for GUIs and examples. Note that UI Automation UDFs must be installed in the Includes folder. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Note that under Windows 7 and earlier versions, only the original four event handlers (AutomationEventHandler, FocusChangedEventHandler, PropertyChangedEventHandler, StructureChangedEventHandler) introduced in Windows 7 can be used. Comments are welcome. Let me know if there are any issues. UIAEHEvents.7z1 point
-
Hi all, a long time ago I wanted a comfortable tool to get information of a specified user in our active directory. After some searching I decided to create my own tool and "Userinfo" was born. displays all useful information about the user (retrieved from active directory) displays the PCs/NCs the user has (if this information can be retrieved from a database) displays the list of neighbours of the current user compares the active directoy groups of the selected user with another user unlock a locked account Feel free to adjust it to your needs Credits go to: Water for his excellent Active Directory UDF Ascend4nt for his Clipput.html Funkey for demonstrating how to check if a label is bold or not rasim for the example showing how to sort Listview Items DanyFirex for his Loga-Library. Included a modified version in the zip-File which also logs milliseconds. Update 2018-03-08: Release of v3.43. Changes from 2.80: ehrm, plenty. Multilanguage support is removed, but this version is translated to english. This time, the Zip file includes two versions: the stripped-down version, which uses only the active directory. This version should run out-of-the-box (hehe, a Domain is required. Wouldn't make much sense otherwise, would it?) the 'full' version. This needs to be adopted to your environment, because it requires some SQL Database connections to get information about the user's PC Update 2022-02-21: Release of v4.07 Changes: now the Userinfo uses waters excellent AD.UDF instead of some code of it improved interface lots of new abilities now uses the loga.udf to create a Logfile if started from scite or if the compiled exe ist launched with the /log parameter now there is not a stripped-down version and a "full version" of the code. Instead, before trying any database connection, the server to be queried is checked via ping. So the code should run out-of-the-box without changes, and you can edit the database queries to fit to your environment best regards, Marc Userinfo.zip userinfo_english v3.43.zip Userinfo 4.07.zip1 point
-
You should use ControlClick() with ClassNameNN parameter instead of X,Y coordinates in such case.1 point
-
Folder watcher doesn't work when folder has more than a few files
argumentum reacted to emendelson for a topic
This is terrific help. Thank you both. I'm away from my development machine for most of the day, but will work on this tonight (EST) and tomorrow. I'm extremely grateful!1 point -
look at controlclick. It will allow you to interact with a control even when the window does not have focus. As Misashi suggest - use command line. Look here for more information: http://www.get-itsolutions.com/notepad-silent-install-exe-msi-version/1 point
-
Google API key not working from script
Twincharger reacted to Danp2 for a topic
Looks like you are appending "?" to your URL even when $sData is empty. That's probably messing things up since your URL already contains all of your necessary information.1 point -
OutlookEX
water reacted to seadoggie01 for a file
This is an amazing UDF... if you use Outlook at all, get it. The code is logical and intuitive and there is a way to do anything you can think of. There are plenty of examples and the documentation is outstanding. Stop reading this and download it! It should be a part of the base includes. Water has done it again1 point