Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/02/2013 in all areas

  1. Jon

    AutoIt v3.3.9.14 Beta

    File Name: AutoIt v3.3.9.14 Beta File Submitter: Jon File Submitted: 02 Aug 2013 File Category: Beta 3.3.9.14 (2nd August, 2013) (Beta) AutoIt: - Changed: IsAdmin() function changed to be based on token membership. Maybe more acurate for Sandbox type environments. - Changed: ShellExecute() will return the process ID. UDFs: - Fixed: _GUICtrlListView_InsertItem() would fail to insert -1 if passed as the $sText parameter. - Fixed #2371: _PathSplit() incorrectly working with relative paths. Others: - Added: Notepad++ autoit.xml file to the editors folder. These contains a list of up to date functions. - Changed: Editor syntax files now include UDF functions. Click here to download this file
    6 points
  2. I have beat FireFox, is a good day I'm jocking, this is what MyEarth want: ; johnmcloud #include <GuiDateTimePicker.au3> #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 120, 50, -1, -1) $hDTP = _GUICtrlDTP_Create($hGUI, 20, 15, 80, 21, $DTS_UPDOWN) GUISetState() _GUICtrlDTP_SetFormat($hDTP, "HH.mm.ss") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE
    3 points
  3. Starg

    Simple 3D Graphics with GDI+

    Another example: #include <GUIConstantsEx.au3> #include <S3d.au3> Global Const $PI = 3.1416 Main() Func Main() ; Create a window and initialize GDI+ Local $hGUI = GUICreate("S3d Test", 650, 550) GUISetState() _GDIPlus_Startup() Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics(650, 550, $hGraphics) Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $hBrushB = _GDIPlus_BrushCreateSolid(0x996699FF) Local $hBrushG = _GDIPlus_BrushCreateSolid(0x9966FF33) Local $hPen = _GDIPlus_PenCreate(0xCCFF6633, 3) ; Select a Graphic object ; width = 650, height = 550 _S3d_SelectGraphic($hGraphic, 650, 550) _S3d_SelectPen($hPen) Local $i = 0 ; Loop until user exits Do ; Clear the Graphics object _S3d_Clear(0xFFCCCCCC) ; Set camera _S3d_SetCamera(500 * Cos($i), 500 * Sin($i), 1000, 0, 0, 600) ; Draw an arrow _S3d_Arrow(0, 0, -300, 0, 0, 900) _S3d_SelectBrush($hBrushG) _S3d_MoveTo2(100, 0, 0, 130, 0, 0) For $j = 0 To $PI * 2 * 3 Step ($PI * 2) / 20 _S3d_RibbonTo(100 * Cos($j), 100 * Sin($j), $j * 50, 130 * Cos($j), 130 * Sin($j), $j * 50) Next _S3d_SelectBrush($hBrushB) _S3d_MoveTo2(-100, 0, 0, -130, 0, 0) For $j = 0 To $PI * 2 * 3 Step ($PI * 2) / 20 _S3d_RibbonTo(-100 * Cos($j), -100 * Sin($j), $j * 50, -130 * Cos($j), -130 * Sin($j), $j * 50) Next ; Copy to the window _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0) $i += 0.3 Sleep(30) Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushB) _GDIPlus_BrushDispose($hBrushG) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) EndFunc ;==>Main
    2 points
  4. Hi! Today I want to show you my current AutoIt project: The ISN AutoIt Studio. The ISN AutoIt Studio is a complete IDE made with AutoIt, for AutoIt! It includes a GUI designer, a code editor (with syntax highlighting, auto complete & intelisense), a file viewer, a backup system, trophies and a lot more features!! Here are some screenshots: Here some higlights: -> easy to create/manage/public your AutoIt-projects! ->integrated GUI-Editor (ISN Form Studio 2) ->integrated - file & projectmanager ->auto backupfunction for your Projects ->extendable with plugins! ->available in several languages ->trophies ->Syntax highlighting /Autocomplete / Intelisense ->Dynamic Script ->detailed overview of the project (total working hours, total size...) And much more!!! -> -> Click here to download ISN AutoIt Studio <- <- Here is the link to the german autoit forum where I posted ISN AutoIt Studio the first time: http://autoit.de/index.php?page=Thread&threadID=29742&pageNo=1 For more information visit my Homepage: https://www.isnetwork.at So….have fun with ISN AutoIt Studio! PS: Sorry for my bad English! ^^
    1 point
  5. S3d.au3 This UDF enables you to draw simple 3D graphics. Features: Simple and easy to useDoesn't require external libraries. You don't need OpenGL or DirectX. Available Functions: _S3d_SelectGraphic($hGraphic, $iWidth, $iHeight, $iSmooth = 2) _S3d_SelectPen($hPen) _S3d_SelectBrush($hBrush) _S3d_SelectFont($hFont) _S3d_SelectFormat($hFormat) _S3d_SetClipCount($iCount) _S3d_Dist($nPos1X = 0, $nPos1Y = 0, $nPos1Z = 0, $nPos2X = 0, $nPos2Y = 0, $nPos2Z = 0) _S3d_DistFromCamera($nPosX = 0, $nPosY = 0, $nPosZ = 0) _S3d_SetCamera($nCameraX, $nCameraY, $nCameraZ, $nTargetX, $nTargetY, $nTargetZ, $nVAngle = 0, $nFAngle = 0.8, $nFScale = 1000) _S3d_SetCameraEx($nCameraX, $nCameraY, $nCameraZ, $nXYAngle = 0, $nXZAngle = 0, $nVAngle = 0, $nFAngle = 0.8, $nFScale = 1000) _S3d_SetLocalMatrix($n00 = 1, $n01 = 0, $n02 = 0, $n03 = 0, $n10 = 0, $n11 = 1, $n12 = 0, $n13 = 0, $n20 = 0, $n21 = 0, $n22 = 1, $n23 = 0, $n30 = 0, $n31 = 0, $n32 = 0, $n33 = 1) _S3d_MultiplyLocalMatrix($n00 = 1, $n01 = 0, $n02 = 0, $n03 = 0, $n10 = 0, $n11 = 1, $n12 = 0, $n13 = 0, $n20 = 0, $n21 = 0, $n22 = 1, $n23 = 0, $n30 = 0, $n31 = 0, $n32 = 0, $n33 = 1, $fRefresh = True) _S3d_LocalTranslate($nX, $nY, $nZ, $fRefresh = True) _S3d_LocalScale($nX, $nY, $nZ, $fRefresh = True) _S3d_LocalRotateX($nAngle, $fDeg = False, $fRefresh = True) _S3d_LocalRotateY($nAngle, $fDeg = False, $fRefresh = True) _S3d_LocalRotateZ($nAngle, $fDeg = False, $fRefresh = True) _S3d_GetLocalMatrix() _S3d_SetLocalMatrixEx(ByRef $aMatrix) _S3d_GetPos($nX, $nY, $nZ) _S3d_InitCurrentPos() _S3d_MoveTo($nX, $nY, $nZ = Default) _S3d_Clear($nColor = 0xFF000000) _S3d_Line($nX1, $nY1, $nZ1, $nX2, $nY2, $nZ2) _S3d_LineTo($nX, $nY, $nZ) _S3d_Box($nX1, $nY1, $nZ1, $nX2, $nY2, $nZ2) _S3d_Arrow($nX1, $nY1, $nZ1, $nX2, $nY2, $nZ2, $nLen = 30, $nAngle = 0.6) _S3d_Circle($nX, $nY, $nZ, $nRad, $fFill = False) _S3d_Polygon($aPoints, $fFill = False) _S3d_RegPolygon($nX, $nY, $nZ, $nRad, $iNum, $fFill = True) _S3d_Star($nX, $nY, $nZ, $nRad1, $nRad2, $iNum, $fFill = True) _S3d_Square($nX1, $nY1, $nZ1, $nX2, $nY2, $nZ2, $nX3, $nY3, $nZ3, $nX4, $nY4, $nZ4, $fFill = True) _S3d_MoveTo2($nXL, $nYL, $nZL, $nXR, $nYR, $nZR) _S3d_RibbonTo($nXL, $nYL, $nZL, $nXR, $nYR, $nZR) _S3d_String($sString, $nX, $nY, $nZ) New version!S3d.zip v1.3.1 (09/JUN/2014) * Archives S3d.zip v1.3.0 (05/SEP/2013) S3d.zip v1.2.3 (16/AUG/2013) Enjoy!
    1 point
  6. For now the algorithm is not being replaced, but added as an alternative. This is because I doesn't bring performance improvements in all cases. Spiff, what is your specific issue with the inclusion of Melba23s function?
    1 point
  7. boththose, Have you even looked at the _FielListToArrayRec UDF as it currently exists in the Beta? Like the OP, probably not, as it uses a dual pivot sort algorithm which is not (yet) in the main Array.au3 UDF and the only modified existing function it uses is to concatenate various arrays - all 5 lines of it. The additional 7 lines in the existing function are pure error-checking. So chase this red herring as far as you all want. As to having "faster" versions of the various UDFs by removing errorchecking - not a hope. It would essentially double the size of the #include files. Besides it would only be in special cases where they are called as intensively as in this UDF and the gains in normal use would be relatively minor. And that is all I am going to say on the subject. As explained earlier, I was not the instigator of adding the UDF to the standard install - if enough people decide that it is not worthy, then appeal to the Devs to remove it. I will be perfectly happy to continue it as one of my personal UDFs in the Examples thread. But I reiterate my warning that I will not stand for any more pure flaming of the type that began this thread - just as I would not accept it in a case where I was not personally involved. M23
    1 point
  8. I doubt it, destluck has already been Moderated for game related posts, and told not to start another. I'm sure he's not that stupid So as soon as he tells us what application he's trying to manipulate, we can help
    1 point
  9. guinness

    Aero Flip 3D

    What does 105 mean?
    1 point
  10. Melba23

    _IsPressed problems

    Sparky90ful, Because of the long Sleep times when your script is unresponsive you have to keep the keys pressed untitl they are checked - this makes it look as if you are stuck in the loop. Better to check as the script waits like this: #include <Misc.au3> HotKeySet("{ESC}", "On_Exit") $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("64", $hDLL) Then ConsoleWrite("Starting loop" & @CRLF) Sleep(100) While 1 $nBegin = TimerInit() ; get a timestamp While TimerDiff($nBegin) < 3050 ; Until the delay expires If _IsPressed("65", $hDLL) = 1 Then ; Check for the key ExitLoop 2 ; Exit both loops EndIf WEnd ConsoleWrite("NP6" & @CRLF) ;Send ("{NUMPAD6}") $nBegin = TimerInit() While TimerDiff($nBegin) < 100 If _IsPressed("65", $hDLL) = 1 Then ExitLoop 2 EndIf WEnd ConsoleWrite("NP4" & @CRLF) WEnd ConsoleWrite("Ending Loop" & @CRLF) EndIf Sleep(100) WEnd Func On_Exit() DllClose($hDLL) Exit EndFunc ;==>On_Exit That works fine for me. How about you? M23
    1 point
  11. '?do=embed' frameborder='0' data-embedContent>>
    1 point
  12. Does the removeM47 code (above) work?
    1 point
  13. I was about to post that part before going to sleep a bit (it's 4:51 here!) Func Remove_M47(); This function removes the M47 code from the program Local $ReadInput1 = GUICtrlRead($Input1) Local $sText = FileRead($ReadInput1) Local $sTextDelM47 = StringRegExpReplace($sText, "(?m)(N\d+\.\dM47\R)(?=N\d+M0\R)", "", 1) MsgBox(0, "First added M47 now removed", $sTextM47) FileWrite($ReadInput1, $sTextDelM47) EndFunc Should work if you pray hard enough!
    1 point
  14. aha, yes sir i begged for it
    1 point
  15. I gave you the second part so here is the first one: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Memory.au3> GUIBlitExample() Func GUIBlitExample() #region GUI Local $hGUISrc = 0, $nSrcControl = 0 $hGUISrc = GUICreate("Source", 200, 200, 50, 50) $nSrcControl = GUICtrlCreateGraphic(50, 50, 100, 100) GUICtrlSetStyle(-1, $SS_NOTIFY) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff) GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff) GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90) GUISetState(@SW_SHOW, $hGUISrc) #endregion Local $hHBMP = 0 GraphicsBlit(GUICtrlGetHandle($nSrcControl), $hHBMP) _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBMP) _WinAPI_DeleteObject($hHBMP) ; This is the binary data of your image. ConsoleWrite(BinaryLen(_GDIPlus_SaveImage2Binary($hBitmap, 100)) & @CrLf) ;~ _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\test.png") _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd EndFunc Func GraphicsBlit($hWnd, ByRef $hHBMP) Local $hDC = 0, $tRect = 0 $hDC = _WinAPI_GetDC($hWnd) $tRect = _WinAPI_GetClientRect($hWnd) Local $iLeft = DllStructGetData($tRect, "Left"), $iTop = DllStructGetData($tRect, "Top") Local $iRight = DllStructGetData($tRect, "Right"), $iBottom = DllStructGetData($tRect, "Bottom") Local $hDDC = _WinAPI_GetDC($hWnd) Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC) $hHBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iRight - $iLeft, $iBottom - $iTop) _WinAPI_SelectObject($hCDC, $hHBMP) _WinAPI_BitBlt($hCDC, 0, 0, $iRight - $iLeft, $iBottom - $iTop, $hDDC, $iLeft, $iTop, $SRCCOPY) _WinAPI_ReleaseDC($hWnd, $hDDC) _WinAPI_DeleteDC($hCDC) EndFunc ;==>GraphicsBlitBetweenWindows Func _GDIPlus_SaveImage2Binary($hBitmap, $iQuality = 50) ;Coded by Andreik, modified by UEZ Local $sImgCLSID = _GDIPlus_EncodersGetCLSID("jpg") Local $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Local $pEncoder = DllStructGetPtr($tGUID) Local $tParams = _GDIPlus_ParamInit(1) Local $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100 Local $pData = DllStructGetPtr($tData) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Local $pParams = DllStructGetPtr($tParams) Local $hStream = DllCall("ole32.dll", "uint", "CreateStreamOnHGlobal", "ptr", 0, "bool", True, "ptr*", 0) $hStream = $hStream[3] DllCall($ghGDIPDll, "uint", "GdipSaveImageToStream", "ptr", $hBitmap, "ptr", $hStream, "ptr", $pEncoder, "ptr", $pParams) ;~ _GDIPlus_BitmapDispose($hBitmap) Local $hMemory = DllCall("ole32.dll", "uint", "GetHGlobalFromStream", "ptr", $hStream, "ptr*", 0) $hMemory = $hMemory[2] Local $iMemSize = _MemGlobalSize($hMemory) Local $pMem = _MemGlobalLock($hMemory) $tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem) Local $bData = DllStructGetData($tData, 1) Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data;ptr") DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) _MemGlobalFree($hMemory) Return $bData EndFunc ;==>__GDIPlus_SaveImage2BinaryEdit: Added indents. Br, FireFox.
    1 point
  16. JohnOne

    Autorun an autoit program

    $iDuration = 20 ; minutes $iTimer = TimerInit() While 50025 Sleep(1000) If TimerDiff($iTimer) >= (1000 * 60) * $iDuration Then ; every $iDuration minutes run your script ShellExecute('D:\folder\script.exe') SoundPlay(@WindowsDir & "\media\tada.wav", 2) $iTimer = TimerInit(); reset timer EndIf WEnd
    1 point
  17. Sea

    [UDF] Structure Parser 1.2

    Hello everybody, I'm currently working on structure for make it like in C. For the moment the UDF is able to Read some structure from a file Read with a given structure Get structure by the name or by GUID,it's automaticly detect if it's a GUID or name Create our datatype What will be coming? Write a file with a given structure UDF #include <WinAPI.au3> #include <Array.au3> #include <String.au3> Global $nBytes ; #FUNCTION# ============================================================================= ; Name...........: getStruct ; Description ...: Get Autoit structure and the size of it ; Syntax.........: getStruct($sPath,$sStructName,$iType) ; Parameters ....: $sPath - Path of the file who contening the structure. ; $sStructName - String contening the name of the structure of his GUID (8bit-4bit-4bit-4bit-12bit) ; $iRecursivelvl - Int egual to the level of the recusivity of the script. ; Optional.......: ; Return values .: Success - Returns an array [0] = Structure ; [1] = Size of structure ; [2] = Number of Data ; Failure - Returns a 0 ; @Error - 0 = No error. ; 1 = Path is not a string ; 2 = Can't open file ; 3 = Can't find the structure name ; Author ........: sea78 ; ======================================================================================== Func getStruct($sPath,$sStructName,$iRecursivelvl = 1) If Not IsString($sPath) Then SetError(1) Return 0 EndIf if ($iRecursivelvl = 1) Then Global $text[1] Global $data[3] $data[2] = 0 Else ReDim $text[$iRecursivelvl] EndIf $file = FileOpen($sPath) If $file = -1 Then SetError(2) Return 0 EndIf $text[$iRecursivelvl-1] = FileRead($file) FileClose($file) $text[$iRecursivelvl-1] = StringReplace($text[$iRecursivelvl-1],@CR,"") $text[$iRecursivelvl-1] = StringReplace($text[$iRecursivelvl-1],@LF,"") If (StringRegExp($sStructName, '^(\{){0,1}[[:xdigit:]]{8}\-[[:xdigit:]]{4}\-[[:xdigit:]]{4}\-[[:xdigit:]]{4}\-[[:xdigit:]]{12}(\}){0,1}$')) Then $text[$iRecursivelvl-1] = StringRegExpReplace($text[$iRecursivelvl-1], "(.*)"&$sStructName&"}{", "", 0) $text[$iRecursivelvl-1] = StringRegExpReplace($text[$iRecursivelvl-1], "}(.*)", "", 0) Else $text[$iRecursivelvl-1] = StringRegExpReplace($text[$iRecursivelvl-1], "(.*)struct "&$sStructName&"({)(.{8})-(.{4})-(.{4})-(.{4})-(.{12})}{", "", 0) $text[$iRecursivelvl-1] = StringRegExpReplace($text[$iRecursivelvl-1], "}(.*)", "", 0) EndIf $textExplosed = _StringExplode($text[$iRecursivelvl-1],';') If (StringRegExp($text[0], "struct", 0)) Then SetError(3) Return 0 EndIf Redim $textExplosed[UBound($textExplosed)-1] for $i = 0 to UBound($textExplosed)-1 If CheckType($textExplosed[$i]) = 1 Then $data[0] = $data[0]&$textExplosed[$i]&';' $data[1] = $data[1]+getSize($textExplosed[$i]) $data[2] = $data[2]+1 ElseIf CheckType($textExplosed[$i]) = 2 Then $nb = StringRegExpReplace($textExplosed[$i], "(\D)", "", 0) if $nb <> "" Then for $y = 0 to $nb getStruct($sPath,StringRegExpReplace($textExplosed[$i], "\[(.*)\]", "", 0),$iRecursivelvl+1) Next Else getStruct($sPath,StringRegExpReplace($textExplosed[$i], "\[(.*)\]", "", 0),$iRecursivelvl+1) EndIf EndIf Next Return $data EndFunc ; #FUNCTION# ============================================================================= ; Name...........: CheckType ; Description ...: Check if the data is knowed datatype ; Syntax.........: CheckType($sData) ; Parameters ....: $sData - String contening the DataType ; Optional.......: ; Return values .: Success - Returns an int ; 1 => DataType is Know ; 2 => DataType is Home Maid ; Failure - Returns a 0 ; @Error - 1 = Data is not a string. ; Author ........: sea78 ; ======================================================================================== Func CheckType($sData) If Not IsString($sData) Then SetError(1) Return 0 EndIf If StringRegExp($sData,"char") Then Return 1 ElseIf StringRegExp($sData,"byte") Then $sData = StringRegExpReplace($sData, "\D", "", 0) Return 1 ElseIf StringRegExp($sData,"boolean") Then return 1 ElseIf StringRegExp($sData,"wchar") Then $sData = StringRegExpReplace($sData, "\D", "", 0) Return 1 ElseIf StringRegExp($sData,"short") Then Return 1 ElseIf StringRegExp($sData,"ushort") Then Return 1 ElseIf StringRegExp($sData,"word") Then Return 1 ElseIf StringRegExp($sData,"int") Then Return 1 ElseIf StringRegExp($sData,"long") Then Return 1 ElseIf StringRegExp($sData,"bool") Then Return 1 ElseIf StringRegExp($sData,"uint") Then Return 1 ElseIf StringRegExp($sData,"ulong") Then Return 1 ElseIf StringRegExp($sData,"dword") Then Return 1 ElseIf StringRegExp($sData,"float") Then Return 1 ElseIf StringRegExp($sData,"double") Then Return 1 ElseIf StringRegExp($sData,"double") Then Return 1 Else Return 2 EndIf EndFunc ; #FUNCTION# ============================================================================= ; Name...........: getSize ; Description ...: Get size of type. ; Syntax.........: getSize($sData) ; Parameters ....: $sData - String contening the DataType ; Optional.......: ; Return values .: Success - Returns an int egal to the size of the DataType ; Failure - Returns a 0 ; @Error - 0 = No error. ; 1 = Data is not a string ; 2 = Undefine DataType ; Author ........: sea78 ; ======================================================================================== Func getSize($sData) If Not IsString($sData) Then SetError(1) Return 0 EndIf If StringRegExp($sData,"char") Then $sData = StringRegExpReplace($sData, "\D", "", 0) Return $sData ElseIf StringRegExp($sData,"byte") Then $sData = StringRegExpReplace($sData, "\D", "", 0) Return $sData*2 ElseIf StringRegExp($sData,"boolean") Then return 1 ElseIf StringRegExp($sData,"wchar") Then $sData = StringRegExpReplace($sData, "\D", "", 0) Return $sData*2 ElseIf StringRegExp($sData,"short") Then return 2 ElseIf StringRegExp($sData,"ushort") Then return 2 ElseIf StringRegExp($sData,"word") Then return 2 ElseIf StringRegExp($sData,"int") Then return 4 ElseIf StringRegExp($sData,"long") Then Return 4 ElseIf StringRegExp($sData,"bool") Then Return 4 ElseIf StringRegExp($sData,"uint") Then Return 4 ElseIf StringRegExp($sData,"ulong") Then Return 4 ElseIf StringRegExp($sData,"dword") Then Return 4 ElseIf StringRegExp($sData,"float") Then Return 4 ElseIf StringRegExp($sData,"double") Then Return 8 ElseIf StringRegExp($sData,"double") Then Return 8 Else SetError(2) Return 0 EndIf EndFunc ; #FUNCTION# ============================================================================= ; Name...........: readStruct ; Description ...: Read data with structure. ; Syntax.........: readStruct($sFile,$aData) ; Parameters ....: $sFile - path of the file to read ; $aData - Array with structure & Size [0] = Autoit string struct ; [1] = Size of the structure ; [2] = Number of data ; Optional.......: ; Return values .: Success - Returns an array who contening the data read ; Failure - Returns a 0 ; @Error - 0 = No error. ; 1 = sFile is not a string ; 2 = aData is not an array ; 3 = aData[0] is not a string ; 4 = aData[1] is not an int ; 5 = aData[2] is not an int ; 6 = Can't open file ; Failure - Returns a 1 ; @Error - Look the error code for DllStructCreate ; Author ........: sea78 ; ======================================================================================== Func readStruct($sFile,$aData) If Not IsString($sFile) Then SetError(1) Return 0 EndIf If Not IsArray($aData) Then SetError(2) Return 0 EndIf If Not IsString($aData[0]) Then SetError(3) Return 0 EndIf If Not IsInt($aData[1]) Then SetError(4) Return 0 EndIf If Not IsInt($aData[2]) Then SetError(5) Return 0 EndIf Dim $aBuffer[$aData[2]+1] $hFile = _WinAPI_CreateFile($sFile, 2, 2) If $hFile = 0 Then SetError(6) Return 0 EndIf $tBuffer = DllStructCreate($aData[0]) If $tBuffer = 0 Then Return 1 EndIf _WinAPI_ReadFile($hFile, DllStructGetPtr($tBuffer), $aData[1], $nBytes) For $i = 0 to $aData[2] $aBuffer[$i] = DllStructGetData($tBuffer, $i+1) Next _WinAPI_CloseHandle($hFile) Return $aBuffer EndFunc An exemple of use. #include <Structure.au3> ;See the UDF ^^ $sFile = 'C:\DataFileToBeRead.data' $test = readStruct($sFile,getStruct('Structure.txt',"MyName")) _ArrayDisplay($test) $test = readStruct($sFile,getStruct('Structure.txt',"C817F7B0-E4C7-40FB-97B3-2B97CC000521")) _ArrayDisplay($test) $test = readStruct($sFile,getStruct('Structure.txt',"test")) _ArrayDisplay($test) Exemple of structure Be carefull the syntaxe of the structure must be like that struct Name {GUID} { DataType1; DataType2; } The space between struc and the name of it are obligatory.The newline too. Each data must be separate by a semicolon.. struct MyName {C817F7B0-E4E7-40FB-97B3-2B97CC000521} { char[4]; char[4]; int; int; int; char[108]; } struct hey {C817F7B0-E4C7-40FB-97B3-2B97CC000521} { char[10]; char[4]; int; int; int; char[108]; } struct test {C817FAD0-E4E7-40FB-97B3-2B97CC000521} { MyName; MyName[10]; } Version Note Legend: +: Addition, -: Remouved/Deprecated, *: Modified, !: Bug correction V1.1 +Read some structure from a file +Get structure by her name V1.2 +Get structure by the name or by GUID,it's automaticly detect if it's a GUID or name V1.3 +Create our datatype
    1 point
  18. This is how I get the IE object for the currently active tab: ;=============================================================================== ; ; Function Name: _IEGetActiveTab() ; Description: Retrieve the IE Window Object of the currently active tab ; Parameter(s): None ; Requirement(s): AutoIt3 V3.2 or higher ; On Success - Returns an object variable pointing to the IE Window Object ; On Failure - Returns 0 and sets @ERROR ; @ERROR - 0 ($_IEStatus_Success) = No Error ; - 7 ($_IEStatus_NoMatch) = No Match ; Author(s): Dan Pollak ;=============================================================================== ; Func _IEGetActiveTab() Local $hwnd, $i, $title, $oIE ; get first IE instance $oIE = _IEAttach ("", "instance", 1) If @error = $_IEStatus_Success Then ; get window title $hwnd = _IEPropertyGet($oIE, "hwnd") $title = WinGetTitle($hwnd) $oIE = _IEAttach($title, "windowtitle") EndIf Return $oIE EndFunc
    1 point
  19. Return values of SetError() and SetExtended() should be docummented as undefined for cases when return value parameter is omitted. That's the whole thing and probably it's the most correct. Documenting this type of information regarding these functions or other built-ins should be left to developers.
    1 point
×
×
  • Create New...