Leaderboard
Popular Content
Showing content with the highest reputation on 06/27/2020 in all areas
-
AutoIt MediaDevice Library Allows you to communicate with attached media and storage devices. What's MediaDevice Library? MediaDevice Allows you to communicate with attached media and storage devices. Features. List Files and Folders. Delete Files and Folders. Copy File From Device. Copy File To Device. Basic Usage: #include "..\MediaDevice.au3" Local $sDevice = _MD_DeviceGet() ;Get First Found Portable Device Local $oDevice = _MD_DeviceOpen($sDevice) Local $aDrives = _MD_DeviceGetDrives($oDevice) _ArrayDisplay($aDrives,"Storage Drives") _MD_DeviceClose($oDevice) More examples here. Check MediaDevice on GitHub. Saludos2 points
-
After seeing a number of threads talking about how to exchange efficiently messages between processes (Inter Process Communication), I decided to create a framework using Windows Messages WM_COPYDATA. What is new with this UDF you ask ? Well it will depends how familiar you are with IPC. One thing is sure, the simplicity of use and the fabulous speed are amazing. This is based on a Clients-Server approach. You can have an unlimited number of clients talking with a single server. You will have to define the protocol of communication between them, but the code you have to create is incredibly low. The UDF proposes 2 simple message properties of communication. The first (called data) is based on a number. You can decide what value 1,2,3, etc. means between your client and server. Server will react upon the value of the data field. Second, there is a string field where you can inscribe additional information on request, and where the server will respond to client request (if necessary). Here are the functions that I have wrapped around this : Func _WCD_CreateServer Func _WCD_CreateClient Func _WCD_GetServerHandle Func _WCD_IsServerAvailable Func _WCD_Send Func _WCD_WM_COPYDATA_CLIENT_HANDLER Func _WCD_Client_GetResponse Func _WCD_WM_COPYDATA_SERVER_HANDLER Func _WCD_Server_PeekRequest Func _WCD_Server_GetRequest Func _WCD_Server_IsRequestAvail Here an example of the server : #include <Constants.au3> #include <GUIConstants.au3> #include "WCD_IPC.au3" Opt ("MustDeclareVars", 1) $_WCD_Verbose = False ; make it True if you want to follow the convos. False is by default. Local $hServer = _WCD_CreateServer () Local $aReq, $iData While True If _WCD_Server_IsRequestAvail () Then $aReq = _WCD_Server_GetRequest () $iData = @extended Switch $iData Case 1 ; who are you _WCD_Send($hServer, $aReq[0], $iData, @ComputerName) Case 2 Switch Number($aReq[1]) Case 1 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress1) Case 2 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress2) Case 3 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress3) Case 4 _WCD_Send($hServer, $aReq[0], $iData, @IPAddress4) Case Else _WCD_Send($hServer, $aReq[0], $iData, "Invalid parameter") EndSwitch EndSwitch EndIf Sleep (100) WEnd And the client : #include <Constants.au3> #include <GUIConstants.au3> #include "WCD_IPC.au3" Opt ("MustDeclareVars", 1) $_WCD_Verbose = True ; as for the server, you can decide to make client verbose or not Global $hWnd = _WCD_CreateClient ("Test WCD Client") Global $hWndServer = _WCD_GetServerHandle () _WCD_Send($hWnd, $hWndServer, 1) ; simple request - who are you ? Local $sString = WaitForResponse () ConsoleWrite ($sString & @CRLF) _WCD_Send($hWnd, $hWndServer, 2, "5") ; adding text to a more complex request $sString = WaitForResponse () ConsoleWrite ($sString & @CRLF) Func WaitForResponse () Local $sResp While _WCD_IsServerAvailable () $sResp = _WCD_Client_GetResponse () If $sResp <> "" Then Return $sResp Sleep (100) WEnd EndFunc As always, let me know if you got issues, comments, suggestions. I will be glad to answer. Version 2020-06-27 * Allows processes with different levels of privilege to communicate with each other WCD_IPC.au31 point
-
A simple fast IPC based on Windows Messaging
argumentum reacted to Nine for a topic
New version available : As per @argumentum suggestion, I added IPC between different levels of execution1 point -
1 point
-
Variable used without being declared error
jackiemagpie reacted to Zedna for a topic
While 1 PixelSearch(673,154,842,302,0xF8F4F8) If Not @error Then ExitLoop Sleep(10) WEnd1 point -
Variable used without being declared error
jackiemagpie reacted to Musashi for a topic
Local $WaitPixelColor = 0xF8F4F8, $waitpixel While 1 $waitpixel=PixelSearch (673,154,842,302, $WaitPixelColor) If Not @error Then ExitLoop Sleep(10) WEnd1 point -
Thanks! I'm glad you were able to get it all sorted out.1 point
-
When I ran your script I got this error : Unable to open MSSQL connection. @error = 5. I found that the $oConnection is missing so I added this line : Global $oConnection = ObjCreate("ADODB.Connection") If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to open MSSQL connection. @error = " & @error) I was able to open the connection with SQL and then I got this error : Unable to begin transactions. @error = 6. Update: For some reason it considers every _ADO_Execute as an error, so I removed those lines and it worked like a charm, @TheXman you're the best, can't thank you enough, thank you @jchd I appreciate your help. #include <ADO.au3> #include <Constants.au3> Local $sDriver = 'SQL Server' Local $sDatabase = 'AdventureWorks2016' ; change this string to YourDatabaseName Local $sServer = 'Localhost' ; change this string to YourServerLocation Local $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & ';PWD=' & ';' Global $sQUERY Global $aRecordset Local $oConnection = ObjCreate("ADODB.Connection") If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to open MSSQL connection. @error = " & @error) _ADO_EVENTS_SetUp(True) ;Open connection _ADO_Connection_OpenConString($oConnection, $sConnectionString) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to open MSSQL connection. @error = " & @error) ConsoleWrite("Connection opened." & @CRLF) ;Begin transaction _ADO_Execute($oConnection, "BEGIN TRANSACTION", True) ConsoleWrite("BEGIN TRANSACTION successful." & @CRLF) ;Update table _ADO_Execute($oConnection, "UPDATE HumanResources.Department SET GroupName = 'Research && Development' WHERE Name = 'Engineering'", True) ConsoleWrite("UPDATE successful." & @CRLF) ;Query table $aRecordset = _ADO_Execute($oConnection, "SELECT * FROM HumanResources.Department WHERE Name = 'Engineering'", True) ; setting $aRecordset with the result before rolling back ConsoleWrite("SELECT successful." & @CRLF) ;Rollback the update _ADO_Execute($oConnection, "ROLLBACK TRANSACTION", True) ConsoleWrite("ROLLBACK TRANSACTION successful." & @CRLF) ;Display query result (This is result set captured before rollback) _ADO_Recordset_Display($aRecordset, 'Query Result') $aRecordset = _ADO_Execute($oConnection, "SELECT * FROM HumanResources.Department WHERE Name = 'Engineering'", True) ; setting $aRecordset with the original result after rolling back ;Display query result (This is result set captured after rollback) _ADO_Recordset_Display($aRecordset, 'Query Result') ;Close connection _ADO_Connection_Close($oConnection) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to close MSSQL connection. @error = " & @error) ConsoleWrite("Connetion closed." & @CRLF)1 point
-
Thanks @TheXman that sounds much more reasonable! @Nas you typically open an SQL connection at application startup, use it by issuing SQL statements at will, then only close it at program termination, just like you generally do with a GUI. That's true for any SQL engine I can think of.1 point
-
I don't have a SQL Server instance installed at the moment so I can't test the script. Can you run the script below and see if it executes successfully and returns the expected results? If it fails with any errors, please post the error and the console log. #include <ADO.au3> #include <Constants.au3> Global $sDriver = 'SQL Server' Global $sDatabase = 'DataBase' ; change this string to YourDatabaseName Global $sServer = 'Localhost' ; change this string to YourServerLocation Global $sConnectionString = 'DRIVER={' & $sDriver & '};SERVER=' & $sServer & ';DATABASE=' & $sDatabase & ';UID=' & ';PWD=' & ';' Global $sQUERY Global $aRecordset Global $oConnection _ADO_EVENTS_SetUp(True) ;Open connection _ADO_Connection_OpenConString($oConnection, $sConnectionString) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to open MSSQL connection. @error = " & @error) ConsoleWrite("Connection opened." & @CRLF) ;Begin transaction _ADO_Execute($oConnection, "BEGIN TRANSACTION", True) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to begin transactions. @error = " & @error) ConsoleWrite("BEGIN TRANSACTION successful." & @CRLF) ;Update table _ADO_Execute($oConnection, "UPDATE table SET hour = 4 WHERE cust = 'TEST'", True) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to update table. @error = " & @error) ConsoleWrite("UPDATE successful." & @CRLF) ;Query table $aRecordset = _ADO_Execute($oConnection, "SELECT * FROM table WHERE cust = 'TEST'", True) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to update table. @error = " & @error) ConsoleWrite("SELECT successful." & @CRLF) ;Rollback the update _ADO_Execute($oConnection, "ROLLBACK TRANSACTION", True) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to rollback transactions. @error = " & @error) ConsoleWrite("ROLLBACK TRANSACTION successful." & @CRLF) ;Display query result (This is result set captured before rollback) _ADO_Recordset_Display($aRecordset, 'Query Result') ;Close connection _ADO_Connection_Close($oConnection) If @error Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to close MSSQL connection. @error = " & @error) ConsoleWrite("Connetion closed." & @CRLF)1 point
-
Got some time to look into it, still not quite sure why WinSetState does not work with this exe, but found a solution that is doing fine for me both Win7 and Win10 : #include <SendMessage.au3> #include <MenuConstants.au3> #include <WindowsConstants.au3> Run(@ComSpec & ' /c magnify.exe', "", @SW_HIDE) $hWnd = WinWait ("[CLASS:MagUIClass]") ConsoleWrite ($hWnd & @CRLF) Sleep (2000) _SendMessage ($hWnd, $WM_SYSCOMMAND, $SC_MINIMIZE)1 point