Leaderboard
Popular Content
Showing content with the highest reputation on 07/22/2021 in all areas
-
create a Word Frequency Counter
SkysLastChance and one other reacted to JockoDundee for a topic
Come on, Vinny, ya know I’m just messin’ with ya! That post was from before we really got started cranking out the hits. But by the end of the semester, we was all good, right?2 points -
able to Send and Receive Frame and properly close websocket.1 point
-
Object method with structure array as parameter
DonChunior reacted to TheXman for a topic
@DonChunior I haven't looked through your whole bits.au3 udf file, but I do see one issue. Your definition if the BG_FILE_INFO struct is not correct. You aren't currently using it in your UDF but when/if you do, it will cause problems as it is currently defined. It is currently defined as: ; BG_FILE_INFO structure (https://docs.microsoft.com/en-us/windows/win32/api/bits/ns-bits-bg_file_info) Global Const $tagBG_FILE_INFO = "struct;wchar remoteName[2201];wchar localName[261];endstruct" it should be something like: Const $tagBG_FILE_INFO = _ "struct; " & _ "ptr remoteName;" & _ "ptr localName;" & _ "endstruct;" Below is a quick example that I created that will create an array of BG_FILE_INFO structs. It is based on an interpretation of the AddFileSet example code from the Microsoft site. It is commented pretty well but does not have any error checking. It is just a quick script to show another way that the struct array can be created. Because AutoIt does not make it easy to get pointer information of normally declared variables, the next best thing is to declare structs to hold the variables. That will give you access to their pointers. So as you will see, in order to get pointers to the remote and local names of the file set, I create an array of structs for the names. Other than that, the code should be pretty straight forward. I haven't tested it with your UDF. I'll leave that part of the fun to you. #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d #include <Constants.au3> #include <WinAPIDiag.au3> #include <Array.au3> Const $gtagBG_FILE_INFO = _ "struct; " & _ "ptr remoteName;" & _ "ptr localName;" & _ "endstruct;" Global $gaFileSet = _ [ _ ["http://ipv4.download.thinkbroadband.com/1GB.zip", "C:\Temp\1GB.zip"], _ ["http://ipv4.download.thinkbroadband.com/512MB.zip", "C:\Temp\512MB.zip"] _ ] Global $gtBG_FILE_INFO_ARRAY = "" ;Get BG_FILE_INFO_ARRAY $gtBG_FILE_INFO_ARRAY = get_bg_file_info_array_struct_example($gaFileSet) ;Display BG_FILE_INFO_ARRAY _WinAPI_DisplayStruct( _ $gtBG_FILE_INFO_ARRAY, _ StringFormat("ptr[%i]", UBound($gaFileSet) * 2), _ "BG_FILE_INFO Array" _ ) Func get_bg_file_info_array_struct_example($aFileSet) Local $tBG_FILE_INFO = "", $tByteBuffer = "", $tBG_FILE_INFO_ARRAY = "" Local $iBG_FILE_INFO_SIZE = 0 Local $pArrayItemPointer = 0 Local $xWcharString = Binary("") Local $atRemoteNames[0], $atLocalNames[0] ;For each file set For $i = 0 To UBound($aFileSet) - 1 ;Add remote name to array of remote name structs $xWcharString = StringToBinary($aFileSet[$i][0], $SB_UTF16LE) $tByteBuffer = DllStructCreate(StringFormat("byte data[%i];", BinaryLen($xWcharString))) $tByteBuffer.data = $xWcharString _ArrayAdd($atRemoteNames, $tByteBuffer) ;Add local name to array of local name structs $xWcharString = StringToBinary($aFileSet[$i][1], $SB_UTF16LE) $tByteBuffer = DllStructCreate(StringFormat("byte data[%i];", BinaryLen($xWcharString))) $tByteBuffer.data = $xWcharString _ArrayAdd($atLocalNames, $tByteBuffer) Next ;Create a bg_file_info struct to get size of struct $tBG_FILE_INFO = DllStructCreate($gtagBG_FILE_INFO) $iBG_FILE_INFO_SIZE = DllStructGetSize($tBG_FILE_INFO) ;Create byte buffer to hold array of bg_file_info structs $tBG_FILE_INFO_ARRAY = DllStructCreate(StringFormat("byte buffer[%i]", $iBG_FILE_INFO_SIZE * UBound($aFileSet))) ;For each file set For $i = 0 To UBound($aFileSet) - 1 ;Add a populated bg_file_info struct to the array of bg_file_info structs $pArrayItemPointer = DllStructGetPtr($tBG_FILE_INFO_ARRAY) + ($iBG_FILE_INFO_SIZE * $i) $tBG_FILE_INFO = DllStructCreate($gtagBG_FILE_INFO, $pArrayItemPointer) $tBG_FILE_INFO.remoteName = DllStructGetPtr($atRemoteNames[$i]) $tBG_FILE_INFO.localName = DllStructGetPtr($atLocalNames[$i]) Next ;Sanity check - Display values from the bg_file_info array to make sure they were loaded properly For $i = 0 To UBound($aFileSet) - 1 ;Point to bg_file_info struct item within the bg_file_info array $pArrayItemPointer = DllStructGetPtr($tBG_FILE_INFO_ARRAY) + ($iBG_FILE_INFO_SIZE * $i) $tBG_FILE_INFO = DllStructCreate($gtagBG_FILE_INFO, $pArrayItemPointer) ;Get & display the remote name pointed to by the remote name pointer $tByteBuffer = DllStructCreate("byte data[1000];", $tBG_FILE_INFO.remoteName) ConsoleWrite(StringFormat("Remote name %2i = %s", $i + 1, BinaryToString($tByteBuffer.data, $SB_UTF16LE)) & @CRLF) ;Get & display the local name pointed to by the local name pointer $tByteBuffer = DllStructCreate("byte data[1000];", $tBG_FILE_INFO.localName) ConsoleWrite(StringFormat("Local name %2i = %s", $i + 1, BinaryToString($tByteBuffer.data, $SB_UTF16LE)) & @CRLF) Next Return $tBG_FILE_INFO_ARRAY EndFunc Console output: (this output was just a sanity check for me to know that the information in the arrays were correct) Remote name 1 = http://ipv4.download.thinkbroadband.com/1GB.zip Local name 1 = C:\Temp\1GB.zip Remote name 2 = http://ipv4.download.thinkbroadband.com/512MB.zip Local name 2 = C:\Temp\512MB.zip1 point -
1 point
-
I found another way to change the color without loosing proper anti-aliasing. For this solution GDI+ v1.1 (Win7+) is required. #include <Array.au3> #include <GDIPlus.au3> #include <WinAPISysWin.au3> #include <WinAPIShellEx.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example_1() Func _SetBkIcon($ControlID, $iForeground, $iBackground, $sIcon, $iIndex, $iWidth, $iHeight) Local Static $STM_SETIMAGE = 0x0172 Local $hBitmap, $hGfx, $hImage, $hIcon, $hBkIcon $hIcon = _WinAPI_ShellExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) $hImage = _GDIPlus_BitmapCreateFromHICON32($hIcon) Local $r = BitShift(BitAND($iForeground, 0xFF0000), 16), $g = BitShift(BitAND($iForeground, 0xFF00), 8), $b = BitAND($iForeground, 0xFF) Local $hEffect = _GDIPlus_EffectCreateColorCurve($GDIP_AdjustExposure, $GDIP_CurveChannelRed, $r) ;GDI+ v1.1 is needed -> Win7+ _GDIPlus_BitmapApplyEffect($hImage, $hEffect) _GDIPlus_EffectDispose($hEffect) $hEffect = _GDIPlus_EffectCreateColorCurve($GDIP_AdjustExposure, $GDIP_CurveChannelGreen, $g) _GDIPlus_BitmapApplyEffect($hImage, $hEffect) _GDIPlus_EffectDispose($hEffect) $hEffect = _GDIPlus_EffectCreateColorCurve($GDIP_AdjustExposure, $GDIP_CurveChannelBlue, $b) _GDIPlus_BitmapApplyEffect($hImage, $hEffect) _GDIPlus_EffectDispose($hEffect) If $iBackground Then $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsClear($hGfx, $iBackground) _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage, 0, 0, $iWidth, $iHeight) _GDIPlus_ImageDispose($hImage) $hImage = _GDIPlus_ImageClone($hBitmap) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) EndIf $hBkIcon = _GDIPlus_HICONCreateFromBitmap($hImage) GUICtrlSendMsg($ControlID, $STM_SETIMAGE, $IMAGE_ICON, $hBkIcon) _WinAPI_RedrawWindow(GUICtrlGetHandle($ControlID)) _WinAPI_DeleteObject($hIcon) _WinAPI_DeleteObject($hBkIcon) _GDIPlus_ImageDispose($hImage) Return SetError(0, 0, 1) EndFunc ;==>_SetBkIcon Func Example_1() Local $hGui = GUICreate("GDI+", 512, 256) GUISetState(@SW_SHOW) If Not _GDIPlus_Startup() Or @extended < 6 Then MsgBox($MB_SYSTEMMODAL, "ERROR", "GDIPlus.dll v1.1 not available") Return EndIf ; Original Icon GUICtrlCreateIcon(@ScriptDir & "\git.ico", -1, 0, 0, 256, 256) ; Only Recolor Background GUICtrlCreateIcon("", -1, 256, 0, 256, 256) _SetBkIcon(-1, 0xFFABCDEF, 0xFFFFFF00, @ScriptDir & "\git.ico", -1, 256, 256) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete($hGui) EndFunc ;==>Example_1 Works best with monochrome like images. Btw, when you use $hImage = _GDIPlus_BitmapCreateFromHICON32($hIcon) in your example it will work, too.1 point
-
Thanky you pseakins and Musashi for you help with this.1 point
-
(Poll) What features do you wish you had in AutoIt?
argumentum reacted to TheDcoder for a topic
@Earthshine Good to know that you'd use EasyCodeIt if those features were implemented. Yes, but I was not referring to AutoIt itself in my message, I was talking about ECI. As you can see from the amount of suggested features in this thread, some of those would take a couple of good megabytes No reason to have any of that around if your code isn't using those bits. Also this would make the job of AVs easier as they can actually check if the code needs networking or crypto to determine if it is a virus, win-win for everyone. We have discussed namespaces already, I plan to introduce them as they could be used to maintain backward compatible version of functions etc. while also providing improved versions of the same functions. Perhaps it could also be useful to get rid of very long prefixes to variable and function names in UDFs. You have bought up a good point, I am not sure if I will implement multi-dimensional arrays, instead I am thinking about implementing first-class support for sub-arrays, meaning you can assign an array like a normal value to any other variable, including arrays. C has the same implementation, you can't have multi-dimensional arrays but you can have arrays inside arrays. This would not be needed if arrays are implemented in the method mentioned above. I will also be introducing array literals, this should give array objects first class support as opposed to the sort of exotic objects they are now in AU3. Should be easy to implement, named arguments aren't bad either. Again, array as a first-class object means you can have arbitrary amount of recursion or cells (only limited by memory and integer representation size). Struggled with this issue myself, so will definitely implement an atomic swap operation for variables. This was already suggested atleast once before, what's the difference between them and arrays? Perhaps you can link to relevant material (according to what you mean by "lists"?) Another thing which I thought of before, will definitely look into implementing... perhaps the syntax can be For ByRef $x In $aArray so that $x will always reference the same object that is in the array. -- Without quoting jchd's huge post about sorting, I think a good idea will be to implement native in-place sorting with the help of a custom function, similar to how qsort works.1 point -
create a Word Frequency Counter
JockoDundee reacted to TheDcoder for a topic
I hate homework and interview coding, there isn't much of a difference between both, they want some arbitrary twisted thing done instead of something practical. If I was good at those I would be doing math or spell bee competitions1 point -
Think I've found the regression which was introduced by the changes I've made for Please check this Beta v3.3.15.5 of au3check to see what other things I've broken.1 point
-
AutoIt v3.3.15.4 Beta
Trong reacted to argumentum for a topic
Ok, I replaced the v3.3.15.4 ( failing ) with v3.3.14.5 ( ok ) and even 1.54.22.0 ( ok ). So the issue started with this new version. >"C:\PortableAU3\autoit-v3.3.15.4\SciTE\..\AutoIt3.exe" "C:\PortableAU3\autoit-v3.3.15.4\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /Prod /AU3check /in "C:\PortableAU3\autoit-v3.3.15.4\Examples\GUI\SampleControls.au3" +>13:28:54 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0) Keyboard:00000409 OS:WIN_10/2004 CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\PortableAU3\autoit-v3.3.15.4\SciTE UserDir => C:\PortableAU3\autoit-v3.3.15.4\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\PortableAU3\autoit-v3.3.15.4\SciTE\SCITE_USERHOME >Running AU3Check (3.3.15.4) from:C:\PortableAU3\autoit-v3.3.15.4 input:C:\PortableAU3\autoit-v3.3.15.4\Examples\GUI\SampleControls.au3 +>13:28:54 AU3Check ended.rc:0 +>13:28:54 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6618 I edited and added the code to "SampleControls.au3" for this test.1 point -
Faster search
FrancescoDiMuro reacted to Nine for a topic
How about your create a simple SQLite DB to manage this (Table = Machine number , Tool number) You could query in both direction -> What tools runs on a specific machine or What machines can take a specific tool.1 point -
After you close the tab, it is your responsibility to reestablish the original tab as the active "target". You need to do something like this -- ; Save the current tab handle $sTabHandle = _WD_Window($sSession, 'window') ; Perform your intermediate steps here ; Reactivate original tab _WD_Window($sSession, 'window', $sTabHandle)1 point
-
Can you fix the HotKeySet and @HotKeyPressed
Dana reacted to JockoDundee for a topic
Imagining what V. would say to that1 point -
The new Windows and Internet Explorer
TheDcoder reacted to argumentum for a topic
Quite a lengthy text to say the IE UDF does not work on Win11. Thank you for reading.1 point -
WebDriver UDF (W3C compliant version) - 2024/09/21
CorporateRobotics reacted to TheXman for a topic
Below is my version of the _WD_GetTable() helper function (named _WD_GetTable_2) that I use for grabbing tables from web sites. The difference between it and the existing _WD_GetTable() is that it spins thru the rows to find the maximum number of columns in the table. As you know, the current _WD_GetTable() only checks the first <tr> to determine the number of columns. I found that to be problematic for some of the tables that I have come across. This is certainly not the fastest way to get table data, but it is a more reliable way to get table data and uses native WebDriver functions. Maybe others may find it useful in those cases where the first row of the table doesn't reflect all of the columns in the body of the table. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WD_GetTable_2 ; Description ...: Return all elements of a table ; Syntax ........: _WD_GetTable_2($sSession, $sBaseElement) ; Parameters ....: $sSession - Session ID from _WDCreateSession ; $sTableXpath - XPath of the table to return ; Return values .: Success - 2D array ; Failure - "" ; @ERROR - $_WD_ERROR_Success ; - $_WD_ERROR_Exception ; - $_WD_ERROR_NoMatch ; @EXTENDED - WinHTTP status code ; Author ........: TheXman ; Modified ......: ; Remarks .......: Number of rows and max cols are determined based on actual table data. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WD_GetTable_2($sSession, $sTableXpath) Const $sFuncName = "_WD_GetTable_2" Local $aTable[0], $aRowElements[0], $aColElements[0] Local $sRowColumns = "" Local $iRows = 0, $iCols = 0, $iChildCount = 0 ;Get table row elements $aRowElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sTableXpath & "/tbody/tr", "", True) If @error <> $_WD_ERROR_Success Then Return SetError(__WD_Error($sFuncName, @error, "HTTP status = " & $_WD_HTTPRESULT), $_WD_HTTPRESULT, "") $iRows = UBound($aRowElements) ;Find max number of columns by checking each row's child count property For $iRow = 0 To UBound($aRowElements) - 1 $iChildCount = _WD_ElementAction($sSession, $aRowElements[$iRow], "property", "childElementCount") If @error <> $_WD_ERROR_Success Then Return SetError(__WD_Error($sFuncName, @error, "HTTP status = " & $_WD_HTTPRESULT), $_WD_HTTPRESULT, "") ;If number of row columns is greater the previous value, then save new value If $iChildCount > $iCols Then $iCols = $iChildCount Next ;Dimension and load table data ReDim $aTable[0][$iCols] For $iRow = 0 To $iRows - 1 ;Get column elements (td or th) $aColElements = _WD_FindElement($sSession, _ $_WD_LOCATOR_ByXPath, _ "./td|./th", _ $aRowElements[$iRow], _ True) If @error <> $_WD_ERROR_Success Then Return SetError(__WD_Error($sFuncName, @error, "HTTP status = " & $_WD_HTTPRESULT), $_WD_HTTPRESULT, "") ;Build pipe-separated row of column data $sRowColumns = "" For $iCol = 0 To UBound($aColElements) - 1 If $iCol = 0 Then $sRowColumns &= _WD_ElementAction($sSession, $aColElements[$iCol], "text") Else $sRowColumns &= "|" & _WD_ElementAction($sSession, $aColElements[$iCol], "text") EndIf Next ;Add row to array _ArrayAdd($aTable, $sRowColumns) Next ;Return result table Return $aTable EndFunc Here's an example of a table and its definition that the current _WD_GetTable() has a problem with because the first <tr> does not accurately define the max number of columns.1 point