
l4tran
Active Members-
Posts
43 -
Joined
-
Last visited
Everything posted by l4tran
-
GraphGDIPlus UDF - Create GDI+ line graphs
l4tran replied to andybiochem's topic in AutoIt Example Scripts
Thanks that works. -
GraphGDIPlus UDF - Create GDI+ line graphs
l4tran replied to andybiochem's topic in AutoIt Example Scripts
Hi I'm trying to modify the UDF to output colours depending on the Y input data. I'm modifying the colour using RGB Dim $aColor[3] = [255, 255, 0] and then converting that into Hex using _ColorSetRGB($aColor) function to feed into $hPen = _GDIPlus_PenCreate(). What am I doing wrong? Func _GraphGDIPlus_Plot_Point(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return $hexcolour=getRGB($iY,0,$aGraphArray[9]) $hPen = _GDIPlus_PenCreate($hexcolour, 2) ;----- Draw point from previous point to new point ----- $iX = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $iY = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) $hPen1 = _GDIPlus_PenCreate(_StringToHex("000255000"), 2) _GDIPlus_GraphicsDrawRect($aGraphArray[17], $iX - 1, $iY - 1, 2, 2, $hPen) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- save current as last coords ----- $aGraphArray[18] = $iX $aGraphArray[19] = $iY EndFunc ;==>_GraphGDIPlus_Plot_Point Func getRGB($i,$min,$max) $i*=100 $max*=100 if $i < 0 then $i *= -1 if $i > $max then Return Dim $aColor[3] = [255, 255, 0] if $i < $max/2 Then $aColor[0] = Map($i,$min,$max/2,0,255) if $i > $max then $aColor[1] = Map($i,$max/2,$max,255,0) ConsoleWrite(" Red=" & Hex($aColor[0], 2) & " Green=" & Hex($aColor[1], 2) & " Blue=" & Hex($aColor[2], 2) & " Color=" & Hex(_ColorSetRGB($aColor)) & @CRLF) Return _ColorSetRGB($aColor) EndFunc ;==>getRGB Func Map($iValue, $iFromLow, $iFromHigh, $iToLow, $iToHigh) Return round(($iValue - $iFromLow) * ($iToHigh - $iToLow) / ($iFromHigh - $iFromLow) + $iTolow,0) EndFunc -
Crash in WM_COMMAND DllStructGetData()
l4tran replied to l4tran's topic in AutoIt General Help and Support
I don't understand what a "runnable replicatie script" is. Please explain. When I run the script, the program just hangs and then it self terminate. -
Hi, I'm trying to implement a double click event in a listview. But somehow it's crashing the program. I'm suspecting that it has something to do with DllStructGetData() function. Im running on version 3.3.16.1 Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $iCode = BitShift($wParam, 16) Switch $lParam Case GUICtrlGetHandle($inputSerial) If $iCode = $EN_SETFOCUS Then $inputFocus = $inputSerial Case GUICtrlGetHandle($inputWorkSlip) If $iCode = $EN_SETFOCUS Then $inputFocus = $inputWorkSlip Case GUICtrlGetHandle($inputMain) If $iCode = $EN_SETFOCUS Then $inputFocus = $inputMain EndSwitch $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $iCode Case $NM_DBLCLK If $iIDFrom = $idListview Then _EditListItem(_GUICtrlListView_GetItemText($idListview, _GUICtrlListView_GetHotItem($idListview))) EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND
-
Would this work on Office 2016?
-
I'm trying to convert " Chung Vầng Trăng Đợi " using your UDF but I'm getting "Chung V?ng Trang Ð?i". It suppose to be "Chung Vầng Trăng Đợi "
-
Yet another Access UDF( but different - *.accdb only)
l4tran replied to kcvinu's topic in AutoIt Example Scripts
Doesn't work. Return the same error. Even if it did, wouldn't I need to _Start_Connection() again? That is just the same as this... $GetData = _Get_Records("SELECT [Col1],[Col2] FROM Table1 WHERE Col3 = 'AutoIt Stone' ;") if not(isArray($GetData)) then _Close_Connection() _Start_Connection(@ScriptDir & "\Test.accdb;") endif -
Yet another Access UDF( but different - *.accdb only)
l4tran replied to kcvinu's topic in AutoIt Example Scripts
I using the code from your example. I don't have any problems with _Insert_Data(). #include "Access_UDF.au3" #include <Array.au3> $Connection = _Start_Connection(@ScriptDir & "\Test.accdb;") $InsertData = _Insert_Data("INSERT INTO Table1([Col1], [Col2], [Col3]) VALUES ('AutoIt', 'Coding is Fun', 'AutoIt Rocks');") $GetData = _Get_Records("SELECT [Col1],[Col2] FROM Table1 WHERE Col3 = 'AutoIt Stone' ;") msgbox(0,'',ubound($GetData)) $GetData = _Get_Records("SELECT [Col1],[Col2] FROM Table1 WHERE Col3 = 'AutoIt Rocks' ;") msgbox(0,'',ubound($GetData)) _Close_Connection() The first _Get_Records() function Where Col3 = 'Autoit Stone' doesn't return an array because it doesn't exist in the table but it leaves the object open, the second time I run _Get_Records() it will throw an error. See the error message above. The only way I can make it work is to call _Close_Connection() and _Start_Connection every time _Get_Records() doesn't return an array. $GetData = _Get_Records("SELECT [Col1],[Col2] FROM Table1 WHERE Col3 = 'AutoIt Stone' ;") if not(isArray($GetData)) then _Close_Connection() _Start_Connection(@ScriptDir & "\Test.accdb;") endif -
Yet another Access UDF( but different - *.accdb only)
l4tran replied to kcvinu's topic in AutoIt Example Scripts
Hello, great work. I ran into a problem while using this UDF Here is the Code.... $Connection = _Start_Connection(@ScriptDir & "\Test.accdb;") $InsertData = _Insert_Data("INSERT INTO Table1([Col1], [Col2], [Col3]) VALUES ('AutoIt', 'Coding is Fun', 'AutoIt Rocks');") $GetData = _Get_Records("SELECT [Col1],[Col2] FROM Table1 WHERE Col3 = 'AutoIt Stone' ;") msgbox(0,'',ubound($GetData)) $GetData = _Get_Records("SELECT [Col1],[Col2] FROM Table1 WHERE Col3 = 'AutoIt Rocks' ;") msgbox(0,'',ubound($GetData)) _Close_Connection() Basically I want to modify the Where clause to accept other conditions but I got an error the second time I ran _Get_Records(). Error message "ADODB COM Error err.description is: Operation is not allowed when the ojbect is open." How do I close the object when _Get_Records() returns nothing? Anybody know how to fix this without using _Close_Connection() and _Start_Connection() again.... -
Sorry for resurrecting an old thread. I am running autoit ver. 3.3.14, I'm getting errors when I try to run this program. "Error: DllStructSize(), DllStructSet(), DllStructPtr(), DllStructGet(), DllStructFree() undefined function." I tried replacing with DllStructGetSize(), DllStructSetData(), DllStructGetPtr(), DllStructGetData() and DllClose(), but got another error "DllCall("Winmm.dll","int","joyGetPosEx",^ ERROR". Anybody know how to get this working?
-
Anybody with here with Javascript experience? I am using AuCGI along with Google Map API via javascript to write a GPS tracker. I manage to get Google map to display along with a marker when I initialize the javascript. Suppose in the body, I have a new latitude and longitude, how do I pass these variables to marker1 and run marker1.setmap(map) to update the marker? <?au3 #NoTrayIcon _standardHeader() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <style type="text/css"> html, body, #map-canvas { height: 100%; margin: 0; padding: 0;} </style> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key="> </script> <script type="text/javascript"> function initialize() { var useragent = navigator.userAgent; var mapdiv = document.getElementById("map-canvas"); var mapOptions = { center: { lat: 43.61910797367798, lng: -79.55092150602343}, zoom: 11, panControl: false, zoomControl: false, scaleControl: true }; var map = new google.maps.Map(document.getElementById('map-canvas','mapOptions'),mapOptions); var myLatlng = new google.maps.LatLng(43.61910797367798,-79.75092150602343); var marker1 = new google.maps.Marker({ position: myLatlng, map:map, title:"Hello World!" }); if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 ) { mapdiv.style.width = '600px'; mapdiv.style.height = '800px'; } else { mapdiv.style.width = '100%'; mapdiv.style.height = '100%'; } ;marker1.setMap(map) } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <form name = "login" action="<?au3 inline($_SCRIPT_NAME) ?>" method="POST"> <center><br><br><br> <input id="user" name="user" value="Username"><br><br> <input id="pwd" name="pwd" value="password" type="password"><br><br> <button name="submit" value="submit">Submit</button> <button>Reset</button> <?au3 If _POST("submit") Then if _POST("user")="Username" and _POST("pwd")="password" Then echo ("works") echo ('<div id="map-canvas"></div>') for $i=1 to 10 sleep(3000) $new_lat=43.61910797367798 $new_lng=-80.75092150602343 + $i ;stuck how to pass these coordinates marker1 and run marker1.setmap(map) Next EndIf EndIf ?> </form> </body></html>
-
Found it and it works. Thanks.
-
That is all the code. What is pragma directive, and how do I use it? The Autoit version I'm using is 3.3.10.2. I compile it using ctrl+F7, then goto Resource Update tab, and enter the version number. Is this the correct way of doing it? MsgBox(0,"",FileGetVersion(@ScriptFullPath,"FileVersion")) gives me nothing.
-
How do I get the version number of my script. The output below is always 0.0.0.0, same even after I compiled it. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** MsgBox(0,"",FileGetVersion(@ScriptFullPath))
-
_SelfUpdate() - Update the running executable.
l4tran replied to guinness's topic in AutoIt Example Scripts
Oops sorry, I'll post it in another section. -
_SelfUpdate() - Update the running executable.
l4tran replied to guinness's topic in AutoIt Example Scripts
Hi newbie question, I'm running autoit v3.3.10.2. I'm getting 0.0.0.0 when I use MsgBox(0,"",FileGetVersion(@ScriptFullPath)) in my script. What am I missing? This is my Region: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=c:****.exe #AutoIt3Wrapper_Res_Fileversion=1.0.0.2 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** -
Programming an USB Relay Controller in Autoit
l4tran replied to Chris86's topic in AutoIt General Help and Support
Any success? Which board did you get? -
Hello everyone, I have created parent/child gui windows, how I do draw objects in Parents from Child? #include<file.au3> #include<array.au3> #include<GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <WinAPI.au3> #include <GuiMenu.au3> $parentx = 1200 $parenty = 700 $parent = GUICreate("Management", $parentx, $parenty, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) $file_menu = GUICtrlCreateMenu("File") $exit_item = GUICtrlCreateMenuItem("Exit", $file_menu) $tool_menu = GUICtrlCreateMenu("Tools") $setup_item = GUICtrlCreateMenuItem("Setup", $tool_menu) $help_menu = GUICtrlCreateMenu("Help") $about_item = GUICtrlCreateMenuItem("About", $help_menu) GUICtrlCreateGroup("Section E", 10, 10, 400, 400) #cs $Sections = IniReadSectionNames(@ScriptDir & "\wok-sections.ini") For $i = 1 To UBound($Sections) - 1 $Tables = IniReadSection(@ScriptDir & "\wok-sections.ini", $Sections[$i]) If IsArray($Tables) Then For $j = 1 To UBound($Tables) - 1 $Table_values = IniReadSection(@ScriptDir & "\wok-tables.ini", $Tables[$j][1]) If IsArray($Table_values) Then $dimension = IniReadSection(@ScriptDir & "\wok-tabledimension.ini", $Table_values[3][1]) ;_ArrayDisplay($dimension) $Tables[$j][0] = GUICtrlCreateButton($Tables[$j][1], Int($Table_values[1][1]), Int($Table_values[2][1]), Int($dimension[1][1]), Int($dimension[2][1])) If Not (StringInStr($Table_values[3][1], "rec")) Then GUICtrlSetImage(-1, $dimension[3][1]) EndIf Next EndIf Next #ce GUISetState(@SW_SHOW) $child = GUICreate("Phim 88 ", 500, 400, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_WINDOWEDGE, $WS_EX_MDICHILD), $parent) GUICtrlCreateGroup("Add Table(s)", 10, 10, 480, 380) GUICtrlCreateLabel("Section", 20, 30, 40) $Section = GUICtrlCreateCombo("", 60, 25, 75, 20) GUICtrlSetData(-1, "Section-A|Section-B|Section-C|Section-D|Section-E|Section-F", "") GUICtrlCreateLabel("Name", 20, 60, 40) $Name = GUICtrlCreateInput("", 60, 55, 75, 20) GUICtrlCreateLabel("Top", 140, 30, 40) $top = GUICtrlCreateInput("", 170, 25, 40, 20) GUICtrlCreateLabel("Left", 140, 60, 40) $left = GUICtrlCreateInput("", 170, 55, 40, 20) GUICtrlCreateLabel("Shape", 220, 30, 40) $shape = GUICtrlCreateCombo("", 260, 25, 135, 20) GUICtrlSetData(-1, "recv-4ppl|rech-4ppl|oval-8ppl", "recv-4ppl") GUICtrlCreateLabel("Image", 220, 60, 40) $image = GUICtrlCreateInput("", 260, 55, 135, 20) $btn1=GUICtrlCreateButton("Create Grid in Parent",70,90,200) GUISetState(@SW_HIDE) While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $parent Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $about_item MsgBox(8192, "about", "Parent Child Windows") Case $setup_item GUISetState(@SW_SHOW, $child) EndSwitch Case $child Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $child) Case $Section $Tables = IniReadSection(@ScriptDir & "\wok-sections.ini", GUICtrlRead($Section)) If IsArray($Tables) Then $num = Int(StringRight($Tables[UBound($Tables) - 1][1], 2)) + 1 GUICtrlSetData($Name, StringRight(GUICtrlRead($Section), 1) & String($num)) Else GUICtrlSetData($Name, StringRight(GUICtrlRead($Section), 1) & "1") _ArrayDisplay($Tables) EndIf Case $btn1 drawgrid() MsgBox(0,"","I want to draw the grid numbers in the parent windows from here") EndSwitch EndSwitch WEnd Func drawgrid() Dim $gridx[1], $gridy[1] $i = 0 For $x = 0 To $parentx Step 50 ReDim $gridx[UBound($gridx) + 1] $gridx[$i] = GUICtrlCreateLabel($x, $x, 0, 20, 20) GUICtrlSetState(-1, $gui_disable) $i += 1 Next $i = 0 For $y = 0 To $parenty Step 50 ReDim $gridy[UBound($gridy) + 1] $gridx[$i] = GUICtrlCreateLabel($y, 0, $y, 20, 20) GUICtrlSetState(-1, $gui_disable) $i += 1 Next EndFunc ;==>drawgrid
-
I found that the return message for tcpsend() and tcprecv() is not reliable, so I improved on it. The purpose of this is to send large amount of data with error checking in between. Basically, the data that is being sent is converted from a string to binary and then compressed. The compressed binary is then split into an array, each element being 1000 character in length. Each element is then sent to the receiver and expect the receiver to reply with a confirmation before continue sending the rest. On the receiving end, each element is compiled back into an array, and then from the array back into binary and finally decompressed back to string. This works well with files smaller than 5 megs. #include #include Global $skey = "blah123" ;Encryption key ; #FUNCTION# ==================================================================================================================== ; Name...........: SendData ; Description....: Send compress string using TCPSend() ; Syntax.........: SendData($iSock, $PacketSize, $sData, $msgBuffer, [1|0], n, [1|0], $progress) ; Parameters.....: $iSock - Socket ID ; $PacketSize - Size of receiving packets ; $sData - string to send ; $msgBuffer - Buffer storage for incoming data ; $iEncrytion - true|false to encryption $sData ; $iRetry - the number of time to retry sending data ; $iConfirmation - true|false if data is expected to be return from recipiant ; $progress - $progressbar id from GUICtrlCreateProgress() if used ; Return values..: Success: The uncompress data from ReceiveData() function ; Failure: -1 if error from socket ; 0 if $msgBuffer is not empty ; Remarks........: if string len of $sData < 100, the compressed binary size of $sData may be larger than original uncompressed ; Author.........: l4tran ; =============================================================================================================================== Func SendData(ByRef $iSock, $PacketSize, $sData, ByRef $msgBuffer, $iEncrypt = 0, $iRetry = 3, $iConfirmation = 0, $progress = 0) Local $aData[1] Local $sRecv = "" local $iSplitSize = 1000 $msgBuffer &= TCPRecv($iSock,$PacketSize) ;check status of socket and check for incoming data if @error Then $iSock = -1 ConsoleWrite("Resetting Sock:"&$iSock&" to -1"&@crlf) return -1 EndIf if $msgBuffer <> "" then return 0 ;do not send if there are incoming data $iCompressionBefore = BinaryLen(StringToBinary($sData)) $sData=Compress($sData) ;compression $sData using UDF from trancexx $iCompressionAfter = BinaryLen($sData) ;display compression ratio ConsoleWrite(@crlf&"Compression ratio: "&$iCompressionBefore&':'&$iCompressionAfter&" Percentage: "&100-Round($iCompressionAfter/$iCompressionBefore*100,2)&'%'&@CRLF) If $iEncrypt = 1 Then $sData = _StringEncrypt(1, $sData, $skey) ;Encrypt string if true If StringLen($sData) > $iSplitSize Then ;Split $sData into elements of string size 1000 and store it into an array While StringLen($sData) > $iSplitSize ReDim $aData[UBound($aData) + 1] $aData[UBound($aData) - 2] = StringLeft($sData, $iSplitSize) $sData = StringTrimLeft($sData, $iSplitSize) WEnd EndIf $aData[UBound($aData) - 1] = $sData If $iRetry = 0 Then Return 0 For $i = 0 To UBound($aData) - 1 ;Starting sending each element in the array GUICtrlSetData($progress, Round($i / (UBound($aData) - 1) * 100)) ConsoleWrite(".") ;send confirmation string | Encryption status | element of $sData | and iConfirmation bit TCPSend($iSock, UBound($aData) - 1 & '~' & $i & '~' & $iEncrypt & '~' & $aData[$i] & '~' & $iConfirmation & @CRLF) $ConfirmSent = TimerInit() Do ;Check from recipiant if each element is received. $sRecv = TCPRecv($iSock, $PacketSize) If TimerDiff($ConfirmSent) > 2500 Then ExitLoop ;wait 2.5 seconds for return packet confirmation before attempting to resend element Until ($sRecv = UBound($aData) - 1 & '~' & $i) If $sRecv <> UBound($aData) - 1 & '~' & $i Then ;check for confirmation string from recipiant; confirmation string = size of array & current counter ConsoleWrite(".") ;retry sending SendData($iSock, $PacketSize, $aData[$i], $msgBuffer, $iEncrypt = 0, $iRetry - 1, $iConfirmation, $progress) EndIf $sRecv = "" Next If $iConfirmation Then ;check if data is to be returned from recipiant $ConfirmSent = TimerInit() Do $sData = ReceiveData($iSock, $PacketSize, $msgBuffer, $progress) If TimerDiff($ConfirmSent) > 20000 Then ExitLoop Until ($sData) ;check for confirmation sent request has completed Return $sData ;return data that was sent back from recipiant EndIf EndFunc ;==>SendData Func getPacket($iSock, $PacketSize, ByRef $msgBuffer) $sRecv = TCPRecv($iSock, $PacketSize) If $sRecv <> "" Then $msgBuffer &= $sRecv EndIf If StringInStr($msgBuffer, @CRLF) Then ;ConsoleWrite($msgBuffer & @CRLF) If StringInStr($msgBuffer, '~') Then $aMsgRecv = StringSplit($msgBuffer, '~') $msgBuffer = "" Return $aMsgRecv EndIf EndIf EndFunc ;==>getPacket ; #FUNCTION# ==================================================================================================================== ; Name...........: ReceiveData ; Description....: Receive compress string from TCPRecv() ; Syntax.........: ReceiveData($iSock, $PacketSize, ByRef $msgBuffer, $progress = 0) ; Parameters.....: $iSock - Socket ID ; $PacketSize - Size of receiving packets ; $msgBuffer - Buffer storage for incoming data ; $progress - $progressbar id from GUICtrlCreateProgress() if used ; Return values..: Success: The uncompress data from ReceiveData() function ; Failure: 0 if receiving data is not formatted properly ; Remarks........: if string len of $sData < 100, the compressed binary size of $sData may be larger than original uncompressed ; Author.........: l4tran ; =============================================================================================================================== Func ReceiveData($iSock, $PacketSize, ByRef $msgBuffer, $progress = 0) Local $aData[1], $iSize = 1, $iCounter = 0 $aMsgRecv = getPacket($iSock, $PacketSize, $msgBuffer) ;get first element of array to determine the size of array If IsArray($aMsgRecv) Then If UBound($aData) - 1 <> $aMsgRecv[1] Then ReDim $aData[$aMsgRecv[1] + 1] ;resizing array based on confirmation string $aData[$aMsgRecv[2]] = $aMsgRecv[4] ;adding first element into array TCPSend($iSock, $aMsgRecv[1] & '~' & $aMsgRecv[2]) ;send confirmation string back to sender; packet received successfully If $aMsgRecv[1] > 0 Then Do ;completing the rest of array $aMsgRecv = getPacket($iSock, $PacketSize, $msgBuffer) ;getting more element of array If IsArray($aMsgRecv) Then If $progress <> 0 Then GUICtrlSetData($progress, Round($iCounter / $iSize * 100, 0)) ;Update progress bar status $iSize = $aMsgRecv[1] ;Size of array $iCounter = $aMsgRecv[2] ;Current counter $aData[$iCounter] = $aMsgRecv[4] TCPSend($iSock, $aMsgRecv[1] & '~' & $aMsgRecv[2]) ;send confirmation string back to sender; packet received successfully EndIf Until ($iSize = $iCounter) ;complete until counter reaches size of array EndIf EndIf $sData = "" ;convert array back to string For $i = 0 To UBound($aData) - 1 $sData &= $aData[$i] Next If IsArray($aMsgRecv) Then ;check if string needs to be decrypted before returning If $aMsgRecv[3] = 1 Then Return BinaryToString(Decompress(_StringEncrypt(0,$sData, $skey))) & '|' & $aMsgRecv[5] ElseIf $aMsgRecv[3] = 0 Then Return BinaryToString(Decompress($sData)) & '|' & $aMsgRecv[5] EndIf EndIf $aMsgRecv = 0 Return 0 EndFunc ;==>ReceiveData Func Compress($binString, $iCompressionStrength = 1) If Not IsBinary($binString) Then $binString = Binary($binString) Local $tCompressed Local $tSource = DllStructCreate('byte[' & BinaryLen($binString) & ']') DllStructSetData($tSource, 1, $binString) _WinAPI_LZNTCompress($tSource, $tCompressed, $iCompressionStrength) Local $bincompressed = DllStructGetData($tCompressed, 1) $tSource = 0 Return Binary($bincompressed) EndFunc ;==>Compress Func Decompress($binString) If Not IsBinary($binString) Then $binString = Binary($binString) Local $tSource = DllStructCreate('byte[' & BinaryLen($binString) & ']') DllStructSetData($tSource, 1, $binString) Local $tDecompress _WinAPI_LZNTDecompress($tSource, $tDecompress) $tSource = 0 Local $bString = Binary(DllStructGetData($tDecompress, 1)) Return $bString EndFunc Func _WinAPI_LZNTDecompress(ByRef $tInput, ByRef $tOutput, $iBufferSize = 0x800000) Local $tBuffer, $Ret $tOutput = 0 $tBuffer = DllStructCreate('byte[' & $iBufferSize & ']') If @error Then Return SetError(1, 0, 0) $Ret = DllCall('ntdll.dll', 'uint', 'RtlDecompressBuffer', 'ushort', 0x0002, 'ptr', DllStructGetPtr($tBuffer), 'ulong', $iBufferSize, 'ptr', DllStructGetPtr($tInput), 'ulong', DllStructGetSize($tInput), 'ulong*', 0) If @error Then Return SetError(2, 0, 0) If $Ret[0] Then Return SetError(3, $Ret[0], 0) $tOutput = DllStructCreate('byte[' & $Ret[6] & ']') If Not _WinAPI_MoveMemory(DllStructGetPtr($tOutput), DllStructGetPtr($tBuffer), $Ret[6]) Then $tOutput = 0 Return SetError(4, 0, 0) EndIf Return $Ret[6] EndFunc ;==>_WinAPI_LZNTDecompress ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_LZNTCompress ; Description....: Compresses an input data. ; Syntax.........: _WinAPI_LZNTCompress ( $tInput, ByRef $tOutput [, $fMaximum] ) ; Parameters.....: $tInput - "byte[n]" or any other structure that contains the data to be compressed. ; $tOutput - "byte[n]" structure that is created by this function, and contain the compressed data. ; $fMaximum - Specifies whether use a maximum data compression, valid values: ; |TRUE - Uses an algorithm which provides maximum data compression but with relatively slower performance. ; |FALSE - Uses an algorithm which provides a balance between data compression and performance. (Default) ; Return values..: Success - The size of the compressed data, in bytes. ; Failure - 0 and sets the @error flag to non-zero, @extended flag may contain the NTSTATUS code. ; Author.........: trancexx ; Modified.......: Yashied, UEZ ; Remarks........: The input and output buffers must be different, otherwise, the function fails. ; Related........: ; Link...........: @@MsdnLink@@ RtlCompressBuffer ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_LZNTCompress(ByRef $tInput, ByRef $tOutput, $fMaximum = True) Local $tBuffer, $tWorkSpace, $Ret Local $COMPRESSION_FORMAT_LZNT1 = 0x0002, $COMPRESSION_ENGINE_MAXIMUM = 0x0100 If $fMaximum Then $COMPRESSION_FORMAT_LZNT1 = BitOR($COMPRESSION_FORMAT_LZNT1, $COMPRESSION_ENGINE_MAXIMUM) $tOutput = 0 $Ret = DllCall('ntdll.dll', 'uint', 'RtlGetCompressionWorkSpaceSize', 'ushort', $COMPRESSION_FORMAT_LZNT1, 'ulong*', 0, 'ulong*', 0) If @error Then Return SetError(1, 0, 0) If $Ret[0] Then Return SetError(2, $Ret[0], 0) $tWorkSpace = DllStructCreate('byte[' & $Ret[2] & ']') $tBuffer = DllStructCreate('byte[' & (2 * DllStructGetSize($tInput)) & ']') $Ret = DllCall('ntdll.dll', 'uint', 'RtlCompressBuffer', 'ushort', $COMPRESSION_FORMAT_LZNT1, 'ptr', DllStructGetPtr($tInput), 'ulong', DllStructGetSize($tInput), 'ptr', DllStructGetPtr($tBuffer), 'ulong', DllStructGetSize($tBuffer), 'ulong', 4096, 'ulong*', 0, 'ptr', DllStructGetPtr($tWorkSpace)) If @error Then Return SetError(3, 0, 0) If $Ret[0] Then Return SetError(4, $Ret[0], 0) $tOutput = DllStructCreate('byte[' & $Ret[7] & ']') If Not _WinAPI_MoveMemory(DllStructGetPtr($tOutput), DllStructGetPtr($tBuffer), $Ret[7]) Then $tOutput = 0 Return SetError(5, 0, 0) EndIf Return $Ret[7] EndFunc ;==>_WinAPI_LZNTCompress Func _WinAPI_MoveMemory($pDestination, $pSource, $iLenght) DllCall('ntdll.dll', 'none', 'RtlMoveMemory', 'ptr', $pDestination, 'ptr', $pSource, 'ulong_ptr', $iLenght) If @error Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinAPI_MoveMemory
-
Working with Powershell and Exchange
l4tran replied to kor's topic in AutoIt General Help and Support
I've just noticed you and kor have enable-mailbox -Identity in your powershell script. This by definition, creates a mailbox in Exchange for an existing user in Active Directory. If the user already existed, no password needs to be set. Your script doesn't create a user in AD, it creates a mailbox for the existing user in AD. -
Working with Powershell and Exchange
l4tran replied to kor's topic in AutoIt General Help and Support
It's prompting for a password. I'm not using RemoteExchange.ps1 since I don't have it in my system, so I the only thing that is close is Exchange.ps1. Could this be the problem? -
If I delete an item, how do I refresh the listview?
-
Working with Powershell and Exchange
l4tran replied to kor's topic in AutoIt General Help and Support
$user = StringLeft($accounts[2], StringInStr($accounts[2], '@') - 1) $sCreateMailbox = 'powershell.exe -PSConsoleFile "C:Program FilesMicrosoftExchange ServerBinExShell.Psc1" -command . ' & _ 'New-Mailbox -name "' & $user & _ '" -UserPrincipalName "' & $accounts[2] & _ '" -Database "' & $sEXDatabase[$index] & ' Storage Group' & '' & $sEXDatabase[$index] & ' Mailbox Database' & _ '" -OrganizationalUnit "' & $emailOU[$index] & ',dc=ABC,dc=COM' & _ '" -Alias "' & $user & _ '" -DisplayName "' & $displayname[$index] & ' ' & $user & _ '" -Firstname "' & $displayname[$index] & _ '" -Lastname "' & $user & '"' ;MsgBox(0,"",$sCreateMailbox) ClipPut($sCreateMailbox) RunWait($sCreateMailbox);,@SW_HIDE)