Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/14/2015 in all areas

  1. Yashied

    WinAPIEx UDF

    LAST VERSION - 3.8 03-Jul-12 This library contains the WinAPI functions are not included for unknown reasons to the native AutoIt WinAPI library. I use this UDF in nearly all of my programs, and decided to share it with the AutoIt community. I agree that over time some of these functions will be part of the native AutoIt library, but still... The library includes some undocumented, but useful functions (eg _WinAPI_GetFontResourceInfo()). The library also contains all the necessary constants to work with the appropriate functions. Most functions from this UDF intended for experienced users, but beginners will find the same lot of useful information for yourself. I will be to periodically add new functions to the library. The archive contains WinAPIEx library, and as usual an excellent examples from me. Some examples I took from this forum and to simplify them for better understanding. For those who use SciTE (full version) I have prepared the au3.userudfs.properties and au3.user.calltips.api files to highlight functions from this UDF in your scripts. Just copy this files to ...SciTEProperties and ...SciTEAPI, respectively. I hope this UDF will be useful for many as for me. I look forward to any feedback and suggestions. Maybe somebody wants to add new WinAPI functions? Credits Available functions Files to download WinAPIEx UDF v3.8 for AutoIt 3.3.6.1 Previous downloads: 27953 WinAPIEx UDF v3.8 for AutoIt 3.3.8.x Previous downloads: 14850
    1 point
  2. If it is your inputbox then try guictrlread ...
    1 point
  3. The context was provided by you. You asked: ...And I answered: "No, nor it should be." What are you afraid of? If you have an idea or question then ask and explain your ideas. So what if some uber-developer thinks your ideas are stupid. You will never learn if you'd be afraid to ask the real questions. If I were you I would say "Hey guys, I have an idea! What if we would be able to reference the object that a COM error was generated on inside the event handler function and then use that object to do... this and that. You think that'd be good idea?" Geeze mLipok.
    1 point
  4. NoizeBit, Glad I could help. M23
    1 point
  5. NoizeBit, You could use my ArrayMultiColSort UDF to do this easily - but you will need to swap the column order as the UDF only sorts them in left-to-right order: #include <Array.au3> #include <File.au3> #include "ArrayMultiColSort.au3" $sFile = "test.csv" ; Read file into a 2D array Global $aArray _FileReadToArray($sFile, $aArray, $FRTA_NOCOUNT, ",") ; And here it is _ArrayDisplay($aArray, "Original", Default, 8) ; Swapt the columns to get them in the right order _ArraySwap($aArray, 4, 8, True) _ArrayDisplay($aArray, "Swapped", Default, 8) ; Sort in the required order Local $aSortData[2][2] = [[4, 0], [8, 0]] _ArrayMultiColSort($aArray, $aSortData, 1) ; And her is the result _ArrayDisplay($aArray, "Sorted", Default, 8) ; Finally swap the columns back _ArraySwap($aArray, 4, 8, True) _ArrayDisplay($aArray, "Swapped back", Default, 8)Please ask if you have any questions. M23
    1 point
  6. You could do something like this. Make sure you check out all the functions in this script using the help file. #include <Array.au3> #include <File.au3> Local $aRetArray ; read csv to an array _FileReadToArray('my.csv', $aRetArray, $FRTA_NOCOUNT, ',') ;_ArrayDisplay($aRetArray) ; get rid of the extra column ReDim $aRetArray [UBound($aRetArray)][UBound($aRetArray, 2) -1] _ArrayDisplay($aRetArray) ; sort by order time _ArraySort ($aRetArray , 0, 1, 0 ,4) _ArrayDisplay($aRetArray)
    1 point
  7. jchd

    compare variables

    You can also make your life simpler by using _Min() function (see help). _Min(_Min($a, $b), _Min($c, $d))
    1 point
  8. jchd

    Reading a file .db

    I found it interesting to see how deep wrong ideas can grow their roots. As you say you and me don't care since we're not the ones who shall hit bricks at full speed.
    1 point
  9. Jos

    Reading a file .db

    @jchd, Not sure I've seen you this persistent before. Please watch your blood pressure and when he doesn't get it by now it surely is a lost case... But it is his case. ;-) Jos
    1 point
  10. For those that have an understanding of 1D/2D Arrays or wish to learn, then this post is a good way to start. This isn't a UDF, more of 'what I've discovered' from reading many Forum posts (especially from Melba23, KaFu) about how ReDim should only be used when required and in an efficient way. For those who tend to create their own Arrays it's inevitable that sometimes ReDim will have to be used. Sometimes knowing the final size of the Array isn't known, especially if using FileFindFirstFile/FileFindNextFile to record the file name(s). For most we use ReDim $aArray[$iTotal_Rows + 1] to increase the size of the Array (by 1 Row) but when it comes to Arrays that might have 1000+ items this starts to slow the Script down. So a little trick Melba23/KaFu pointed out, is to only ReDim when really necessary & then if so multiply the size by 1.5 and round to the next integer. Thus reducing the need for 'ReDimming' every time. 17 * 1.5 = 25.5 Ceiling(17 * 1.5) = 26For Example if we were to create an Array with 1000 items using the traditional way, it would require the Array to be ReDimmed (you guessed it) 1000 times, but using the trick (when required and multiply by 1.5) this is reduced to only 16 times! In the tests I conducted this was the difference of 388ms VS 20ms, what a huge speed increase and only on 1000 items. The reason why I haven't made this a UDF is because users declare variables differently. How I do it is I store the row size in index 0 and if using columns I store the size in index 0 & column 1. Others will use Ubound to find the size as they don't store the Array size in the Array or in a variable e.g. For $i = 0 To Ubound($aArray, 1) - 1. Others will store the row size in index 0, but won't keep a reference of how many columns the Array has, especially when they just 'hard code' it in Functions e.g. $aArray[$i][5] += 1. How I declare Arrays: #include <Array.au3> Local $a1D[6] = [5, 1, 2, 3, 4, 5] ; Array count in the 0th element e.g. 5. Local $a2D[6][3] = [[5, 3], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]] ; Array count in the 0th element, 0th column e.g. 5 and the column count in the 0th element, 1st column e.g. 3. _ArrayDisplay($a1D, '1D Array') _ArrayDisplay($a2D, '2D Array')Therefore have a look at the Examples that are below and read the comments to understand a little further. Comments, suggestions, then please post below. Thanks. Functions. Func _ReDim1D(ByRef $aArray, ByRef $iDimension) ; Where Index [0] is the Row count. If ($aArray[0] + 1) >= $iDimension Then $iDimension = Ceiling(($aArray[0] + 1) * 1.5) ReDim $aArray[$iDimension] Return 1 EndIf EndFunc ;==>_ReDim1D Func _ReDim2D(ByRef $aArray, ByRef $iDimension) ; Where Index [0, 0] is the Row count and Row [0, 1] is the Column count. If ($aArray[0][0] + 1) >= $iDimension Then $iDimension = Ceiling(($aArray[0][0] + 1) * 1.5) ReDim $aArray[$iDimension][$aArray[0][1]] Return 1 EndIf EndFunc ;==>_ReDim2D Func _ReDim1D_Ubound(ByRef $aArray, ByRef $iDimension, ByRef $iCount) ; Using Ubound($aArray, 1) to find the Row size. $iCount += 1 If ($iCount + 1) >= $iDimension Then $iDimension = Ceiling((UBound($aArray, 1) + 1) * 1.5) ReDim $aArray[$iDimension] Return 1 EndIf EndFunc ;==>_ReDim1D_Ubound Func _ReDim2D_Ubound(ByRef $aArray, ByRef $iDimension, ByRef $iCount) ; Using Ubound($aArray, 1) to find the Row size and Ubound($aArray, 2) for the Column size. $iCount += 1 If ($iCount + 1) >= $iDimension Then $iDimension = Ceiling((UBound($aArray, 1) + 1) * 1.5) ReDim $aArray[$iDimension][UBound($aArray, 2)] Return 1 EndIf EndFunc ;==>_ReDim2D_UboundExample use of Functions: #include <Array.au3> #include <Constants.au3> ; Change the value of the $ARRAY_SIZE constant to determine the array size. Global Const $ARRAY_SIZE = 5000 _1D_Slow() ; See how Slow this is by doing it the traditional way of increasing by 1. _1D_1() ; Only ReDim when required and if so mutliply the count by 1.5 and round to the next integer. _1D_2() ; Only ReDim when required and if so mutliply the count by 1.5 and round to the next integer. _2D_1() ; Only ReDim when required and if so mutliply the count by 1.5 and round to the next integer, this also uses Ubound() to find the size of the Array. _2D_2() ; Only ReDim when required and if so mutliply the count by 1.5 and round to the next integer, this also uses Ubound() to find the size of the Array. Func _1D_Slow() Local $aArray[1] = [0], $hTimer = 0, $iCount = 0, $iDimension = 0 $hTimer = TimerInit() ; Start the timer. For $i = 1 To $ARRAY_SIZE ReDim $aArray[($aArray[0] + 1) + 1] ; ReDim the array by adding 1 to the total count and then increasing by 1 for a new row. $iCount += 1 ; If array was ReDimmed then add to the ReDim count for output at the end. $aArray[0] += 1 ; Increase Index [0] by 1. $aArray[$i] = 'Row ' & $i & ': Col 0' ; Add random data. If Mod($i, 1000) = 0 Then ConsoleWrite('It''s still working! Now we''re at about ' & $i & ' elements in the array.' & @CRLF) EndIf Next $hTimer = Round(TimerDiff($hTimer)) ; End the timer and find the difference from start to finish. ReDim $aArray[$aArray[0] + 1] ; Remove the empty Rows, by ReDimming the total count plus the row for holding the count. ; _ArrayDisplay($aArray) MsgBox($MB_SYSTEMMODAL, 'How many times? - _1D_Slow()', 'The amount of times a ' & $ARRAY_SIZE & ' element array was ''ReDimmed'' was ' & $iCount & ' times.' & @CRLF & _ 'It only took ' & $hTimer & ' milliseconds to complete.') EndFunc ;==>_1D_Slow Func _1D_1() Local $aArray[1] = [0], $hTimer = 0, $iCount = 0, $iDimension = 0 $hTimer = TimerInit() ; Start the timer. For $i = 1 To $ARRAY_SIZE If _ReDim1D($aArray, $iDimension) Then ; Returns 1 if ReDimmed OR 0 if it wasn't. This uses ByRef, so just pass the array and a previously delcared variable for monbitoring the dimension. $iCount += 1 ; If array was ReDimmed then add to the ReDim count for output at the end. EndIf $aArray[0] += 1 ; Increase Index [0] by 1. $aArray[$i] = 'Row ' & $i & ': Col 0' ; Add random data. Next $hTimer = Round(TimerDiff($hTimer)) ; End the timer and find the difference from start to finish. ReDim $aArray[$aArray[0] + 1] ; Remove the empty Rows, by ReDimming the total count plus the row for holding the count. ; _ArrayDisplay($aArray) MsgBox($MB_SYSTEMMODAL, 'How many times? - _1D_1()', 'The amount of times a ' & $ARRAY_SIZE & ' element array was ''ReDimmed'' was ' & $iCount & ' times.' & @CRLF & _ 'It only took ' & $hTimer & ' milliseconds to complete.') EndFunc ;==>_1D_1 Func _1D_2() Local $aArray[1] = [0], $hTimer = 0, $iCount = 0, $iDimension, $iIndexTotal = 0 $hTimer = TimerInit() ; Start the timer. For $i = 1 To $ARRAY_SIZE If _ReDim1D_Ubound($aArray, $iDimension, $iIndexTotal) Then ; Returns 1 if ReDimmed OR 0 if it wasn't. This uses ByRef, so just pass the array and a previously delcared variable for monbitoring the dimension and a second variable for monitoring the total count. $iCount += 1 ; If array was ReDimmed then add to the ReDim count for output at the end. EndIf $aArray[0] += 1 ; Increase Index [0] by 1. $aArray[$i] = 'Row ' & $i & ': Col 0' ; Add random data. Next $hTimer = Round(TimerDiff($hTimer)) ; End the timer and find the difference from start to finish. ReDim $aArray[$aArray[0] + 1] ; Remove the empty Rows, by ReDimming the total count plus the row for holding the count. ; _ArrayDisplay($aArray) MsgBox($MB_SYSTEMMODAL, 'How many times? - _1D_2()', 'The amount of times a ' & $ARRAY_SIZE & ' element array was ''ReDimmed'' was ' & $iCount & ' times.' & @CRLF & _ 'It only took ' & $hTimer & ' milliseconds to complete.') EndFunc ;==>_1D_2 Func _2D_1() Local $aArray[1][2] = [[0, 2]], $hTimer = 0, $iCount = 0, $iDimension = 0 $hTimer = TimerInit() ; Start the timer. For $i = 1 To $ARRAY_SIZE If _ReDim2D($aArray, $iDimension) Then ; Returns 1 if ReDimmed OR 0 if it wasn't. This uses ByRef, so just pass the array and a previously delcared variable for monbitoring the dimension. $iCount += 1 ; If array was ReDimmed then add to the ReDim count for output at the end. EndIf $aArray[0][0] += 1 ; Increase Index [0, 0] by 1. $aArray[$i][0] = 'Row ' & $i & ': Col 0' ; Add random data. $aArray[$i][1] = 'Row ' & $i & ': Col 1' ; Add random data. Next $hTimer = Round(TimerDiff($hTimer)) ; End the timer and find the difference from start to finish. ReDim $aArray[$aArray[0][0] + 1][$aArray[0][1]] ; Remove the empty Rows, by ReDimming the total count plus the row for holding the count and include the number of colums too. ; _ArrayDisplay($aArray) MsgBox($MB_SYSTEMMODAL, 'How many times? - _2D_1()', 'The amount of times a ' & $ARRAY_SIZE & ' element array was ''ReDimmed'' was ' & $iCount & ' times.' & @CRLF & _ 'It only took ' & $hTimer & ' milliseconds to complete.') EndFunc ;==>_2D_1 Func _2D_2() Local $aArray[1][2] = [[0, 2]], $hTimer = 0, $iCount = 0, $iDimension = 0, $iIndexTotal = 0 $hTimer = TimerInit() ; Start the timer. For $i = 1 To $ARRAY_SIZE If _ReDim2D_Ubound($aArray, $iDimension, $iIndexTotal) Then ; Returns 1 if ReDimmed OR 0 if it wasn't. This uses ByRef, so just pass the array and a previously delcared variable for monbitoring the dimension and a second variable for monitoring the total count. $iCount += 1 ; If array was ReDimmed then add to the ReDim count for output at the end. EndIf $aArray[0][0] += 1 ; Increase Index [0, 0] by 1. $aArray[$i][0] = 'Row ' & $i & ': Col 0' ; Add random data. $aArray[$i][1] = 'Row ' & $i & ': Col 1' ; Add random data. Next $hTimer = Round(TimerDiff($hTimer)) ; End the timer and find the difference from start to finish. ReDim $aArray[$aArray[0][0] + 1][$aArray[0][1]] ; Remove the empty Rows, by ReDimming the total count plus the row for holding the count and include the number of colums too. ; _ArrayDisplay($aArray) MsgBox($MB_SYSTEMMODAL, 'How many times? - _2D_2()', 'The amount of times a ' & $ARRAY_SIZE & ' element array was ''ReDimmed'' was ' & $iCount & ' times.' & @CRLF & _ 'It only took ' & $hTimer & ' milliseconds to complete.') EndFunc ;==>_2D_2 Func _ReDim1D(ByRef $aArray, ByRef $iDimension) ; Where Index [0] is the Row count. If ($aArray[0] + 1) >= $iDimension Then $iDimension = Ceiling(($aArray[0] + 1) * 1.5) ReDim $aArray[$iDimension] Return 1 EndIf EndFunc ;==>_ReDim1D Func _ReDim2D(ByRef $aArray, ByRef $iDimension) ; Where Index [0, 0] is the Row count and Row [0, 1] is the Column count. If ($aArray[0][0] + 1) >= $iDimension Then $iDimension = Ceiling(($aArray[0][0] + 1) * 1.5) ReDim $aArray[$iDimension][$aArray[0][1]] Return 1 EndIf EndFunc ;==>_ReDim2D Func _ReDim1D_Ubound(ByRef $aArray, ByRef $iDimension, ByRef $iCount) ; Using Ubound($aArray, 1) to find the Row size. $iCount += 1 If ($iCount + 1) >= $iDimension Then $iDimension = Ceiling((UBound($aArray, 1) + 1) * 1.5) ReDim $aArray[$iDimension] Return 1 EndIf EndFunc ;==>_ReDim1D_Ubound Func _ReDim2D_Ubound(ByRef $aArray, ByRef $iDimension, ByRef $iCount) ; Using Ubound($aArray, 1) to find the Row size and Ubound($aArray, 2) for the Column size. $iCount += 1 If ($iCount + 1) >= $iDimension Then $iDimension = Ceiling((UBound($aArray, 1) + 1) * 1.5) ReDim $aArray[$iDimension][UBound($aArray, 2)] Return 1 EndIf EndFunc ;==>_ReDim2D_Ubound
    1 point
  11. PlayHD

    GUI design concepts.

    One of my old projects... #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $RBOX_EVENT_CLOSE = 1 Global $ROUNDES = 20, $LastHwnd = 0 Global $GUIBKCOLOR = 0xEEC591 Global $ARRAY_COLOR_TOP_MIN[3] = [36 ,65 ,142] , $ARRAY_COLOR_TOP_MAX[3] = [11 ,42 ,122] Local $hGui = RBoxCreate("Gui Design PHD",800,600) While 1 CheckX($hGui,$RBOX_EVENT_CLOSE,"GuiCtrlSetColor("&$RBOX_EVENT_CLOSE&",0xA3A3A3)","GuiCtrlSetColor("&$RBOX_EVENT_CLOSE&",0x555555)") $gMsg = GUIGetMsg() Switch $gMsg Case $RBOX_EVENT_CLOSE, $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func RBoxCreate($Title,$width, $height ,$left=-1 ,$top=-1 ,$show=1) Local $GUI = GUICreate($Title,$width,$height,$left,$top,$WS_POPUP) GUISetBkColor($GUIBKCOLOR,$GUI) _GuiRoundCorners($GUI,0,0,$ROUNDES,$ROUNDES) $RBOX_EVENT_CLOSE = GUICtrlCreateLabel('X',$width-20,3,25,25) GUICtrlSetCursor($RBOX_EVENT_CLOSE,0) GUICtrlSetBkColor($RBOX_EVENT_CLOSE,-2) GUICtrlSetFont($RBOX_EVENT_CLOSE,15,800) GUICtrlSetColor($RBOX_EVENT_CLOSE,0x555555) $Title &= " " Local $hTitle = GUICtrlCreateLabel($Title,0,0,$width-20,26,$SS_CENTER,$GUI_WS_EX_PARENTDRAG) GUICtrlSetFont($hTitle,17,400,0,"Consolas") GUICtrlSetBkColor($hTitle,-2) Local $Graphic = GUICtrlCreateGraphic (0,0, $width, 25) GUICtrlSetState($Graphic,$Gui_DISABLE) GradientFill($Graphic, 0, 0, $width, 25, $ARRAY_COLOR_TOP_MIN, $ARRAY_COLOR_TOP_MAX) If $show = 1 Then GUISetState(@SW_SHOW,$GUI) Return $GUI EndFunc Func CheckX($hGui, $CtrlID, $sCMD, $eCMD) Local $cGui = GUIGetCursorInfo($hGui) If Not IsArray($cGui) Then Return 0 if $LastHwnd <> $cGui[4] And $cGui[4] = $CtrlID Then Return Execute($sCMD) + Assign("LastHwnd",$cGui[4]) if $LastHwnd <> $cGui[4] Then Return Execute($eCMD) + Assign("LastHwnd",$cGui[4]) EndFunc Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) Dim $pos, $ret, $ret2 $pos = WinGetPos($h_win) $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3) If $ret[0] Then $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1) If $ret2[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf EndFunc Func GradientFill($im, $x1, $y1, $width, $height, $left_color, $right_color) Local $color0=($left_color[0]-$right_color[0])/$height Local $color1=($left_color[1]-$right_color[1])/$height $color2=($left_color[2]-$right_color[2])/$height For $Y=0 to $height-1 $red=$left_color[0]-floor($Y*$color0) $green=$left_color[1]-floor($Y*$color1) $blue=$left_color[2]-floor($Y*$color2) $col = Dec(Hex($blue,2) & Hex($green,2) & Hex($red,2)) GUICtrlSetGraphic($im,$GUI_GR_COLOR, $col) GUICtrlSetGraphic($im,$GUI_GR_MOVE,0,$Y) GUICtrlSetGraphic($im,$GUI_GR_LINE,$width,$Y) Next GUICtrlSetGraphic($im,$GUI_GR_COLOR, 0x000000) GUICtrlSetGraphic($im,$GUI_GR_MOVE,0,$height) GUICtrlSetGraphic($im,$GUI_GR_LINE,$width,$height) GUICtrlSetGraphic($im,$GUI_GR_REFRESH) EndFunc Here is a screen : http://prntscr.com/ni5sq
    1 point
  12. Yashied

    WinAPIEx UDF

    Help file was updated and added a few examples.
    1 point
  13. guinness

    WinAPIEx UDF

    Thats a lot of work! I was content with the examples you provided before but with all (300 I counted in au3.user.calltips.api) is fantastic.
    1 point
  14. Yashied

    WinAPIEx UDF

    Added Help file (WinAPIEx.chm inside the archive) that contains detailed information and examples for all functions from this library. Special thanks to MrCreatoR for help in the creation (generation) HTML pages for this file.
    1 point
  15. AndyG

    WinAPIEx UDF

    Thanks for this great collection of functions! And for the excellent examples too! Andy
    1 point
×
×
  • Create New...