Leaderboard
Popular Content
Showing content with the highest reputation since 09/09/2025 in Posts
-
EndIf "overhead"
genius257 and 4 others reacted to AspirinJunkie for a topic
To break down the performance behavior in more detail: It depends on whether the condition is met or not. The following test script: Global Const $N = 1e7 Global $iT, $f_Overhead ConsoleWrite(@CRLF & " name time" & @CRLF & "--------------------------------------" & @CRLF) ; determine the overhead of loop [and optional other stuff] $iT = TimerInit() For $i = 1 To $N Next $f_Overhead = TimerDiff($iT) $iVariable = 1 $iT = TimerInit() For $i = 1 To $N If $iVariable Then $iVariable = 1 EndIf Next $iT = TimerDiff($iT) ConsoleWrite(StringFormat("% 20s:\t%10.6f ms\n", "If-EndIf True", ($iT-$f_Overhead) / $N)) $iVariable = 0 $iT = TimerInit() For $i = 1 To $N If $iVariable Then $iVariable = 1 EndIf Next $iT = TimerDiff($iT) ConsoleWrite(StringFormat("% 20s:\t%10.6f ms\n", "If-EndIf False", ($iT-$f_Overhead) / $N)) $iVariable = 1 $iT = TimerInit() For $i = 1 To $N If $iVariable Then $iVariable = 1 Next $iT = TimerDiff($iT) ConsoleWrite(StringFormat("% 20s:\t%10.6f ms\n", "If-OneLiner True", ($iT-$f_Overhead) / $N)) $iVariable = 0 $iT = TimerInit() For $i = 1 To $N If $iVariable Then $iVariable = 1 Next $iT = TimerDiff($iT) ConsoleWrite(StringFormat("% 20s:\t%10.6f ms\n", "If-OneLiner False", ($iT-$f_Overhead) / $N)) produces for me: name time -------------------------------------- If-EndIf True: 0.000260 ms If-EndIf False: 0.000161 ms If-OneLiner True: 0.000481 ms If-OneLiner False: 0.000088 ms So it depends on whether the condition is met or not. If it is met, then the classic If-EndIf is faster. If it is not met, the one-liner is faster. When conditions are balanced, their times will be roughly the same. If you can estimate whether the vast majority of conditions are true or false, then you could certainly optimize on that basis. The relative differences are quite significant. But in absolute terms, they are completely subordinated. To put the measured numbers into perspective: we are talking about a difference between 160 nanoseconds and 88 nanoseconds – not milliseconds, not even microseconds! No, nanoseconds! These are therefore overshadowed by any other parts of the code. (unless the script consists purely of millions of consecutive if queries). This decision therefore makes no relevant difference to the overall script. However, this makes the answer for this thread quite straightforward (as the others have already said): which of the two is used is independent of any performance considerations. The decision should be based solely on readability and clarity at the specific code location.5 points -
I compiled Zint v2.15.09 source and it has 30 functions! ZBarcode_BarcodeName|0x0001CBA0 ZBarcode_Buffer|0x0001CC20 ZBarcode_Buffer_Vector|0x0001CC60 ZBarcode_Cap|0x0001CCA0 ZBarcode_Clear|0x0001D270 ZBarcode_Create|0x0001D390 ZBarcode_Default_Xdim|0x0001D3C0 ZBarcode_Delete|0x0001D5D0 ZBarcode_Dest_Len_ECI|0x0001D630 ZBarcode_Encode|0x0001D6D0 ZBarcode_Encode_File|0x0001D710 ZBarcode_Encode_File_and_Buffer|0x0001DB00 ZBarcode_Encode_File_and_Buffer_Vector|0x0001DB50 ZBarcode_Encode_File_and_Print|0x0001DBA0 ZBarcode_Encode_Segs|0x0001DBE0 ZBarcode_Encode_Segs_and_Buffer|0x0001E890 ZBarcode_Encode_Segs_and_Buffer_Vector|0x0001E8F0 ZBarcode_Encode_Segs_and_Print|0x0001E950 ZBarcode_Encode_and_Buffer|0x0001E990 ZBarcode_Encode_and_Buffer_Vector|0x0001EA10 ZBarcode_Encode_and_Print|0x0001EA90 ZBarcode_HaveGS1SyntaxEngine|0x0001EAF0 ZBarcode_NoPng|0x0001EB00 ZBarcode_Print|0x0001EB10 ZBarcode_Reset|0x0001EC30 ZBarcode_Scale_From_XdimDp|0x0001ECA0 ZBarcode_UTF8_To_ECI|0x0001EE80 ZBarcode_ValidID|0x0001EF40 ZBarcode_Version|0x0001EF80 ZBarcode_XdimDp_From_Scale|0x0001EF90 I will update the code in the next days. I compiled also a x64 Zint DLL but I don't know if it is working yet...4 points
-
💡 Did You Know AutoIt’s Truthiness Rules Can Surprise You? Or that empty strings are False but "0" (as a string) is True? Or that Not $variable doesn’t work the way you might think? 🔍 Understanding Logical Expression Evaluation in AutoIt When working with AutoIt, one of the subtle but important differences compared to languages like C, JavaScript, or Python is how logical expressions are evaluated. 👉 AutoIt does not have a dedicated Boolean type. Instead, it uses other values (strings, numbers, etc.) and interprets them as True or False. This article breaks down AutoIt’s “truthiness rules” and explains what Not $variable really means. 1️⃣ No Boolean Type in AutoIt Unlike many languages, AutoIt does not define a bool type. Instead: Strings and numbers are interpreted as logical values. A function or expression that “returns True/False” is really returning an integer (1 or 0). 2️⃣ Truthiness Rules When AutoIt evaluates a value in a conditional (If, While, etc.): "" (empty string) → False 0 (number) → False Any non-empty string → True Any non-zero number → True ✅ Examples: If "" Then MsgBox(0, "Test", "This will NOT show") ; False If "hello" Then MsgBox(0, "Test", "This WILL show") ; True If 0 Then MsgBox(0, "Test", "This will NOT show") ; False If -1 Then MsgBox(0, "Test", "This WILL show") ; True 3️⃣ What Does Not $variable Do? The Not operator simply inverts the truthiness of a value. ConsoleWrite(Not "" & @CRLF) ; 1 (True) ConsoleWrite(Not "abc" & @CRLF) ; 0 (False) ConsoleWrite(Not 0 & @CRLF) ; 1 (True) ConsoleWrite(Not 123 & @CRLF) ; 0 (False) 👉 In plain: Not $variable is like asking “is this variable empty or zero?” 4️⃣ Real Example: _PathFull UDF In the standard UDF File.au3, the function _PathFull has this line: If Not $sRelativePath Or $sRelativePath = "." Then Return $sBasePath This handles two cases: $sRelativePath is "" → return the base path. $sRelativePath is "." → return the base path (current directory). 💡 This works because AutoIt treats an empty string as False. 5️⃣ Common Pitfalls ❌ Pitfall 1: Expecting False to exist Local $x = False If $x Then MsgBox(0, "Result", "Will this show?") ; False is just 0, there’s no real Boolean type. ❌ Pitfall 2: Forgetting that "0" (string) is True If "0" Then MsgBox(0, "Result", "This WILL show!") ; Non-empty string = True ; But numeric 0 would be False. ❌ Pitfall 3: Misunderstanding Not Local $val = "hello" If Not $val Then MsgBox(0, "Result", "Will this show?") ; Never runs because "hello" = True EndIf ✅ Key Takeaways AutoIt has no Boolean type — just numbers and strings used as truth values. "" (empty string) and 0 (numeric) = False. Everything else = True. "0" (string) = True, but 0 (number) = False. Not $var = “is this variable empty or zero?”. 📝 Conclusion Understanding AutoIt’s truthiness rules is essential for writing reliable conditions. They make scripts concise, but can be surprising if you expect strict Boolean behavior. 👉 Pro Tip: Use AutoIt’s implicit truthiness for quick checks, but when clarity matters, be explicit: Use StringLen() to check if a string is empty. Don't use IsNumber() if you don't understand it, read more here. Use comparisons (=, <>) for precise logic. That way, your intent is clear, and you avoid bugs caused by AutoIt’s flexible but tricky truth rules. 💬 Final Note: If I’ve misunderstood or explained something incorrectly, please share your thoughts — I’d be happy to update and improve this article!3 points
-
Did You Know How AutoIt Evaluates Logical Expressions?
SOLVE-SMART and 2 others reacted to AspirinJunkie for a topic
What exactly leads you to this conclusion? This cannot be deduced from your following text. All of this can be explained perfectly by the fact that there are specific rules for converting other data types to the Boolean data type. There is nothing explicitly against the existence of a corresponding dedicated Boolean data type. Nope - if that were the case, they would behave exactly the same way - but they don't: ConsoleWrite("compare with int type: " & ("0" = retInt() ? True : False) & @CRLF) ConsoleWrite("compare with bool type: " & ("0" = retBool() ? True : False) & @CRLF) Func retInt() Return 1 EndFunc Func retBool() Return True EndFunc The following are also converted to False during conversion to Boolean: Global $aArray[1] Global $mMap[] If $aArray Then MsgBox(0, "", "Array = True") If $mMap Then MsgBox(0, "", "Map = True") If ObjCreate("Scripting.Dictionary") Then MsgBox(0, "", "Object = True") If Default Then MsgBox(0, "", "Default = True") If Ptr(0x0) Then MsgBox(0, "", "Ptr(0) = True") If DllStructCreate("CHAR[1]") Then MsgBox(0, "", "DllStruct = True") If ConsoleWrite Then MsgBox(0, "", "Function pointer = True") Basically, this discussion only touches superficially on logical expressions in AutoIt. In fact, the behavior is only a consequence of the real topic: Implicit data type conversions in AutoIt: AutoIt (like many other languages) is a dynamically typed language. In other words, variables do not have a fixed data type; instead, this can be changed at will during the lifetime of the variable. Nevertheless, variables can be linked together as desired using operators. But internally, at the machine level, only identical data types can be linked together. For example, addition is only possible between two Int32s and not between a Double and an Int32, etc. Therefore, one task of the AutoIt interpreter in operations with multiple operands or when the operation requires a specific target data type is to align the different data types with each other. AutoIt defines fixed rules for how certain data types are converted into others. Integers, for example, are converted to floats by considering the value as the integer part of the resulting float. How exactly certain data types are converted to the Boolean data type (yes, Boolean is explicitly listed as a separate data type) is described in part in the >>AutoIt help<<. Specifically, it says the following, for example: This explains exactly the behavior you described above. And we're not even talking about logical expressions yet - it's just about implicit data type conversion. If you keep in mind that logical operators and the if branch must have the expression as a Boolean, it quickly becomes clear that this is not actually about the behavior of logical expressions, but rather that they are only a consequence of the implicit data type conversion of other data types to the Boolean data type. In summary: The behavior described above describes the effects of implicit conversion of other data types to the Boolean data type. Everything described can be explained completely by this. However, I do not see the slightest indication in the description that AutoIt should not have a dedicated boolean data type.3 points -
UDF and DLL updated! See post#1. The DLLs are too big to post it here. You can find it on my 1Drv! Feel free to post examples here!2 points
-
Disable combobox selection frame
WildByDesign and one other reacted to argumentum for a topic
#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <ComboConstants.au3> Local $hGUI = GUICreate("COMBOBOX", 500, 500) GUISetBkColor(0xE9E6DF) Local $idBttnFocus = GUICtrlCreateButton("=P", -20, -20, 5, 5) ; my trick Local $idComboBox = GUICtrlCreateCombo("Item 1", 100, 200, 260, 20, $CBS_DROPDOWNLIST) GUICtrlSetFont(-1, 18, 700, 0, "Segoe UI", 4) GUICtrlSetData($idComboBox, "COMBOBOX|COMBOBOX1|COMBOBOX2|COMBOBOX3", "COMBOBOX") ; WildByDesign ;~ Global Const $WM_CHANGEUISTATE = 0x0127 ;~ GUICtrlSendMsg($idComboBox, $WM_CHANGEUISTATE, 65537, 0) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) ..am a bit late but, this is what I use.2 points -
Disable combobox selection frame
argumentum and one other reacted to WildByDesign for a topic
GUICtrlSendMsg($idComboBox, $WM_CHANGEUISTATE, 65537, 0) Try this.2 points -
I just came across some odd behavior when automating a third party software app. On this third party app, there's a dialog with an edit control where you can enter an ID number that's 9 digits long. As soon as you enter the 9th digit the app immediately checks to see if it recognizes the ID as being an existing customer and if it does, it pops up a modal Yes/No window asking if you want to autofill the customer's information on the rest of the dialog. This popup correctly occurs whether my AutoIt app fills the edit control with 9 digits using ControlSetText or ControlSend. My AutoIt app needs to know whether the popup happens in order to determine its next action, so I follow the ControlSetText or ControlSend with a WinWait call looking for the popup, with a 2 second timeout. Here's where the odd behavior comes. If I fill the edit control using ControlSetText and the popup window appears, my WinWait doesn't start looking for the popup window until after the user has clicked Yes or No on it (and thereby dismissed the window). The AutoIt app just sits there idle the entire time that the Yes/No window is visible. Then as soon as the user clicks Yes or No (and dismisses the modal window), the WinWait immediately begins looking for that (now dismissed) window and of course never finds it. If I instead fill the edit control with ControlSend, AutoIt doesn't hang while the Yes/No window is visible, and WinWait immediately finds the window as expected. My guess is that the 3rd party app is popping up the modal Yes/No window before the original dialog can provide the return code from ControlSetText's underlying SendMessage command (probably due to some improper subclassing in the 3rd party app that shows the popup dialog before allowing the WndProc function to complete its operation and return a value). As a result, AutoIt is left sitting there waiting for that message before the ControlSetText function completes and it can move on to the next line of the script. Once the user dismisses the modal Yes/No window and the original dialog can continue, the return code gets received by AutoIt, the ControlSetText command finishes, and the script continues. With the ControlSend command, AutoIt apparently doesn't get stuck waiting for a return message, and can proceed with finding the window and acting accordingly. So I'm not looking for a solution, since using ControlSend is the workaround. Just posting here in case someone else comes across something similar and is banging their head on the keyboard as I was.2 points
-
Thank you very much ioa747 , that's exactly what I was looking for 🙂 Have a great weekend, both of you. Reggards2 points
-
Microsoft Edge - WebView2, embed web code in your native application
SOLVE-SMART and one other reacted to mLipok for a topic
May you release it on github.com ? Then we be able to look over enttire udf and have a better look2 points -
MustReturnArray()
Danyfirex and one other reacted to argumentum for a topic
#include <WinAPIProc.au3> ; for the example Func MustReturnArray($aArray, $iColumns = 0, $iErr = @error, $iExt = @extended) If UBound($aArray) Then Return SetError($iErr, $iExt, $aArray) If $iColumns Then Dim $aArray[1][$iColumns] = [[0]] Else Dim $aArray[1] = [0] EndIf Return SetError($iErr, $iExt, $aArray) EndFunc ;==>MustReturnArray Exit MustReturnArray_Example() Func MustReturnArray_Example() ; worry free return Local $aWinList = WinList("nah, is not there") For $n = 1 To $aWinList[0][0] ConsoleWrite($aWinList[$n][1] & @TAB & $aWinList[$n][0] & @CRLF) Next ; worry free return Local $aProcessList = ProcessList("nah, is not there") For $n = 1 To $aProcessList[0][0] ConsoleWrite($aProcessList[$n][1] & @TAB & $aProcessList[$n][0] & @CRLF) Next ; solution ; create a "worry free return" Local $aArray = MustReturnArray(_WinAPI_EnumProcessWindows(4), 2) For $n = 1 To $aArray[0][0] ConsoleWrite($aArray[$n][1] & @TAB & $aArray[$n][0] & @CRLF) Next ; problem ; not a "worry free return" Local $aArray = _WinAPI_EnumProcessWindows(4) For $n = 1 To $aArray[0][0] ConsoleWrite($aArray[$n][1] & @TAB & $aArray[$n][0] & @CRLF) Next EndFunc ;==>MustReturnArray_Example Before I start with my problem ( and solution ), a big thank you to everyone coding these UDFs. AutoIt would not be what it is without them. ... a coder should always check @error, but is a pain, or not. In any case, the internal AutoIt functions return an array even if nothing there when an array is what it returns on success. Am so used to it, that when I use a UDF function I have to RTFM and I don't like reading ( nor writing but here we are 🤷♂️ ) How should I solve this problem given my coding style that does not include a failing function returning a zero stead of the array I was expecting. AutoIt does it, why does the UDFs not do it ?, ... must be a professional coders thing but, am a scripter. I write scripts. So, if it should return an array, then MustReturnArray() !. I hope this idea/function helps you avoid the " ==> Subscript used on non-accessible variable. " and/or simplify your code2 points -
Help File/Documentation Issues. (Discussion Only)
Musashi and one other reacted to pixelsearch for a topic
@donnyh13 Hi When we discussed this with @jchd and @jpm in Trac Ticket #3945 then the last table at the end of the web page showed the results with a better alignment, I'm pasting it below : Row Unicode CharacterName \h \v \s [[:space:]] [[:blank:]] -------------------------------------------------------------------------------- # 1 0x0009 HT xX xX xX xX # 2 0x000A LF xX xX xX # 3 0x000B VT xX xX xX # 4 0x000C FF xX xX xX # 5 0x000D CR xX xX xX # 6 0x0020 SPACE xX xX xX xX # 7 0x0085 NEL xX X X # 8 0x00A0 NO-BREAK SPACE xX X X X # 9 0x1680 OGHAM SPACE MARK xX X X X # 10 0x180E MONGOLIAN VOWEL SEPARATOR xX X X X # 11 0x2000 EN QUAD xX X X X # 12 0x2001 EM QUAD xX X X X # 13 0x2002 EN SPACE xX X X X # 14 0x2003 EM SPACE xX X X X # 15 0x2004 THREE-PER-EM SPACE xX X X X # 16 0x2005 FOUR-PER-EM SPACE xX X X X # 17 0x2006 SIX-PER-EM SPACE xX X X X # 18 0x2007 FIGURE SPACE xX X X X # 19 0x2008 PUNCTUATION SPACE xX X X X # 20 0x2009 THIN SPACE xX X X X # 21 0x200A HAIR SPACE xX X X X # 22 0x2028 LINE SEPARATOR xX X X # 23 0x2029 PARAGRAPH SEPARATOR xX X X # 24 0x202F NARROW NO-BREAK SPACE xX X X X # 25 0x205F MEDIUM MATHEMATICAL SPACE xX X X X # 26 0x3000 IDEOGRAPHIC SPACE xX X X X Legend : xX will match with or without (*UCP) in the pattern X alone will match ONLY if (*UCP) is present at the start of the pattern For example let's create a subject starting with "abc" followed by a no-break space (0x00A0) and ending with "def" , so the subject looks like this "abc def" (make sure there is a no-break space in the middle of the subject between abc and def) . Now let's test different patterns : ======================= 2 patterns searching for \h abc\hdef => 1 match (*UCP)abc\hdef => 1 match Both patterns match because xX is indicated for \h (concerning the no-break space) ======================= 2 patterns searching for \s abc\sdef => NO match (*UCP)abc\sdef => 1 match Only the pattern starting with (*UCP) matches because X is indicated for \s (concerning the no-break space) This example could be applied to any of the 26 characters found in the table above Hope it helps2 points -
ProcessExists ,ProcessClose, FileReadToArray high CPU consumption
ioa747 and one other reacted to AspirinJunkie for a topic
Then, as already mentioned, the most relevant starting point for reducing the load is to write FileReadToArray before the while loop – not within! And at the same time, increase the sleep time slightly. That alone should make a big difference. If there is still a need for further optimization, then a different approach would be required: Currently, your script queries the current status of the process list at regular intervals and processes it. This is commonly referred to as "polling". A better option would be to tell Windows: You know when new processes are created anyway, so just let me know when that happens. This way, the script can go to sleep and will be actively woken up by Windows when a new process appears. This approach is called event registration, for example. There are events for file system operations or window creation and so on. However, I am not aware of any event-based approach for process creation that does not require administrator privileges. But we can still find a workaround. WMI offers the option of periodically querying its tables internally and automatically reporting new records when changes are made. Technically speaking, this is still polling, but in WMI it is more cost-effective than implementing it directly in AutoIt. In addition, you can also specify which processes you are interested in and specify from the outset that only processes with a name from your list should be reported, e.g. This further reduces the effort required for the script. And yes, your concern is correct: this does make the script more complicated. But if further optimization is really necessary, there is no real way around it: HotKeySet("{F9}", "goout") ; Create WMI object and sink for events Global $oWMI = ObjGet("winmgmts:\\") Global $oSink = ObjCreate("WbemScripting.SWbemSink") ; say WMI that the script should be informed of new processes as they appear in test.dat. (See function definition) _registerProcessCreation() ; endless loop for keeping the script running Do Sleep(100) Until False ; Function that is automatically called when the __InstanceCreationEvent occurs Func SINK_OnObjectReady($oProcess) ProcessClose($oProcess.TargetInstance.ProcessID) EndFunc Func goout() Exit EndFunc ; Creates the query string that defines exactly which process settings should be responded to. ; This query is then linked to the user's own function as an event handler. Func _registerProcessCreation() Local $mProcNames[] ; build the query-string out of the "Test.dat" file ; Queries the __InstanceCreationEvent events on the WMI class Win32_Process every 100 ms. ; Also limit the query to the processes listed in Test.dat. Local $sQuery = "SELECT * FROM __InstanceCreationEvent WITHIN 0.1 WHERE TargetInstance ISA 'Win32_Process' AND (" For $sProcessName In FileReadToArray("Test.dat") If Not MapExists($mProcNames, $sProcessName) Then ; Prevent duplicate process names $sQuery &= "TargetInstance.name = '" & $sProcessName & "' OR " $mProcNames[$sProcessName] = "" EndIf Next $sQuery = StringTrimRight($sQuery, 4) & ")" ; Events with the prefix “SINK_” are linked to corresponding AutoIt functions (we only need SINK_OnObjectReady). ObjEvent($oSink, "SINK_") ; Queries the __InstanceCreationEvent events on the WMI class Win32_Process every 100 ms. $oWMI.ExecNotificationQueryAsync($oSink, $sQuery) EndFunc2 points -
EndIf "overhead"
argumentum and one other reacted to Andreik for a topic
It's good to have a constant desire to write good and fast running code but on this matter I have the same feeling as @argumentum and as long as I use AutoIt I don't care too much so I use a mix of different conditional statements that make sense in each situation. If the performance it's such an issue to make me fight for each 1000th part of a ms probably I want to code in another language. But again as a good practice and for learning purpose your question is legit.2 points -
EndIf "overhead"
Andreik and one other reacted to argumentum for a topic
..perhaps.. . Perhaps is good. Not because one of your questions did not bring the house down, or you were right or not about making a big deal out of, something. Is good, is all good. So keep asking if there is a question. I enjoy the threads even if I don't have either time, or anything to contribute to it. This if-then-else thing, ...I had no idea, nor ever came up in my brain. Thinking about it, at times I use Switch as an If when is practical ( I don't care much about speed or memory with today's hardware )2 points -
_WinAPI_DwmEnableBlurBehindWindow in Windows 11
argumentum and one other reacted to mlibre2 for a topic
@argumentum @WildByDesign checked, as you say, this effect does not work in virtualized mode, thanks for trying it. and in the local environment 24h2 by inertia deactivate the transfer effect, it was the one that caused the detail2 points -
To use _WinAPI_BitmapDisplayTransparentInGUI() you must create a complete frame within the function. Example: ; https://www.autoitscript.com/forum/topic/213118-_circularprogress/ ;---------------------------------------------------------------------------------------- ; Title...........: _CircularProgress.au3 ; Description.....: Creates a customizable circular progress bar using GDI+ graphics. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.5 ; Note............: Testet in Win10 22H2 Date:08/09/2025 ; Based on post ..: https://www.autoitscript.com/forum/topic/213113-simple-circular-progressbar-with-smooth-edges-gradient-color/#findComment-1545755 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPISysWin.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <WinAPIConstants.au3> #include <Array.au3> _GDIPlus_Startup() Global $hGUI _Example() ; as demo _GDIPlus_Shutdown() Func _Example() $hGUI = GUICreate("RingProgressBar", 300, 300, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetState(@SW_SHOW) Local $aList[2000] Local $iCnt = UBound($aList) ConsoleWrite("$iCnt=" & $iCnt & @CRLF) Local $nProgress For $i = 1 To UBound($aList) $nProgress = Int($i / $iCnt * 100) ConsoleWrite($i & ") $nProgress=" & $nProgress & @CRLF) _CircularProgress($nProgress) Next Sleep(200) ; Give it some time to see the 100%. EndFunc ;==>_Example ; #FUNCTION# ==================================================================================================================== ; Name...........: _CircularProgress ; Description....: Creates a customizable circular progress bar using GDI+ graphics. ; Syntax.........: _CircularProgress($iPercent [, $iLeft = -1 [, $iTop = -1 [, $iSize = 300 [, $iThickness = 30 [, $TextCol = 0xFFFFFF [, $StartCol = 0xFF0000, $EndCol = 0xFFFF00]]]]]]) ; Parameters.....: $iPercent - The percentage complete for the progress bar (0 to 100). ; $iLeft - [optional] X-coordinate of the top-left corner. (Default is -1 for center) ; $iTop - [optional] Y-coordinate of the top-left corner. (Default is -1 for center) ; $iSize - [optional] width and height of the circular progress bar. (Default is 300) ; $iThickness - [optional] Thickness of the progress arc. (Default is 30) ; $TextCol - [optional] Color of the text within the progress bar. (Default is White) ; $StartCol - [optional] Start color of the progress arc gradient. (Default is Yellow) ; $EndCol - [optional] End color of the progress arc gradient. (Default is Red) ; Return values .: Success: create the progress bar GUI ; Author ........: ioa747 ; Modified ......: 08/09/2025 - v0.5 ; Remarks .......: Cleanup is handled automatically by passing an $iPercent > 100. ; Avoid using 0x050505 Color for $TextCol, $StartCol, or $EndCol, as it is used as a transparency color for the background. ; Related .......: _GDIPlus_Startup, _GDIPlus_GraphicsCreateFromHWND, etc. ; Link ..........: https://www.autoitscript.com/forum/topic/213113-simple-circular-progressbar-with-smooth-edges-gradient-color/#findComment-1545755 ; Example .......: _CircularProgress(50, -1, -1, 300, 20, 0x00FF00, 0xFF00FF, 0xFFFFFF) ; =============================================================================================================================== Func _CircularProgress($iPercent, $iSize = 300, $iThickness = 30, $TextCol = 0xFF404040, $StartCol = 0xFFFFFF00, $EndCol = 0xFFFF0000) Local $hBmp, $hBmpGraphics, $inSize, $iRadius, $iX, $iY $inSize = $iSize $iRadius = ($inSize - 4) / 2 $iX = $inSize / 2 $iY = $iX ; Create an off-screen bitmap for double-buffering $hBmp = _GDIPlus_BitmapCreateFromScan0($inSize, $inSize) $hBmpGraphics = _GDIPlus_ImageGetGraphicsContext($hBmp) _GDIPlus_GraphicsSetSmoothingMode($hBmpGraphics, 4) _GDIPlus_GraphicsSetTextRenderingHint($hBmpGraphics, 4) ; Draw progress arc as pie Local $angle = ($iPercent / 100) * 360 Local $hBrushProg = _GDIPlus_LineBrushCreate($iX - $iRadius, $iY, $iX + $iRadius, $iY, $EndCol, $StartCol, 1) Local $hPen = _GDIPlus_PenCreate2($hBrushProg, $iThickness) _GDIPlus_GraphicsDrawArc($hBmpGraphics, $iX - $iRadius + $iThickness / 2, $iY - $iRadius + $iThickness / 2, $iRadius * 2 - $iThickness, $iRadius * 2 - $iThickness, -90, $angle, $hPen) _GDIPlus_BrushDispose($hBrushProg) _GDIPlus_PenDispose($hPen) Local $hFontFamily = _GDIPlus_FontFamilyCreate("Times New Roman") Local $iFontSize = $iRadius * 0.3 Local $hFont = _GDIPlus_FontCreate($hFontFamily, $iFontSize, 1) Local $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 2) _GDIPlus_StringFormatSetLineAlign($hFormat, 2) Local $hBrushText = _GDIPlus_BrushCreateSolid($TextCol) ; Draw percentage text Local $rect = _GDIPlus_RectFCreate(($inSize - ($iFontSize * 4)) / 2, ($inSize - ($iFontSize * 2)) / 2, $iFontSize * 4, $iFontSize * 2) _GDIPlus_GraphicsDrawStringEx($hBmpGraphics, $iPercent & "%", $hFont, $rect, $hFormat, $hBrushText) _GDIPlus_FontFamilyDispose($hFontFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrushText) Local $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp) _WinAPI_BitmapDisplayTransparentInGUI($hHBmp, $hGUI) _GDIPlus_BitmapDispose($hBmp) _GDIPlus_GraphicsDispose($hBmpGraphics) EndFunc ;==>_CircularProgress Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $iFlags = $ULW_ALPHA, $bReleaseGDI = True, $tDest = Null, $iBGR = 0) If Not BitAND(GUIGetStyle($hGUI)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, $tDest, $tSize, $hMemDC, $tSource, $iBGR, $tBlend, $iFlags) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc ;==>_WinAPI_BitmapDisplayTransparentInGUI If you have static variable, such as bitmap, brushes, etc., you can put out these parts off the _CircularProgress() function.2 points
-
AutoIt v3.3.18.0 has been released - mainly a UDF release. Thanks to @jpm and the MVPs who were responsible for the majority of code in this version. Download it here. Complete list of changes: History2 points
-
Here a first draft for creating barcodes using the Zint.dll (v2.15.09). Mor information about Zint can be found here: https://zint.org.uk Zint, libzint and Zint Barcode Studio are Copyright © 2022 Robin Stuart. All historical versions are distributed under the GNU General Public License version 3 or later. Version 2.5 (and later) is released under a dual license: the encoding library is released under the BSD license whereas the GUI, Zint Barcode Studio, is released under the GNU General Public License version 3 or later. The code became too long to post here! -> Download from my OneDrive: Zint Zint.au3 ;Coded by UEZ ;v0.60 build 2025-09-14 beta ;IMPORTANT: You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name! ; Distributing copies of the program in compiled format (exe) must be free of any fee! #include-once #include "ZintDll.au3" Global $g__ZintDLL = @AutoItX64 ? (@ScriptDir & "\Zint64.dll") : (@ScriptDir & "\Zint.dll") #Region Constances ; === Barcode Symbologies === Global Const $BARCODE_CODE11 = 1 ; Code 11 Global Const $BARCODE_C25STANDARD = 2 ; 2 of 5 Standard (Matrix) Global Const $BARCODE_C25MATRIX = 2 ; Legacy Global Const $BARCODE_C25INTER = 3 ; 2 of 5 Interleaved Global Const $BARCODE_C25IATA = 4 ; 2 of 5 IATA Global Const $BARCODE_C25LOGIC = 6 ; 2 of 5 Data Logic Global Const $BARCODE_C25IND = 7 ; 2 of 5 Industrial Global Const $BARCODE_CODE39 = 8 ; Code 39 Global Const $BARCODE_EXCODE39 = 9 ; Extended Code 39 Global Const $BARCODE_EAN8 = 10 ; EAN-8 (GTIN-8) Global Const $BARCODE_EAN_2ADDON = 11 ; EAN/UPC 2-digit add-on Global Const $BARCODE_EAN_5ADDON = 12 ; EAN/UPC 5-digit add-on Global Const $BARCODE_EANX = 13 ; Legacy Global Const $BARCODE_EANX_CHK = 14 ; Legacy Global Const $BARCODE_EAN13 = 15 ; EAN-13 (GTIN-13) Global Const $BARCODE_GS1_128 = 16 ; GS1-128 Global Const $BARCODE_EAN128 = 16 ; Legacy Global Const $BARCODE_CODABAR = 18 ; Codabar Global Const $BARCODE_CODE128 = 20 ; Code 128 Global Const $BARCODE_DPLEIT = 21 ; Deutsche Post Leitcode Global Const $BARCODE_DPIDENT = 22 ; Deutsche Post Identcode Global Const $BARCODE_CODE16K = 23 ; Code 16k Global Const $BARCODE_CODE49 = 24 ; Code 49 Global Const $BARCODE_CODE93 = 25 ; Code 93 Global Const $BARCODE_FLAT = 28 ; Flattermarken Global Const $BARCODE_DBAR_OMN = 29 ; GS1 DataBar Omnidirectional Global Const $BARCODE_RSS14 = 29 ; Legacy Global Const $BARCODE_DBAR_LTD = 30 ; GS1 DataBar Limited Global Const $BARCODE_RSS_LTD = 30 ; Legacy Global Const $BARCODE_DBAR_EXP = 31 ; GS1 DataBar Expanded Global Const $BARCODE_RSS_EXP = 31 ; Legacy Global Const $BARCODE_TELEPEN = 32 ; Telepen Alpha Global Const $BARCODE_UPCA = 34 ; UPC-A Global Const $BARCODE_UPCA_CHK = 35 ; UPC-A including check digit Global Const $BARCODE_UPCE = 37 ; UPC-E Global Const $BARCODE_UPCE_CHK = 38 ; UPC-E including check digit Global Const $BARCODE_POSTNET = 40 ; USPS POSTNET Global Const $BARCODE_MSI_PLESSEY = 47 ; MSI Plessey Global Const $BARCODE_FIM = 49 ; Facing Identification Mark Global Const $BARCODE_LOGMARS = 50 ; LOGMARS Global Const $BARCODE_PHARMA = 51 ; Pharmacode One-Track Global Const $BARCODE_PZN = 52 ; Pharmazentralnummer Global Const $BARCODE_PHARMA_TWO = 53 ; Pharmacode Two-Track Global Const $BARCODE_CEPNET = 54 ; Brazilian CEPNet Postal Code Global Const $BARCODE_PDF417 = 55 ; PDF417 Global Const $BARCODE_PDF417COMP = 56 ; Compact PDF417 Global Const $BARCODE_PDF417TRUNC = 56 ; Legacy Global Const $BARCODE_MAXICODE = 57 ; MaxiCode Global Const $BARCODE_QRCODE = 58 ; QR Code Global Const $BARCODE_CODE128AB = 60 ; Code 128 (Suppress Code Set C) Global Const $BARCODE_CODE128B = 60 ; Legacy Global Const $BARCODE_AUSPOST = 63 ; Australia Post Standard Customer Global Const $BARCODE_AUSREPLY = 66 ; Australia Post Reply Paid Global Const $BARCODE_AUSROUTE = 67 ; Australia Post Routing Global Const $BARCODE_AUSREDIRECT = 68 ; Australia Post Redirection Global Const $BARCODE_ISBNX = 69 ; ISBN Global Const $BARCODE_RM4SCC = 70 ; Royal Mail 4-State Global Const $BARCODE_DATAMATRIX = 71 ; Data Matrix (ECC200) Global Const $BARCODE_EAN14 = 72 ; EAN-14 Global Const $BARCODE_VIN = 73 ; Vehicle Identification Number Global Const $BARCODE_CODABLOCKF = 74 ; Codablock-F Global Const $BARCODE_NVE18 = 75 ; NVE-18 (SSCC-18) Global Const $BARCODE_JAPANPOST = 76 ; Japanese Postal Code Global Const $BARCODE_KOREAPOST = 77 ; Korea Post Global Const $BARCODE_DBAR_STK = 79 ; GS1 DataBar Stacked Global Const $BARCODE_RSS14STACK = 79 ; Legacy Global Const $BARCODE_DBAR_OMNSTK = 80 ; GS1 DataBar Stacked Omnidirectional Global Const $BARCODE_RSS14STACK_OMNI = 80 ; Legacy Global Const $BARCODE_DBAR_EXPSTK = 81 ; GS1 DataBar Expanded Stacked Global Const $BARCODE_RSS_EXPSTACK = 81 ; Legacy Global Const $BARCODE_PLANET = 82 ; USPS PLANET Global Const $BARCODE_MICROPDF417 = 84 ; MicroPDF417 Global Const $BARCODE_USPS_IMAIL = 85 ; USPS Intelligent Mail Global Const $BARCODE_ONECODE = 85 ; Legacy Global Const $BARCODE_PLESSEY = 86 ; UK Plessey Global Const $BARCODE_TELEPEN_NUM = 87 ; Telepen Numeric Global Const $BARCODE_ITF14 = 89 ; ITF-14 Global Const $BARCODE_KIX = 90 ; Dutch Post KIX Global Const $BARCODE_AZTEC = 92 ; Aztec Global Const $BARCODE_DAFT = 93 ; DAFT Global Const $BARCODE_DPD = 96 ; DPD Global Const $BARCODE_MICROQR = 97 ; Micro QR Global Const $BARCODE_HIBC_128 = 98 ; HIBC Code 128 Global Const $BARCODE_HIBC_39 = 99 ; HIBC Code 39 Global Const $BARCODE_HIBC_DM = 102 ; HIBC Data Matrix Global Const $BARCODE_HIBC_QR = 104 ; HIBC QR Global Const $BARCODE_HIBC_PDF = 106 ; HIBC PDF417 Global Const $BARCODE_HIBC_MICPDF = 108 ; HIBC MicroPDF417 Global Const $BARCODE_HIBC_BLOCKF = 110 ; HIBC Codablock-F Global Const $BARCODE_HIBC_AZTEC = 112 ; HIBC Aztec Global Const $BARCODE_DOTCODE = 115 ; DotCode Global Const $BARCODE_HANXIN = 116 ; Han Xin Global Const $BARCODE_MAILMARK_2D = 119 ; Royal Mail 2D Mailmark Global Const $BARCODE_UPU_S10 = 120 ; UPU S10 Global Const $BARCODE_MAILMARK_4S = 121 ; Royal Mail 4-State Mailmark Global Const $BARCODE_MAILMARK = 121 ; Legacy Global Const $BARCODE_AZRUNE = 128 ; Aztec Runes Global Const $BARCODE_CODE32 = 129 ; Code 32 Global Const $BARCODE_EANX_CC = 130 ; Legacy Global Const $BARCODE_GS1_128_CC = 131 ; GS1-128 Composite Global Const $BARCODE_EAN128_CC = 131 ; Legacy Global Const $BARCODE_DBAR_OMN_CC = 132 ; DataBar Omnidirectional Composite Global Const $BARCODE_RSS14_CC = 132 ; Legacy Global Const $BARCODE_DBAR_LTD_CC = 133 ; DataBar Limited Composite Global Const $BARCODE_RSS_LTD_CC = 133 ; Legacy Global Const $BARCODE_DBAR_EXP_CC = 134 ; DataBar Expanded Composite Global Const $BARCODE_RSS_EXP_CC = 134 ; Legacy Global Const $BARCODE_UPCA_CC = 135 ; UPC-A Composite Global Const $BARCODE_UPCE_CC = 136 ; UPC-E Composite Global Const $BARCODE_DBAR_STK_CC = 137 ; DataBar Stacked Composite Global Const $BARCODE_RSS14STACK_CC = 137 ; Legacy Global Const $BARCODE_DBAR_OMNSTK_CC = 138 ; DataBar Stacked Omnidirectional Composite Global Const $BARCODE_RSS14_OMNI_CC = 138 ; Legacy Global Const $BARCODE_DBAR_EXPSTK_CC = 139 ; DataBar Expanded Stacked Composite Global Const $BARCODE_RSS_EXPSTACK_CC = 139 ; Legacy Global Const $BARCODE_CHANNEL = 140 ; Channel Code Global Const $BARCODE_CODEONE = 141 ; Code One Global Const $BARCODE_GRIDMATRIX = 142 ; Grid Matrix Global Const $BARCODE_UPNQR = 143 ; UPNQR Global Const $BARCODE_ULTRA = 144 ; Ultracode Global Const $BARCODE_RMQR = 145 ; Rectangular Micro QR Global Const $BARCODE_BC412 = 146 ; IBM BC412 Global Const $BARCODE_DXFILMEDGE = 147 ; DX Film Edge Global Const $BARCODE_EAN8_CC = 148 ; EAN-8 Composite Global Const $BARCODE_EAN13_CC = 149 ; EAN-13 Composite Global Const $BARCODE_LAST = 149 ; Max marker ; === Output options === Global Const $BARCODE_BIND_TOP = 0x00001 ; Bind top Global Const $BARCODE_BIND = 0x00002 ; Bind bottom Global Const $BARCODE_BOX = 0x00004 ; Box around symbol Global Const $BARCODE_STDOUT = 0x00008 ; Output to stdout Global Const $READER_INIT = 0x00010 ; Reader Initialisation Global Const $SMALL_TEXT = 0x00020 ; Small human readable text Global Const $BOLD_TEXT = 0x00040 ; Bold human readable text Global Const $CMYK_COLOUR = 0x00080 ; Use CMYK in EPS Global Const $BARCODE_DOTTY_MODE = 0x00100 ; Dotty mode Global Const $GS1_GS_SEPARATOR = 0x00200 ; Use GS as separator Global Const $OUT_BUFFER_INTERMEDIATE = 0x00400 ; Return intermediate data Global Const $BARCODE_QUIET_ZONES = 0x00800 ; Force quiet zones Global Const $BARCODE_NO_QUIET_ZONES = 0x01000 ; Suppress quiet zones Global Const $COMPLIANT_HEIGHT = 0x02000 ; Compliant height Global Const $EANUPC_GUARD_WHITESPACE = 0x04000 ; Guard whitespace Global Const $EMBED_VECTOR_FONT = 0x08000 ; Embed vector font Global Const $BARCODE_MEMORY_FILE = 0x10000 ; Output to memory Global Const $BARCODE_RAW_TEXT = 0x20000 ; Output raw text ; === Input modes === Global Const $DATA_MODE = 0 ; Binary input Global Const $UNICODE_MODE = 1 ; Unicode input Global Const $GS1_MODE = 2 ; GS1 input Global Const $ESCAPE_MODE = 0x0008 ; Escape sequences Global Const $GS1PARENS_MODE = 0x0010 ; GS1 parentheses Global Const $GS1NOCHECK_MODE = 0x0020 ; Skip GS1 checks Global Const $HEIGHTPERROW_MODE = 0x0040 ; Height per row Global Const $FAST_MODE = 0x0080 ; Fast mode Global Const $EXTRA_ESCAPE_MODE = 0x0100 ; Extra escape Global Const $GS1SYNTAXENGINE_MODE = 0x0200 ; GS1 syntax engine ; === Data Matrix options === Global Const $DM_SQUARE = 100 ; Square only Global Const $DM_DMRE = 101 ; DMRE only Global Const $DM_ISO_144 = 128 ; ISO 144 compliance ; === QR/Han Xin/Grid Matrix options === Global Const $ZINT_FULL_MULTIBYTE = 200 ; Full multibyte ; === Ultracode options === Global Const $ULTRA_COMPRESSION = 128 ; Compression mode ; === Warnings & Errors === Global Const $ZINT_WARN_HRT_TRUNCATED = 1 ; HRT truncated Global Const $ZINT_WARN_INVALID_OPTION = 2 ; Invalid option Global Const $ZINT_WARN_USES_ECI = 3 ; Uses ECI Global Const $ZINT_WARN_NONCOMPLIANT = 4 ; Noncompliant symbol Global Const $ZINT_ERROR = 5 ; General error Global Const $ZINT_ERROR_TOO_LONG = 5 ; Data too long Global Const $ZINT_ERROR_INVALID_DATA = 6 ; Invalid data Global Const $ZINT_ERROR_INVALID_CHECK = 7 ; Invalid check digit Global Const $ZINT_ERROR_INVALID_OPTION = 8 ; Invalid option Global Const $ZINT_ERROR_ENCODING_PROBLEM = 9 ; Encoding problem Global Const $ZINT_ERROR_FILE_ACCESS = 10 ; File access error Global Const $ZINT_ERROR_MEMORY = 11 ; Memory error Global Const $ZINT_ERROR_FILE_WRITE = 12 ; File write error Global Const $ZINT_ERROR_USES_ECI = 13 ; Uses ECI Global Const $ZINT_ERROR_NONCOMPLIANT = 14 ; Noncompliant Global Const $ZINT_ERROR_HRT_TRUNCATED = 15 ; HRT truncated ; === Warning levels === Global Const $WARN_DEFAULT = 0 ; Default warnings Global Const $WARN_FAIL_ALL = 2 ; Treat all warnings as errors ; === Capabilities === Global Const $ZINT_CAP_HRT = 0x0001 ; Has HRT Global Const $ZINT_CAP_STACKABLE = 0x0002 ; Stackable Global Const $ZINT_CAP_EANUPC = 0x0004 ; EAN/UPC Global Const $ZINT_CAP_EXTENDABLE = 0x0004 ; Extendable (legacy) Global Const $ZINT_CAP_COMPOSITE = 0x0008 ; Composite Global Const $ZINT_CAP_ECI = 0x0010 ; ECI capable Global Const $ZINT_CAP_GS1 = 0x0020 ; GS1 capable Global Const $ZINT_CAP_DOTTY = 0x0040 ; Dotty capable Global Const $ZINT_CAP_QUIET_ZONES = 0x0080 ; Quiet zones Global Const $ZINT_CAP_FIXED_RATIO = 0x0100 ; Fixed ratio Global Const $ZINT_CAP_READER_INIT = 0x0200 ; Reader Init Global Const $ZINT_CAP_FULL_MULTIBYTE = 0x0400 ; Full multibyte Global Const $ZINT_CAP_MASK = 0x0800 ; Masking Global Const $ZINT_CAP_STRUCTAPP = 0x1000 ; Structured Append Global Const $ZINT_CAP_COMPLIANT_HEIGHT = 0x2000 ; Compliant height Global Const $ZINT_CAP_BINDABLE = 0x4000 ; Bindable ; === Limits === Global Const $ZINT_MAX_DATA_LEN = 17400 ; Max data length Global Const $ZINT_MAX_SEG_COUNT = 256 ; Max segment count #EndRegion #Region Structs ; Vector elements Global Const $tag_zint_vector_rect = "struct;" & _ "float x;" & _ ; Top left "float y;" & _ "float height;" & _ "float width;" & _ "long colour;" & _ ; -1 foreground, 1-8 = Cyan, Blue, Magenta, Red, Yellow, Green, Black, White "ptr next;" & _ ; Pointer to next rectangle "endstruct" Global Const $tag_zint_vector_hexagon = "struct;" & _ "float x;" & _ ; Centre x "float y;" & _ ; Centre y "float diameter;" & _ ; Short diameter (inscribed circle) "long rotation;" & _ ; 0, 90, 180, 270 (0 = apex at top) "ptr next;" & _ ; Pointer to next hexagon "endstruct" Global Const $tag_zint_vector_string = "struct;" & _ "float x;" & _ ; Relative to halign "float y;" & _ ; Relative to baseline "float fsize;" & _ ; Font size "float width;" & _ ; Rendered width estimate "long length;" & _ ; Number of characters (bytes) "long rotation;" & _ ; 0, 90, 180, 270 "long halign;" & _ ; 0 = centre, 1 = left, 2 = right "ptr text;" & _ ; UTF-8, NUL-terminated "ptr next;" & _ ; Pointer to next string "endstruct" Global Const $tag_zint_vector_circle = "struct;" & _ "float x;" & _ ; Centre x "float y;" & _ ; Centre y "float diameter;" & _ ; Circle diameter (excludes width) "float width;" & _ ; Perimeter width, 0 = fill "long colour;" & _ ; 0 = foreground colour, else background "ptr next;" & _ ; Pointer to next circle "endstruct" Global Const $tag_zint_vector = "struct;" & _ "float width;" & _ ; Overall barcode width "float height;" & _ ; Overall barcode height "ptr rectangles;" & _ ; Pointer to first rectangle "ptr hexagons;" & _ ; Pointer to first hexagon "ptr strings;" & _ ; Pointer to first string "ptr circles;" & _ ; Pointer to first circle "endstruct" ; Structured Append info Global Const $tag_zint_structapp = "long index;" & _ ; Position in sequence (1-based) "long count;" & _ ; Number of symbols in sequence "char id[32];" ; Optional ID, ASCII, NUL-terminated ; Segment info Global Const $tag_zint_seg = "struct;" & _ "ptr source;" & _ ; Data pointer "long length;" & _ ; Data length (0 = NUL-terminated) "long eci;" & _ ; Extended Channel Interpretation "endstruct" ; Main symbol structure Global Const $tag_zint_symbol = "struct;" & _ "long symbology;" & _ ; Symbol type "float height;" & _ ; Barcode height "float scale;" & _ ; Scale factor "long whitespace_width;" & _ ; Horizontal whitespace "long whitespace_height;" & _ ; Vertical whitespace "long border_width;" & _ ; Border width "long output_options;" & _ ; Output options "char fgcolour[16];" & _ ; Foreground colour string "char bgcolour[16];" & _ ; Background colour string "ptr fgcolor;" & _ ; Pointer to fgcolour "ptr bgcolor;" & _ ; Pointer to bgcolour "char outfile[256];" & _ ; Output filename "char primary[128];" & _ ; Primary message data "long option_1;" & _ ; Symbol-specific option "long option_2;" & _ "long option_3;" & _ "long show_hrt;" & _ ; Show (1) / hide (0) human readable text "long input_mode;" & _ ; Input encoding "long eci;" & _ ; Extended Channel Interpretation "float dpmm;" & _ ; Resolution in dots/mm "float dot_size;" & _ ; Dot size (dotty mode) "float text_gap;" & _ ; Gap between barcode and text "float guard_descent;" & _ ; EAN/UPC guard bar descent $tag_zint_structapp & _ ; Structured append info "long warn_level;" & _ ; Warning behaviour "long debug;" & _ ; Debug flags "byte text[256];" & _ ; Human-readable text (output) "long text_length;" & _ ; Length of text (output) "long rows;" & _ ; Number of rows (output) "long width;" & _ ; Symbol width (output) "byte encoded_data[28800];" & _ ; Encoded data (flattened 200x144) "float row_height[200];" & _ ; Row heights "char errtxt[160];" & _ ; Error text (output) "ptr bitmap;" & _ ; Bitmap pointer (output) "long bitmap_width;" & _ ; Bitmap width "long bitmap_height;" & _ ; Bitmap height "ptr alphamap;" & _ ; Alpha channel pointer "ptr vector;" & _ ; Vector header pointer "ptr memfile;" & _ ; In-memory file buffer "long memfile_size;" & _ ; Buffer length "ptr raw_segs;" & _ ; Raw segments pointer "long raw_seg_count;" & _ ; Number of raw segs "endstruct" #EndRegion #Region Functions ; Create and initialize a symbol structure Func ZBarcode_Create() If Not FileExists($g__ZintDLL) Then If @AutoItX64 Then _zint64dll(True) Else _zintdll(True) EndIf EndIf Local $hPtr = DllCall($g__ZintDLL, "ptr:cdecl", "ZBarcode_Create")[0] If $hPtr = 0 Then Return SetError(2, 0, 0) Return $hPtr EndFunc ; Free any output buffers that may have been created and initialize output fields Func ZBarcode_Clear($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Clear", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; Free any output buffers that may have been created and reset all fields to defaults Func ZBarcode_Reset($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Reset", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; Free a symbol structure, including any output buffers Func ZBarcode_Delete($pSymbol) If IsPtr($pSymbol) And $pSymbol <> 0 Then DllCall($g__ZintDLL, "none:cdecl", "ZBarcode_Delete", "ptr", $pSymbol) Return 1 EndIf Return SetError(1, 0, 0) EndFunc ; =================================================================== ; Encoding ; =================================================================== ; Encode a barcode. If length is 0 or negative, source must be NUL-terminated Func ZBarcode_Encode($pSymbol, $sInput) Local $iLength = StringLen($sInput) Local $tInput = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tInput.text = $sInput Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength + 1)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode a barcode with multiple ECI segments Func ZBarcode_Encode_Segs($pSymbol, $pSegs, $iSegCount) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode a barcode using input data from file Func ZBarcode_Encode_File($pSymbol, $sFilename) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File", "ptr", $pSymbol, "str", $sFilename)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; =================================================================== ; Output to file ; =================================================================== ; Output a previously encoded symbol to file Func ZBarcode_Print($pSymbol, $iAngle = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Print", "ptr", $pSymbol, "long", $iAngle)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode and output a symbol to file Func ZBarcode_Encode_and_Print($pSymbol, $sInput, $iRotate = 0) Local $iLength = StringLen($sInput) Local $tInput = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tInput.text = $sInput Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Print", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength + 1, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode a symbol with multiple ECI segments and output to file Func ZBarcode_Encode_Segs_and_Print($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Print", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; Encode a symbol using input data from file and output to file Func ZBarcode_Encode_File_and_Print($pSymbol, $sFilename, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Print", "ptr", $pSymbol, "str", $sFilename, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; =================================================================== ; Output to memory (raster/vector) ; =================================================================== Func ZBarcode_Buffer($pSymbol, $iAngle = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Buffer", "ptr", $pSymbol, "long", $iAngle)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_and_Buffer($pSymbol, $sInput, $iRotate = 0) Local $iLength = StringLen($sInput) Local $tInput = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tInput.text = $sInput Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Buffer", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength + 1, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_Segs_and_Buffer($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Buffer", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_File_and_Buffer($pSymbol, $sFilename, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Buffer", "ptr", $pSymbol, "str", $sFilename, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Buffer_Vector($pSymbol, $iAngle = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Buffer_Vector", "ptr", $pSymbol, "long", $iAngle)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_and_Buffer_Vector($pSymbol, $sInput, $iRotate = 0) Local $iLength = StringLen($sInput) Local $tInput = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tInput.text = $sInput Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_and_Buffer_Vector", "ptr", $pSymbol, "struct*", $tInput, "long", $iLength + 1, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_Segs_and_Buffer_Vector($pSymbol, $pSegs, $iSegCount, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_Segs_and_Buffer_Vector", "ptr", $pSymbol, "ptr", $pSegs, "long", $iSegCount, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc Func ZBarcode_Encode_File_and_Buffer_Vector($pSymbol, $sFilename, $iRotate = 0) Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Encode_File_and_Buffer_Vector", "ptr", $pSymbol, "str", $sFilename, "long", $iRotate)[0] If $iResult Then Return SetError($iResult, 0, 0) Return 1 EndFunc ; =================================================================== ; Info & Validation ; =================================================================== ; Is symbol_id a recognized symbology? Func ZBarcode_ValidID($iSymbolID) Return DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_ValidID", "long", $iSymbolID)[0] EndFunc ; Copy BARCODE_XXX name of symbol_id into name buffer Func ZBarcode_BarcodeName($iSymbolID) Local $tName = DllStructCreate("char[32]") Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_BarcodeName", "long", $iSymbolID, "struct*", $tName)[0] If $iResult Then Return SetError($iResult, 0, "") Return DllStructGetData($tName, 1) EndFunc ; Return the capability flags for symbology symbol_id that match cap_flag Func ZBarcode_Cap($iSymbolID, $iCapFlag) Return DllCall($g__ZintDLL, "uint:cdecl", "ZBarcode_Cap", "long", $iSymbolID, "uint", $iCapFlag)[0] EndFunc ; =================================================================== ; X-dimension & Scaling ; =================================================================== Func ZBarcode_Default_Xdim($iSymbolID) Return DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_Default_Xdim", "long", $iSymbolID)[0] EndFunc Func ZBarcode_Scale_From_XdimDp($iSymbolID, $fXDimMM, $fDpmm, $sFiletype = "") Return DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_Scale_From_XdimDp", _ "long", $iSymbolID, "float", $fXDimMM, "float", $fDpmm, "str", $sFiletype)[0] EndFunc Func ZBarcode_XdimDp_From_Scale($iSymbolID, $fScale, $fXDimOrDpmm, $sFiletype = "") Return DllCall($g__ZintDLL, "float:cdecl", "ZBarcode_XdimDp_From_Scale", _ "long", $iSymbolID, "float", $fScale, "float", $fXDimOrDpmm, "str", $sFiletype)[0] EndFunc ; =================================================================== ; UTF-8 & ECI helpers ; =================================================================== Func ZBarcode_UTF8_To_ECI($iEci, $sSource, ByRef $sDest) Local $iLength = StringLen($sSource) Local $tSrc = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tSrc.text = $sSource Local $tDest = DllStructCreate("ubyte[1024]") ; allocate buffer Local $pDestLen = DllStructCreate("int") Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_UTF8_To_ECI", "long", $iEci, "struct*", $tSrc, "long", $iLength + 1, "struct*", $tDest, "struct*", $pDestLen)[0] If $iResult Then Return SetError($iResult, 0, "") $sDest = BinaryToString(DllStructGetData($tDest, 1)) Return 1 EndFunc Func ZBarcode_Dest_Len_ECI($iEci, $sSource) Local $iLength = StringLen($sSource) Local $tSrc = DllStructCreate("struct;ubyte text[" & $iLength + 1 & "];endstruct") $tSrc.text = $sSource Local $pDestLen = DllStructCreate("int") Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Dest_Len_ECI", "long", $iEci, "struct*", $tSrc, "long", $iLength + 1, "struct*", $pDestLen)[0] If $iResult Then Return SetError($iResult, 0, 0) Return DllStructGetData($pDestLen, 1) EndFunc ; =================================================================== ; Build info ; =================================================================== Func ZBarcode_NoPng() Return DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_NoPng")[0] EndFunc Func ZBarcode_HaveGS1SyntaxEngine() Return DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_HaveGS1SyntaxEngine")[0] EndFunc ; Return the version of Zint linked to Func ZBarcode_Version() Local $iResult = DllCall($g__ZintDLL, "long:cdecl", "ZBarcode_Version")[0] Local $a = StringRegExp((Mod(StringLen($iResult), 2) ? "0" : "") & $iResult, ".{2}", 3) If Not IsArray($a) Then Return SetError(1, 0, 0) Return StringFormat("%01i.%02i.%02i", $a[0], $a[1], $a[2]) EndFunc #EndRegion Example1.au3 #AutoIt3Wrapper_UseX64=y #include <GDIPlus.au3> #include "Zint.au3" Global Const $sTestFile = "out.png" ;default output name If FileExists($sTestFile) Then FileDelete($sTestFile) Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) ConsoleWrite("Zint DLL version: " & ZBarcode_Version() & @CRLF) ConsoleWrite("PNG support: " & (ZBarcode_NoPng() ? "No" : "Yes") & @CRLF) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB) If @error Then MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) ZBarcode_Delete($pZB) Exit EndIf With $t_zint_symbol .symbology = $BARCODE_CODE128 .scale = 1 .option_1 = -1 .show_hrt = 1 .output_options = $SMALL_TEXT .outfile = $sTestFile EndWith ZBarcode_Encode_and_Print($pZB, "12340984576") Global $iError = @error ZBarcode_Delete($pZB) If FileExists($sTestFile) Then ShellExecute($sTestFile) Else MsgBox(16, "Error", "Code was not create. Error: " & $iError, 5) EndIf Example2.au3 #AutoIt3Wrapper_UseX64=n #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include "Zint.au3" Global Const $sTestFile = @ScriptDir & "\Barcode.png" Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB) $t_zint_symbol.symbology = $BARCODE_QRCODE $t_zint_symbol.scale = 10 ZBarcode_Encode_and_Buffer($pZB, "Hello QR World ;-)") _GDIPlus_Startup() Global $stride = BitAND(($t_zint_symbol.bitmap_width * 3) + 3, BitNOT(3)) Global $iMemSize = $stride * $t_zint_symbol.bitmap_height Global $tPixel = DllStructCreate("ubyte rgb[" & $iMemSize & "];") Global $hBitmap = _GDIPlus_BitmapCreateFromScan0($t_zint_symbol.bitmap_width, $t_zint_symbol.bitmap_height, $GDIP_PXF24RGB, $stride, $tPixel) DllCall("msvcrt.dll", "ptr:cdecl", "memcpy", "struct*", $tPixel, "ptr", $t_zint_symbol.bitmap, "uint", $iMemSize) Global Const $hGUI = GUICreate("Test QR Code", $t_zint_symbol.bitmap_width, $t_zint_symbol.bitmap_height) GUISetState(@SW_SHOW) Global Const $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap, 0, 0, $t_zint_symbol.bitmap_width, $t_zint_symbol.bitmap_height) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() ZBarcode_Delete($pZB) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Example3.au3 #AutoIt3Wrapper_UseX64=n #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include "Zint.au3" Global $pZB = ZBarcode_Create() If @error Then Exit MsgBox(16, "ERROR", "An error occured!" & @CRLF & "Error code = " & @error, 10) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pZB), $sText = "12340984576 ;-)" With $t_zint_symbol .symbology = $BARCODE_CODE128 .scale = 1 EndWith If Not ZBarcode_Encode_and_Buffer_Vector($pZB, $sText) Then Exit MsgBox(16, "ERROR", "Unable to encode!" & @CRLF & "Error code = " & @error, 10) Global $tVector = DllStructCreate($tag_zint_vector, $t_zint_symbol.vector) Global $tVector_Rect = DllStructCreate($tag_zint_vector_rect, $tVector.rectangles) ConsoleWrite($tVector.width & " x " & $tVector.height & @CRLF) _GDIPlus_Startup() Global $hBitmap = _GDIPlus_BitmapCreateFromScan0($tVector.width, $tVector.height, $GDIP_PXF24RGB), $hCanvas = _GDIPlus_ImageGetGraphicsContext($hBitmap), $hBrush = _GDIPlus_BrushCreateSolid() _GDIPlus_GraphicsClear($hCanvas, 0xFFFFFFFF) While $tVector_Rect.next _GDIPlus_BrushSetSolidColor($hBrush, BitAND($tVector_Rect.colour, 0xFF000000)) _GDIPlus_GraphicsFillRect($hCanvas, $tVector_Rect.x, $tVector_Rect.y, $tVector_Rect.width, $tVector_Rect.height, $hBrush) $tVector_Rect = DllStructCreate($tag_zint_vector_rect, $tVector_Rect.next) WEnd Global $tVector_String = DllStructCreate($tag_zint_vector_string, $tVector.strings) _GDIPlus_GraphicsDrawString($hCanvas, $sText, ($tVector_String.width - $tVector_String.length * $tVector_String.fsize * 0.55) / 2, $tVector.height - $tVector_String.fsize * 1.33333, "Arial", $tVector_String.fsize * 0.75, Default, 0xFF000000) Global Const $hGUI = GUICreate("Test Bar Code 128", $tVector.width, $tVector.height) GUISetState(@SW_SHOW) Global Const $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap, 0, 0, $tVector.width, $tVector.height) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_BrushDispose($hBrush) _GDIPlus_Shutdown() ZBarcode_Delete($pZB) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Example4.au3 #AutoIt3Wrapper_UseX64=y #include "Zint.au3" ; =================================================================== ; Zint AutoIt Demo Test ; =================================================================== ; ------------------------------------------------------------------- ; Step 1: Create a symbol ; ------------------------------------------------------------------- ConsoleWrite("Step 1: Create a symbol" & @CRLF) Global $pSymbol = ZBarcode_Create() If @error Then MsgBox(16, "Error", "Failed to create symbol") Exit EndIf ConsoleWrite("Symbol created: " & $pSymbol & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 2: Encode a simple string ; ------------------------------------------------------------------- ConsoleWrite("Step 2: Encode a simple string" & @CRLF) Global $sData = "HELLO123" If ZBarcode_Encode($pSymbol, $sData) Then ConsoleWrite("Encoding succeeded" & @CRLF) Else ConsoleWrite("Encoding failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 3: Output to raster buffer ; ------------------------------------------------------------------- ConsoleWrite("Step 3: Output to raster buffer" & @CRLF) If ZBarcode_Buffer($pSymbol) Then ConsoleWrite("Raster buffer generated successfully" & @CRLF) Else ConsoleWrite("Raster buffer generation failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 4: Output to vector buffer ; ------------------------------------------------------------------- ConsoleWrite("Step 4: Output to vector buffer" & @CRLF) If ZBarcode_Buffer_Vector($pSymbol) Then ConsoleWrite("Vector buffer generated successfully" & @CRLF) Else ConsoleWrite("Vector buffer generation failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 5: Print to file (just test call, file may not exist) ; ------------------------------------------------------------------- ConsoleWrite("Step 5: Print to file" & @CRLF) Global $t_zint_symbol = DllStructCreate($tag_zint_symbol, $pSymbol) $t_zint_symbol.symbology = $BARCODE_CODE128 $t_zint_symbol.input_mode = $DATA_MODE $t_zint_symbol.height = 50 $t_zint_symbol.scale = 1 $t_zint_symbol.option_1 = 0 $t_zint_symbol.option_2 = 0 $t_zint_symbol.option_3 = 0 $t_zint_symbol.show_hrt = 1 If ZBarcode_Print(DllStructGetPtr($t_zint_symbol)) Then ConsoleWrite("Print function call succeeded" & @CRLF) Else ConsoleWrite("Print failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 6: Get barcode info ; ------------------------------------------------------------------- ConsoleWrite("Step 6: Get barcode info" & @CRLF) ConsoleWrite("Valid ID for CODE128: " & ZBarcode_ValidID(20) & @CRLF) ConsoleWrite("Barcode name for CODE128: " & ZBarcode_BarcodeName(20) & @CRLF) ConsoleWrite("Default X-dim for CODE128: " & ZBarcode_Default_Xdim(20) & " mm" & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 7: UTF-8 to ECI conversion test ; ------------------------------------------------------------------- ConsoleWrite("Step 7: UTF-8 to ECI conversion test" & @CRLF) Global $sDest If ZBarcode_UTF8_To_ECI(3, "HELLO", $sDest) Then ConsoleWrite("UTF-8 to ECI conversion succeeded: " & $sDest & @CRLF) Else ConsoleWrite("UTF-8 to ECI conversion failed, error: " & @error & @CRLF) EndIf ConsoleWrite(@CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 8: Check Zint build info ; ------------------------------------------------------------------- ConsoleWrite("Step 8: Check Zint build info" & @CRLF) ConsoleWrite("Zint No PNG support: " & ZBarcode_NoPng() & @CRLF) ConsoleWrite("Zint GS1 support: " & ZBarcode_HaveGS1SyntaxEngine() & @CRLF) ConsoleWrite("Zint Version: " & ZBarcode_Version() & @CRLF) ConsoleWrite(@CRLF) ; ------------------------------------------------------------------- ; Step 9: Clear, reset and delete symbol ; ------------------------------------------------------------------- ConsoleWrite("Step 9: Clear, reset and delete symbol" & @CRLF) ZBarcode_Clear($pSymbol) ConsoleWrite("Symbol cleared" & @CRLF) ZBarcode_Reset($pSymbol) ConsoleWrite("Symbol reset" & @CRLF) ZBarcode_Delete($pSymbol) ConsoleWrite("Symbol deleted" & @CRLF) ConsoleWrite(@CRLF) MsgBox(64, "Demo Complete", "Zint AutoIt demo test finished successfully.") Please test and reply. Feel free to post examples here!1 point
-
Disable combobox selection frame
WildByDesign reacted to mutleey for a topic
thanks WildByDesign, it worked perfectly!1 point -
No problems And yep, _ArrayDisplay() works the same way as ioa's example 👍1 point
-
WebDriver UDF (W3C compliant version) - 2025/09/01
Danp2 reacted to SOLVE-SMART for a topic
Hi @MWIProd 👋 . Please set $_WD_DEBUG = $_WD_DEBUG_Full Run your browser automation Share the console output and *.log file with us Then we will have a better understanding of your capabilities setup and it's more likely that we can help you. Examples for using the _WD_CapabilitiesAdd() can be found here (autoit-webdriver-boilerplate) or here (au3WebDriver). Best regards Sven1 point -
Check powercfg /requests. Things that don't require user input, but prevent the computer from sleeping are listed there.1 point
-
I am working to fix the double_ws1 point
-
myLogin - 🛡️ Secure lock screen Windows 🖥️
argumentum reacted to mlibre2 for a topic
If I tell you a curious fact... since I started testing the script on builds >= 22000 "windows 11", I get this problem: "unable to add resources", so I decided to remove that directive and insert the icon using the /icon parameter directly when compiling, but I made a typo in the workflow and the icon was not included. It should be corrected for future versions.1 point -
myLogin - 🛡️ Secure lock screen Windows 🖥️
mlibre2 reacted to argumentum for a topic
#pragma compile(Icon, C:\Program Files\AutoIt3\Icons\au3.ico) the portable exe does not show an icon1 point -
myLogin - 🛡️ Secure lock screen Windows 🖥️
argumentum reacted to mlibre2 for a topic
New release available v3.71 point -
Perfect my dear ioa747, Many thanks to you Accept my respect & my best wishes to you Such a great code from UEZ & ioa7471 point
-
Update to Version: 0.8 in the first post $iBgTrans - [optional] The transparency of background, a number in the range 0 - 255. (Default is 0)1 point
-
ProcessExists ,ProcessClose, FileReadToArray high CPU consumption
argumentum reacted to angel83 for a topic
Thanks for your argumentum, but it's a bit complex for me. The code I posted is small and simple. Thanks in advance.1 point -
_WinAPI_DwmEnableBlurBehindWindow in Windows 11
argumentum reacted to WildByDesign for a topic
I just updated the _WinAPI_DwmEnableBlurBehindWindow11 function. I was able to make it so that it behaves just like the original AutoIt _WinAPI_DwmEnableBlurBehindWindow function used to behave prior to Windows 10 which is to extend the blur to the titlebar of the window. I made it default since that is how the original function used to behave before it broke on Windows 10. Titlebar blur can be disabled. I also opened up the entire SetWindowCompositionAttribute API so that you can experiment with any part of it. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_DwmEnableBlurBehindWindow11 ; Description ...: Enables Aero-like blurred background in Windows 11. ; Syntax ........: _WinAPI_DwmEnableBlurBehindWindow11($hWnd[, $AccentState, $BlendColor, $ColorOpacity, $AccentFlags, $AnimationId]) ; Parameters ....: $hWnd - Window handle ; $AccentState - [optional] Enable or disable the blur effect ; $IncludeCaption - [optional] Extend effects to the titlebar ; $BlendColor - [optional] Sets GradientColor ; $ColorOpacity - [optional] Sets blending color opacity value ; $AccentFlags - [optional] Sets AccentFlags value ; $AnimationId - [optional] Sets AnimationId value ; Return values .: 1 on success, 0 otherwise. Call _WinAPI_GetLastError on failure for more information. ; Author ........: scintilla4evr ; Modified ......: WildByDesign - added $AccentState, $BlendColor, $ColorOpacity, $AccentFlags and $AnimationId ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ; ACCENT_DISABLED = 0 ; ACCENT_ENABLE_GRADIENT = 1 ; ACCENT_ENABLE_TRANSPARENTGRADIENT = 2 ; ACCENT_ENABLE_BLURBEHIND = 3 ; ACCENT_ENABLE_ACRYLICBLURBEHIND = 4 ; ACCENT_ENABLE_HOSTBACKDROP = 5 ; ACCENT_INVALID_STATE = 6 ; =============================================================================================================================== Func _WinAPI_DwmEnableBlurBehindWindow11($hWnd, $AccentState = $ACCENT_ENABLE_ACRYLICBLURBEHIND, $IncludeCaption = True, $BlendColor = "", $ColorOpacity = "", $AccentFlags = 0, $AnimationId = 0) If $AccentState And $IncludeCaption Then _WinAPI_DwmEnableBlurBehindWindow($hWnd, 1) If Not $AccentState Then _WinAPI_DwmEnableBlurBehindWindow($hWnd, 0) Local $tAccentPolicy = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId") Local $tAttrData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size") $tAccentPolicy.AccentState = $AccentState If $AccentState = $ACCENT_ENABLE_TRANSPARENTGRADIENT And $AccentFlags = 0 Then $AccentFlags = 2 $tAccentPolicy.AccentFlags = $AccentFlags Local $iVal = Int($ColorOpacity > 99 ? 100 : ($ColorOpacity < 1 ? 0 : $ColorOpacity)) ; no more than 100% or less than 0% Local $sTransparencyHex = Hex(Ceiling(($iVal * 100) * (2.55 * 100) / (100 * 100)), 2) $tAccentPolicy.GradientColor = '0x' & $sTransparencyHex & Hex(_WinAPI_SwitchColor($BlendColor), 6) $tAccentPolicy.AnimationId = $AnimationId $tAttrData.Attribute = $WCA_ACCENT_POLICY $tAttrData.DataBuffer = DllStructGetPtr($tAccentPolicy) $tAttrData.Size = DllStructGetSize($tAccentPolicy) Local $aResult = DllCall($hUser32, "bool", "SetWindowCompositionAttribute", "hwnd", $hWnd, "ptr", DllStructGetPtr($tAttrData)) If $AccentState And $IncludeCaption Then _WinAPI_DwmExtendFrameIntoClientArea($hWnd, _WinAPI_CreateMargins(-1, -1, -1, -1)) If Not $AccentState Then _WinAPI_DwmExtendFrameIntoClientArea($hWnd, _WinAPI_CreateMargins(0, 0, 0, 0)) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_DwmEnableBlurBehindWindow111 point -
EndIf "overhead"
Numeric1 reacted to WildByDesign for a topic
Thank you for your response. I appreciate that you've taken time to share some insight and suggestions as well. I personally have never used Ternary before. I'm still quite new to AutoIt and have a lot to learn. So to be perfectly honest, I don't really have a good understanding of how or when to use Ternary over the other options. This thread (and possibly another thread or two) was really about trying to get the most performance out of, or better efficiency, of the _WinEventProc (SetWinEventHook) function of my Immersive UX project. Since all running processes on the system filter through it, finding various ways to make it more efficient has been incredibly helpful. With the help of this community, it has been really beneficial. If you are curious if Ternary can fit in anywhere and if you have a few minutes, you can have a peak at the hook function (https://github.com/WildByDesign/ImmersiveUX/blob/main/ImmersiveEngine.au3#L587). It's got a lot of things that help make it more efficient, but I am always open to more. And most importantly, I am always interested in learning more.1 point -
EndIf "overhead"
WildByDesign reacted to Numeric1 for a topic
Hi everyone, Thanks for this super interesting thread! I really appreciate the educational aspect of this topic and the way you've shared your insights. Your in-depth investigations into performance are inspiring, and it's impressive to see how much you've dug into the subject as a team! 😊 Just a small remark: while reading your discussions on optimization, I was surprised not to see any mention of the ternary operator. It seems to me that in some cases, it could be an elegant and concise alternative to simplify If...EndIf statements, while also offering a slight performance boost. Have you explored this approach collectively, or perhaps it wasn't applicable to this specific case?1 point -
myLogin - 🛡️ Secure lock screen Windows 🖥️
argumentum reacted to mlibre2 for a topic
This method would be a deterrent alternative for those who know and are aware of the vulnerability of being able to bypass the user's password, with the typical command net users nameUser * This script adds an additional layer of security1 point -
_WinAPI_DwmEnableBlurBehindWindow in Windows 11
WildByDesign reacted to mlibre2 for a topic
I'm testing the function, and it always returns "true," even if the effect is disabled. Perhaps add this filter to the function to check for compatibility... ; Windows 11 If @OSBuild >= 22000 Then $regKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" $regValue = "EnableTransparency" If RegRead($regKey, $regValue) <> 1 Then WinSetTrans($hGUI, "", $g_iTransparencyGUI) Return False EndIf EndIf1 point -
EndIf "overhead"
WildByDesign reacted to rcmaehl for a topic
I'm sure there's some CPU Branch Predictor Optimizations that can be done. However, as you've seen in your Process Name from Handle thread, there's a LOT more performance that can be gained by reusing resources, cutting out unneeded code, and other optimizations. Also, don't be afraid to do things out of order. You may be surprised what still works $iSIHost = ProcessExists("sihost.exe") While True $aProcessList = _WinAPI_EnumChildProcess($iSIHost) If @error Then ContinueLoop ProcessClose($aProcessList[1][0]) $sCommandline = _WinAPI_GetProcessCommandLine($aProcessList[1][0]) $sProcessPath = _WinAPI_GetProcessFileName($aProcessList[1][0]) WEnd And you can always fix a mistake if you're overzealous $iSIHost = ProcessExists("sihost.exe") While True $aProcessList = _WinAPI_EnumChildProcess($iSIHost) If @error Then ContinueLoop ProcessClose($aProcessList[1][0]) $sCommandline = _WinAPI_GetProcessCommandLine($aProcessList[1][0]) $sProcessPath = _WinAPI_GetProcessFileName($aProcessList[1][0]) If Not $aProcessList[1][1] = "msedge.exe" Then ShellExecute($sProcessPath, $sCommandLine) WEnd1 point -
EndIf "overhead"
WildByDesign reacted to rcmaehl for a topic
Big Agree I mean, it definitely helps if you're fighting a race condition but it's not a good idea to get yourself in one in the first place. 👀1 point -
EndIf "overhead"
mlibre2 reacted to argumentum for a topic
Global $iTimer, $iVariable = 1 For $tryNo = 1 To 3 Sleep(1000) $iTimer1 = TimerInit() For $A = 1 To 10000 If $iVariable Then $iVariable = 1 Next $iTimer1 = Round(TimerDiff($iTimer1), 1) ConsoleWrite("10,000 runs (single line If statement): " & @TAB & $iTimer1 & "ms" & @CRLF) $iTimer2 = TimerInit() For $A = 1 To 10000 If $iVariable Then $iVariable = 1 EndIf Next $iTimer2 = Round(TimerDiff($iTimer2), 1) ConsoleWrite("10,000 runs (If statement with EndIf): " & @TAB & @TAB & $iTimer2 & "ms" & @CRLF) $iDifference = Round(($iTimer1 - $iTimer2) / $iTimer2, 2) ConsoleWrite("Percentage Difference: " & @TAB & @TAB & @TAB & @TAB & @TAB & @TAB & $iDifference * 100 & "%" & @CRLF & @CRLF) Next Exit 10,000 runs (single line If statement): 40.5ms 10,000 runs (If statement with EndIf): 3.1ms Percentage Difference: 1206% 10,000 runs (single line If statement): 5.7ms 10,000 runs (If statement with EndIf): 3ms Percentage Difference: 90% 10,000 runs (single line If statement): 5.8ms 10,000 runs (If statement with EndIf): 3ms Percentage Difference: 93% I'll write what makes the code more readable. Anyone having to depend on this, needs to rethink their code. My 2 cents1 point -
myLogin - 🛡️ Secure lock screen Windows 🖥️
mlibre2 reacted to WildByDesign for a topic
I got a chance to test myLogin (3.6) on Windows 11 and I just wanted to confirm that your existing blur method worked perfectly. I did not end up having to add anything to your code.1 point -
with _Timer_SetTimer() that will check every e.g.: 1000ms , if the application is running. If it is running it will do nothing, if it is not running it will remove the links example: #include <Timers.au3> #include <GUIConstantsEx.au3> #include <Array.au3> HotKeySet("{ESC}", "_Exit") ; exit HotKeySet("{HOME}", "_Display") ; Display $aApps array HotKeySet("{END}", "_NewApp") ; Run one more notepad (as new example app) Global $MyAppsDir = @ScriptDir & "\MyApps" Global $aApps[0][2] ; We need a GUI to make AutoIt timers work, as the Timers.au3 library is linked to GUI messages. Global $hGUI = GUICreate("My Timer need one GUI", 100, 100) GUISetState(@SW_HIDE) ; set timer to check every nnn Local $i_TimerInterval = 1000 _Timer_SetTimer($hGUI, $i_TimerInterval, "_TimerCheck") ; Run some example apps _RunApp("notepad") _RunApp("notepad") _RunApp("notepad") ; show result of fake symlink ShellExecute($MyAppsDir) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _Exit() Func _RunApp($sName) ShellExecute($sName) Sleep(200) Local $hWnd = WinGetHandle("[ACTIVE]") ConsoleWrite("$hWnd=" & $hWnd & @CRLF) If Not FileExists($MyAppsDir) Then DirCreate($MyAppsDir) Local $sPath = $MyAppsDir & "\" & $hWnd & ".txt" Local $sFill = $hWnd & "|" & $sPath _ArrayAdd($aApps, $sFill) ; fake symlink FileWrite($sPath, $hWnd) EndFunc ;==>_RunApp ; Timer call back function Func _TimerCheck($hWnd, $iMsg, $iIDTimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer, $iTime If IsArray($aApps) Then Local $sRange = "" For $i = 0 To UBound($aApps) - 1 If Not WinExists(HWnd($aApps[$i][0])) Then ConsoleWrite("found:" & $aApps[$i][0] & @CRLF) FileDelete($aApps[$i][1]) $sRange &= $i & ";" EndIf Next If $sRange <> "" Then $sRange = StringTrimRight($sRange, 1) ConsoleWrite("$sRange=" & $sRange & @CRLF) _ArrayDelete($aApps, $sRange) If @error Then ConsoleWrite("_ArrayDelete @error:" & @error & @CRLF) EndIf EndIf EndFunc ;==>_TimerCheck ; --- HotKeySet functions --- Func _NewApp() _RunApp("notepad") EndFunc ;==>_NewApp Func _Exit() ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) GUIDelete($hGUI) DirRemove($MyAppsDir, 1) Exit EndFunc ;==>_Exit Func _Display() If WinExists("$aApps") Then WinClose("$aApps") Else _ArrayDisplay($aApps, "$aApps") EndIf EndFunc ;==>_Display1 point
-
_WinAPI_DwmEnableBlurBehindWindow in Windows 11
mlibre2 reacted to WildByDesign for a topic
This is probably the case. I would add _WinAPI_DwmIsCompositionEnabled to the myLogin script to ensure that composition is available and enabled. The hardware has to be capable (possibly the VM may not) plus Transparency has to be enabled in the Settings app in Win11.1 point -
_WinAPI_DwmEnableBlurBehindWindow in Windows 11
mlibre2 reacted to argumentum for a topic
Then that's that. A VM will not be the same as a HW one. The remote desktop that connects to it is the "viewer". Not quite a hardware monitor on the PC. Not sure if it can be done personally. It should I guess. But in my VMs I didn't even try. Edit: Well, I did. And it worked too Enable rounded corners: reg add HKLM\SOFTWARE\Microsoft\Windows\Dwm /v ForceEffectMode /t REG_DWORD /d 2 /f Disable the effects (restore defaults): reg delete HKLM\SOFTWARE\Microsoft\Windows\Dwm /v ForceEffectMode /f funny enough, all the settings were as expected but, nothing. Added this "ForceEffectMode" that was for "round corners" in a remote desktop, and that did it.1 point -
Try this: ;Coded by UEZ build 2025-09-06 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIConstants.au3> #include <WinAPISysWin.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172, $SC_DRAGMOVE = 0xF012 Global Const $iW = 300, $iH = $iW Global $hGUI = GUICreate("GDI+ Ring Progressbar", $iW, $iH, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetState() Global $aInterpolations[4][2] ;define the interpolated colors and positions $aInterpolations[0][0] = 3 $aInterpolations[1][0] = 0xFF800000 ;Red $aInterpolations[1][1] = 0 $aInterpolations[2][0] = 0xFFFF6700 ;Orange $aInterpolations[2][1] = 0.5 $aInterpolations[3][0] = 0xFFFFFF00 ;Yellow $aInterpolations[3][1] = 1.0 Global $fPerc = 0, $iSleep = 30 GUIRegisterMsg($WM_TIMER, "PlayAnim") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0) GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_TIMER, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Func PlayAnim() _GDIPlus_RingProgressbar($fPerc, $iW) $fPerc += 0.33333 If $fPerc > 100 Then $fPerc = 0 EndFunc ;==>PlayAnim Func _GDIPlus_RingProgressbar($fPerc, $iSize = 300, $sText = "Please wait...") Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iSize, $iSize) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) If $fPerc < 0 Then $fPerc = 0 If $fPerc > 100 Then $fPerc = 100 Local Const $hPath = _GDIPlus_PathCreate(), _ $fRadius = $iSize / 1.5, $iX = ($iSize - $fRadius) / 2, $iY = ($iSize - $fRadius) / 2, _ $fDX = $iSize / 10, $fAngel = $fPerc * 3.6, $fSize = $iSize / 15 Local Const $hBrush = _GDIPlus_LineBrushCreate($iX, $fDX + $iY, $fRadius, $fRadius, 0, 0, 1) Local Const $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $fRadius, $fRadius) _GDIPlus_MatrixRotate($hMatrix, -35, False) _GDIPlus_LineBrushMultiplyTransform($hBrush, $hMatrix, False) _GDIPlus_LineBrushSetPresetBlend($hBrush, $aInterpolations) _GDIPlus_MatrixDispose($hMatrix) Local Const $hPen = _GDIPlus_PenCreate2($hBrush, $fSize) _GDIPlus_PathAddArc($hPath, $iX, $fDX + $iY, $fRadius, $fRadius, -90, $fAngel) _GDIPlus_GraphicsDrawPath($hCtxt, $hPath, $hPen) _GDIPlus_PathReset($hPath) Local Const $hFamily = _GDIPlus_FontFamilyCreate("Verdana") Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $tLayout = _GDIPlus_RectFCreate(0, $iSize / 12, $iSize, 0) Local Const $tLayout2 = _GDIPlus_RectFCreate(0, ($iSize + $iSize / 18) / 2, $iSize, 0) _GDIPlus_StringFormatSetAlign($hFormat, 1) Local Const $hBrush2 = _GDIPlus_BrushCreateSolid(0xF0FFFFFF) _GDIPlus_PenSetColor($hPen, 0xF0404040) _GDIPlus_PenSetWidth($hPen, $iSize / 100) _GDIPlus_PenSetLineJoin($hPen, 2) _GDIPlus_PathAddString($hPath, $sText, $tLayout, $hFamily, 0, $iSize / 12, $hFormat) _GDIPlus_PathAddString($hPath, StringFormat("%02d%", $fPerc), $tLayout2, $hFamily, 0, $iSize / 9, $hFormat) _GDIPlus_GraphicsDrawPath($hCtxt, $hPath, $hPen) _GDIPlus_GraphicsFillPath($hCtxt, $hPath, $hBrush2) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BrushDispose($hBrush2) _GDIPlus_PathDispose($hPath) Local $hHBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_BitmapDisplayTransparentInGUI($hHBmp, $hGUI) _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hHBmp) EndFunc ;==>_GDIPlus_RingProgressbar Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $iFlags = $ULW_ALPHA, $bReleaseGDI = True, $tDest = Null, $iBGR = 0) If Not BitAND(GUIGetStyle($hGUI)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, $tDest, $tSize, $hMemDC, $tSource, $iBGR, $tBlend, $iFlags) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc ;==>_WinAPI_BitmapDisplayTransparentInGUI Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>WM_LBUTTONDOWN1 point
-
This is an update of the old Automating Windows Explorer example. The update includes Desktop automation. However, Windows XP code has been removed. ThreadsOther threads related to File/Windows Explorer: Implementing Windows Explorer right pane Implementing Windows Explorer address bar Enumerating and Browsing the Desktop Some of these threads are very old. I'm considering updating some of the examples: Remove Windows XP code. Implement some of the code in other ways. Enumerating and Browsing the Desktop is important to me personally because it was the first time I used the ObjCreateInterface() function. The first version of the example was based on _AutoItObject_WrapperCreate() from the AutoItObject UDF. Then I was told that you can use ObjCreateInterface() instead. Of course I had to try. Automating File/Windows Explorer and DesktopAutomating File/Windows Explorer The old example contains a description of the techniques for automating File/Windows Explorer. The techniques are based on COM interfaces. Initially, it's about getting an IShellBrowser interface based on a File/Windows Explorer window handle. An IDispatch interface for the window is important for creating the IShellBrowser interface. Through the IShellBrowser interface, you can generate a large number of interfaces that can be used to implement the automation functions. Automating DesktopBilgus figured out how to get an IDispatch interface for the Desktop in this post: $oIShellWindows.FindWindowSW( Null, Null, $SWC_DESKTOP, $hWnd, $SWFO_NEEDDISPATCH, $pIDispatch ) This is the part of the old code in the GetIShellBrowser() function that needs to be updated to include the Desktop: ; Get an IWebBrowserApp object for each window ; This is done in two steps: ; 1. Get an IDispatch object for the window ; 2. Get the IWebBrowserApp interface ; Check if it's the right window Local $pIDispatch, $oIDispatch Local $pIWebBrowserApp, $oIWebBrowserApp, $hWnd For $i = 0 To $iWindows - 1 $oIShellWindows.Item( $i, $pIDispatch ) If $pIDispatch Then $oIDispatch = ObjCreateInterface( $pIDispatch, $sIID_IDispatch, $dtag_IDispatch ) $oIDispatch.QueryInterface( $tRIID_IWebBrowserApp, $pIWebBrowserApp ) If $pIWebBrowserApp Then $oIWebBrowserApp = ObjCreateInterface( $pIWebBrowserApp, $sIID_IWebBrowserApp, $dtag_IWebBrowserApp ) $oIWebBrowserApp.get_HWND( $hWnd ) If $hWnd = $hExplorer Then ExitLoop EndIf EndIf Next And here the code to include the Desktop is added: ; Get an IWebBrowserApp object for each window ; This is done in two steps: ; 1. Get an IDispatch object for the window ; 2. Get the IWebBrowserApp interface ; Check if it's the right window Local $pIDispatch, $oIDispatch, $hRes Local $pIWebBrowserApp, $oIWebBrowserApp, $hWnd For $i = 0 To $iWindows $hRes = $i < $iWindows ? $oIShellWindows.Item( $i, $pIDispatch ) _ : $oIShellWindows.FindWindowSW( Null, Null, $SWC_DESKTOP, $hWnd, $SWFO_NEEDDISPATCH, $pIDispatch ) If $pIDispatch Then $oIDispatch = ObjCreateInterface( $pIDispatch, $sIID_IDispatch, $dtag_IDispatch ) $oIDispatch.QueryInterface( $tRIID_IWebBrowserApp, $pIWebBrowserApp ) If $pIWebBrowserApp Then $oIWebBrowserApp = ObjCreateInterface( $pIWebBrowserApp, $sIID_IWebBrowserApp, $dtag_IWebBrowserApp ) $oIWebBrowserApp.get_HWND( $hWnd ) If $hWnd = $hExplorer Then ExitLoop EndIf EndIf Next The For loop runs an extra round if a File/Explorer Window has not been identified. In this last loop, the FindWindowSW() method returns a window corresponding to the Desktop. Here, the method always returns the Program Manager window. a consequence of this implementation is that if you specify a non-existent window as a parameter to the GetIShellBrowser() function, then the function will return the Program Manager window. Thus, the Program Manager window is the default window for the function. The IDispatch interface is the important thing in terms of automating the Desktop. Then all the functions used in connection with a File/Windows Explorer window can also be used in connection with the Desktop. Except for a few functions that are not relevant for the Desktop. Functions The automation functions are coded in FileExplorer.au3. The functions are implemented using a number of Shell API functions and Shell COM interfaces coded in ShellFunctions.au3 and ShellInterfaces.au3. The old example contains a list of implemented functions. New functions GetSortColumns() GetSortColumnsEx() SetSortColumns() Examples The 7z-file contains examples for automating the Desktop and a File/Windows Explorer window. These are the same examples as in this post. Note that the examples GetFiles.au3 and GetFolders.au3 also show how to make a list of selected files and folders. Note that the GetSetIconView.au3 example can change the order of icons on the Desktop. If you don't want this, run this example only in a File/Windows Explorer window. The GUI application that was used to demonstrate the features in the old version is not included. The small examples seems to be much more useful. This post contains new examples. In both the old and the new post, the examples are shown for a File/Windows Explorer window. But the 7z-file contains similar examples for the Desktop. Forum examplesThis is a list of the most interesting examples in the old thread: The original collection of small examples Automate a file search with UI Automation code. The question that led to this answer was asked in a slightly earlier post. Execute a function on a double-click in empty space of the listview. Based on UI Automation code. Here the question was asked somewhat earlier. UI Automation code to make a selected item visible by scrolling the listview up or down 7z-fileThe 7z-file contains source code for the UDF and examples. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. FileExplorerAndDesktop.7z1 point
-
interesting accident
KaFu reacted to pixelsearch for a topic
Maybe this explanation ? 1) Button when no style is indicated at creation (-1) , WS_TABSTOP will be forced (help file) Button style becomes 0x50010000 WS_CHILD, WS_VISIBLE, WS_TABSTOP [0x40000000, 'WS_CHILD'] [0x10000000, 'WS_VISIBLE'] [0x00010000, 'WS_TABSTOP'] 2) Button created with 0xFF0000 style Button style becomes 0x50FF0000 WS_CHILD, WS_VISIBLE, WS_OVERLAPPEDWINDOW, WS_VSCROLL, WS_HSCROLL [0x40000000, 'WS_CHILD'] [0x10000000, 'WS_VISIBLE'] [0x00CF0000, 'WS_OVERLAPPEDWINDOW'] [0x00200000, 'WS_VSCROLL'] [0x00100000, 'WS_HSCROLL'] 'WS_OVERLAPPEDWINDOW' means (WS_CAPTION | WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX)1 point -
I wrote this function to list the imports of a DLL. ;Coded by UEZ build 2024-06-09 #AutoIt3Wrapper_UseX64=n #include <Array.au3> #include <Debug.au3> #include <String.au3> #include <WinAPIFiles.au3> #include <WinAPIProc.au3> #include <WinAPIRes.au3> #include <WinAPISys.au3> Const $IMAGE_DIRECTORY_ENTRY_IMPORT = 1 Global $sFile = FileOpenDialog("Select a DLL file", "", "DLL (*.dll)", $FD_FILEMUSTEXIST) If @error Then Exit Global $a = _WinAPI_GetBinaryType2($sFile) Global $b = _WinAPI_GetBinaryType2(_WinAPI_GetProcessFileName()) If $a <> $b Or $a = "Error" Or $b = "Error" Then Exit MsgBox($MB_ICONERROR, "Error", "Script and DLL have not same binary type!", 10) Global $i, $aResult = _WinAPI_ListDLLImports($sFile) _DebugArrayDisplay($aResult, StringRegExpReplace($sFile, ".+\\(.+)", "$1") & " imports") Func _WinAPI_ListDLLImports($sFile, $iLevel = 1, $bRec = False, $bDisplayLocalFilesOnly = True, $iMaxRecLevel = 10) If $iLevel > $iMaxRecLevel Then Return Local Const $hModule = _WinAPI_LoadLibraryEx($sFile, BitOR($DONT_RESOLVE_DLL_REFERENCES, $LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR)) If Not $hModule Then Return SetError(1, 0, 0) Local Const $tSize = DllStructCreate("ulong bytes") ;https://learn.microsoft.com/en-us/windows/win32/api/dbghelp/nf-dbghelp-imagedirectoryentrytodata Local Const $aReturn = DllCall("Dbghelp.dll", "ptr", "ImageDirectoryEntryToData", "ptr", $hModule, "boolean", True, "ushort", $IMAGE_DIRECTORY_ENTRY_IMPORT, "struct*", $tSize) If Not IsArray($aReturn) Or @error Then _WinAPI_FreeLibrary($hModule) Return SetError(2, 0, 0) EndIf If Not $aReturn[0] Then _WinAPI_FreeLibrary($hModule) Return SetError(3, 0, 0) EndIf Local $tIMAGE_IMPORT_DESCRIPTOR, $sDLLName, $sPath = StringRegExpReplace($sFile, "(.+\\).+", "$1"), $sFN, $i = 0, $sDLL = StringRegExpReplace($sFile, ".+\\(.+)", "$1") Static $sDLLFiles = "" ConsoleWrite(_StringRepeat(@TAB, $iLevel - 1) & $sDLL & @CRLF) If $iLevel > 1 Then $sDLLFiles &= $sDLL & "|" While 1 $tIMAGE_IMPORT_DESCRIPTOR = DllStructCreate("dword dummy;dword TimeDateStamp;dword ForwarderChain;dword Name;dword FirstThunk;", $aReturn[0] + $i) If Not $tIMAGE_IMPORT_DESCRIPTOR.FirstThunk Then _WinAPI_FreeLibrary($hModule) If $iLevel = 1 Then Local $aResult = StringSplit(StringTrimRight($sDLLFiles, 1), "|", 2) $aResult = _ArrayUnique($aResult, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT) _ArraySort($aResult) Return $aResult EndIf Return Else $sDLLName = _WinAPI_WideCharToMultiByte(DllStructCreate("char s[256];", $hModule + $tIMAGE_IMPORT_DESCRIPTOR.name).s, 65001) $sFN = $sPath & $sDLLName If $bRec Then If FileExists($sFN) Then $iLevel += 1 _WinAPI_ListDLLImports($sFN, $iLevel) $iLevel -= 1 Else If Not $bDisplayLocalFilesOnly Then $sDLLFiles &= $sDLLName & "|" ConsoleWrite($iLevel & ":" & _StringRepeat(@TAB, $iLevel) & $sDLLName & @CRLF) EndIf Else ConsoleWrite($iLevel & ":" & _StringRepeat(@TAB, $iLevel) & $sDLLName & @CRLF) If Not $bDisplayLocalFilesOnly Then $sDLLFiles &= $sDLLName & "|" Else If FileExists($sFN) Then $sDLLFiles &= $sDLLName & "|" EndIf EndIf Endif $i += DllStructGetSize($tIMAGE_IMPORT_DESCRIPTOR) WEnd EndFunc ; #FUNCTION# ==================================================================================================================== ; Author.........: UEZ ; Modified.......: ; =============================================================================================================================== Func _WinAPI_GetBinaryType2($sFile) Local $hFile = _WinAPI_CreateFile($sFile, 2, 2, 2) If Not $hFile Or @error Then Return SetError(1, 0, 0) Local $hMapping = _WinAPI_CreateFileMapping($hFile, 0, Null, $PAGE_READONLY, Null) If Not $hMapping Then _WinAPI_CloseHandle($hFile) Return SetError(2, 0, 0) EndIf Local Const $pAddress = _WinAPI_MapViewOfFile($hMapping, 0, 0, $FILE_MAP_READ) If Not $pAddress Or @error Then __ReturnGBT2($hMapping, $hFile, 3) Local Const $aHeader = DllCall("Dbghelp.dll", "ptr", "ImageNtHeader", "ptr", $pAddress) If @error Or IsArray($aHeader) = 0 Then Return __ReturnGBT2($hMapping, $hFile, 4) Local Const $tIMAGE_NT_HEADERS = DllStructCreate("dword Signature;ptr FileHeader;ptr OptionalHeader;", $aHeader[0]) If @error Or Not IsDllStruct($tIMAGE_NT_HEADERS) Then Return __ReturnGBT2($hMapping, $hFile, 5) Local Const $tIMAGE_FILE_HEADER = DllStructCreate("word Machine;word NumberOfSections;dword TimeDateStamp;dword PointerToSymbolTable;dword NumberOfSymbols;word SizeOfOptionalHeader;word Characteristics;", _ DllStructGetPtr($tIMAGE_NT_HEADERS) + 4) If @error Or Not IsDllStruct($tIMAGE_FILE_HEADER) Then Return __ReturnGBT2($hMapping, $hFile, 6) __ReturnGBT2($hMapping, $hFile, 0) Switch $tIMAGE_FILE_HEADER.Machine Case 0x014c Return "x86" Case 0x0200 Return "Intel Itanium" Case 0x8664 Return "x64" Case Else Return "Error" EndSwitch EndFunc ;==>_WinAPI_GetBinaryType2 Func __ReturnGBT2(Byref $hMapping, ByRef $hFile, $iError) _WinAPI_CloseHandle($hMapping) _WinAPI_CloseHandle($hFile) If $iError Then Return SetError($iError, 0, 0) EndFunc ;==>__ReturnGBT21 point
-
I've not tried that. maybe later. So you can do something like this: #include <WinAPICom.au3> #include <Process.au3> #include <Array.au3> Opt("MustDeclareVars", 1) Global Const $CLSCTX_INPROC_SERVER = 0x01 + 0x02 + 0x04 + 0x10 Global Enum $eRender, $eCapture, $eAll, $EDataFlow_enum_count Global Enum $AudioSessionStateInactive, $AudioSessionStateActive, $AudioSessionStateExpired Global Const $eMultimedia = 1 Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $sTagIMMDeviceEnumerator = _ "EnumAudioEndpoints hresult(int;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(int;int;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr)" Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" Global Const $sTagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _ "GetMeteringChannelCount hresult(dword*);" & _ "GetChannelsPeakValues hresult(dword;float*);" & _ "QueryHardwareSupport hresult(dword*);" Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $sTagIMMDevice = _ "Activate hresult(clsid;dword;ptr;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(wstr*);" & _ "GetState hresult(dword*)" Global Const $sIID_IAudioSessionManager2 = "{77aa99a0-1bd6-484f-8bc7-2c654c9a9b6f}" Global Const $sTagIAudioSessionManager = "GetAudioSessionControl hresult(ptr;dword;ptr*);" & _ "GetSimpleAudioVolume hresult(ptr;dword;ptr*);" Global Const $sTagIAudioSessionManager2 = $sTagIAudioSessionManager & "GetSessionEnumerator hresult(ptr*);" & _ "RegisterSessionNotification hresult(ptr);" & _ "UnregisterSessionNotification hresult(ptr);" & _ "RegisterDuckNotification hresult(wstr;ptr);" & _ "UnregisterDuckNotification hresult(ptr)" Global Const $sIID_IAudioSessionEnumerator = "{e2f5bb11-0570-40ca-acdd-3aa01277dee8}" Global Const $sTagIAudioSessionEnumerator = "GetCount hresult(int*);GetSession hresult(int;ptr*)" Global Const $sIID_IAudioSessionControl = "{f4b1a599-7266-4319-a8ca-e70acb11e8cd}" Global Const $sTagIAudioSessionControl = "GetState hresult(int*);GetDisplayName hresult(wstr*);" & _ "SetDisplayName hresult(wstr);GetIconPath hresult(wstr*);" & _ "SetIconPath hresult(wstr;ptr);GetGroupingParam hresult(ptr*);" & _ "SetGroupingParam hresult(ptr;ptr);RegisterAudioSessionNotification hresult(ptr);" & _ "UnregisterAudioSessionNotification hresult(ptr);" Global Const $sIID_IAudioSessionControl2 = "{bfb7ff88-7239-4fc9-8fa2-07c950be9c6d}" Global Const $sTagIAudioSessionControl2 = $sTagIAudioSessionControl & "GetSessionIdentifier hresult(wstr*);" & _ "GetSessionInstanceIdentifier hresult(wstr*);" & _ "GetProcessId hresult(dword*);IsSystemSoundsSession hresult();" & _ "SetDuckingPreferences hresult(bool);" Global $bExit= not False HotKeySet("{ESC}","_Exit") _WinAPI_CoInitialize() Local $aApp =0 While $bExit $aApp = _GetAppsPlayingSound() If IsArray($aApp) then ConsoleWrite("!SoundDetected!!!" & @CRLF) For $i= 0 to UBound($aApp)-1 ConsoleWrite($aApp[$i][0] & @CRLF) Next ConsoleWrite("!End" & @CRLF) EndIf Sleep(100) WEnd _WinAPI_CoUninitialize() Func _Exit() $bExit=False EndFunc Func _GetAppsPlayingSound() Local $pIMMDevice = 0 Local $oMMDevice = 0 Local $pIAudioSessionManager2 = 0 Local $oIAudioSessionManager2 = 0 Local $pIAudioSessionEnumerator = 0 Local $oIAudioSessionEnumerator = 0 Local $nSessions = 0 Local $oMMDeviceEnumerator = 0 Local $aApp[0] Local $pIAudioSessionControl2 = 0 Local $oIAudioSessionControl2 = 0 Local $oIAudioMeterInformation = 0 Local $ProcessID = 0 Local $fPeakValue = 0 Local $iState = 0 Local $iVolume = 0 Local $oErrorHandler = 0 $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $sTagIMMDeviceEnumerator) If @error Then Return $aApp If SUCCEEDED($oMMDeviceEnumerator.GetDefaultAudioEndpoint($eRender, $eMultimedia, $pIMMDevice)) Then ;eRender $oMMDevice = ObjCreateInterface($pIMMDevice, $sIID_IMMDevice, $sTagIMMDevice) $oMMDevice.Activate($sIID_IAudioSessionManager2, $CLSCTX_INPROC_SERVER, 0, $pIAudioSessionManager2) $oIAudioSessionManager2 = ObjCreateInterface($pIAudioSessionManager2, $sIID_IAudioSessionManager2, $sTagIAudioSessionManager2) $oIAudioSessionManager2.GetSessionEnumerator($pIAudioSessionEnumerator) $oIAudioSessionEnumerator = ObjCreateInterface($pIAudioSessionEnumerator, $sIID_IAudioSessionEnumerator, $sTagIAudioSessionEnumerator) $oIAudioSessionEnumerator.GetCount($nSessions) For $i = 0 To $nSessions - 1 $oIAudioSessionEnumerator.GetSession($i, $pIAudioSessionControl2) $oIAudioSessionControl2 = ObjCreateInterface($pIAudioSessionControl2, $sIID_IAudioSessionControl2, $sTagIAudioSessionControl2) $oIAudioSessionControl2.GetState($iState) If $iState = $AudioSessionStateActive Then $oIAudioSessionControl2.GetProcessId($ProcessID) $oIAudioMeterInformation = ObjCreateInterface($pIAudioSessionControl2, $sIID_IAudioMeterInformation, $sTagIAudioMeterInformation) $oIAudioSessionControl2.AddRef $oIAudioMeterInformation.GetPeakValue($fPeakValue) If $fPeakValue > 0 Then ReDim $aApp[UBound($aApp) + 1][2] $aApp[UBound($aApp) - 1][0] = _ProcessGetName($ProcessID) $aApp[UBound($aApp) - 1][1] = $fPeakValue EndIf EndIf $fPeakValue = 0 $iState = 0 $ProcessID = 0 $oIAudioMeterInformation = 0 $oIAudioSessionControl2 = 0 Next $oIAudioSessionEnumerator = 0 $oIAudioSessionManager2 = 0 $oMMDevice = 0 $oMMDeviceEnumerator = 0 If UBound($aApp) = 0 Then $aApp = 0 Return $aApp Else Return 0 EndIf EndFunc ;==>_GetAppsPlayingSound Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Saludos1 point
-
@Olex: you're very welcome, and welcome to the AutoIt forums! Re GPT, I currently lack the hardware to develop this, but I'll soon be acquiring a new workhorse, and if that is UEFI-enabled I may be able to add this functionality in future (I guess that's progress, gotta keep running just to stay in the same place), However, to be honest, it's not the top item on my todo list at the moment, being an MBR dinosaur myself (asteroid? what asteroid?) But as my work environment is upgraded, I may suddenly develop an urgent need for it, in which case I'll post it here, of course.1 point
-
I hope this is helpful to you guys ; #FUNCTION# ==================================================================================================================== ; Name...........: GetActiveKeyboardLayout() Function ; Description ...: Get Active keyboard layout ; Author ........: Fredj A. Jad (DCCD) ; MSDN .........: GetWindowThreadProcessId Function ,http://msdn.microsoft.com/en-us/library/ms633522(VS.85).aspx ; MSDN .........: GetKeyboardLayout Function ,http://msdn.microsoft.com/en-us/library/ms646296(VS.85).aspx ; =============================================================================================================================== While 1 If Sleep(250) Then TrayTip('Active!', GetActiveKeyboardLayout(WinGetHandle('')), 5, 1) WEnd Func GetActiveKeyboardLayout($hWnd) Local $aRet = DllCall('user32.dll', 'long', 'GetWindowThreadProcessId', 'hwnd', $hWnd, 'ptr', 0) $aRet = DllCall('user32.dll', 'long', 'GetKeyboardLayout', 'long', $aRet[0]) Return '0000' & Hex($aRet[0], 4) EndFunc ;==>GetActiveKeyboardLayout1 point
-
SoulA modified helpfile example without any checking for menu handles. use the GuiMenu.au3 UDF to make menus you can check for the handles of using wparam in _WM_CONTEXTMENU(). see helpfile GuiMenu UDF section example for _GUICtrlMenu_CreatePopup () Edit: added comment on helpfile example #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Local $contextmenu, $button, $buttoncontext, $buttonitem, $msg, $iFlag = 0 Local $newsubmenu, $textitem, $fileitem, $saveitem, $infoitem ;right click on gui to bring up context Menu. ;right click on the "ok" button to bring up a control specific context menu. ;click on the "ok" button to disable contextmenus GUICreate("My GUI Context Menu", 300, 200) $button = GUICtrlCreateButton("Context Menu Enabled", 75, 100, 150, 20) $buttoncontext = GUICtrlCreateContextMenu($button) $buttonitem = GUICtrlCreateMenuItem("About button", $buttoncontext) $contextmenu = GUICtrlCreateContextMenu() $newsubmenu = GUICtrlCreateMenu("new", $contextmenu) $textitem = GUICtrlCreateMenuItem("text", $newsubmenu) $fileitem = GUICtrlCreateMenuItem("Open", $contextmenu) $saveitem = GUICtrlCreateMenuItem("Save", $contextmenu) GUICtrlCreateMenuItem("", $contextmenu) ; separator $infoitem = GUICtrlCreateMenuItem("Info", $contextmenu) GUIRegisterMsg($WM_CONTEXTMENU, "_WM_CONTEXTMENU") GUISetState() While 1 Switch GUIGetMsg() Case $button $iFlag = Not $iFlag If $iFlag Then GUICtrlSetData($button, "Context Menu Disabled") Else GUICtrlSetData($button, "Context Menu Enabled") EndIf Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd Func _WM_CONTEXTMENU($hwnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If $iFlag Then Return 0 Return $GUI_RUNDEFMSG EndFunc1 point