Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 06/12/2025 in all areas

  1. Jon

    AutoIt v3.3.17.1 Beta

    AutoIt v3.3.17.1 Beta View File 3.3.17.1 (July 08, 2025) (Beta) AutoIt: UDFs: - Fixed: Typo in variable name in Date.au3 introduced in previous beta. 3.3.17.0 (June 29, 2025) (Beta) AutoIt: - Changed: Windows 7/Server 2008 is now the minimum OS version required due to dev environment changes. - Added #3891: DllCall() performance optimisation. - Added: Standard Windows Fonts List for Win10/Win11. - Added #3906: GUICtrlCreateXXX creation in example assign to $idXXX to reflect Ctrl type. - Added: FileGetAttrib() retrieve Join folder (J) as created by FileCreateNTFSLink(). - Added: Split WindowsConstants.u3 in WindowsNotifsConstants.au3, WindowsStylesConstants.au3 and WindowsSysColor.au3. - Added: #3984: GUICtrlSetGraphic() doc precision. - Fixed: Doc Chr(0) handling inside functions. - Fixed #3923: Doc typo in "Send Key List". - Fixed: Regression #3135 handle leak (Thanks Nano, Rudi, Nine). - Fixed #3925: Doc With ... EndWith using DllStruct Type. - Fixed: Links in Tutorials example code (thanks argumentum). Au3info: - Added: Display mouse coordinate mode. - Fixed #3917: Crash under Win7. SciTE-Lite: - Fixed: Folding Fix for #Preprocessor foldblock when followed by a CommentBlock. UDFs: - Added: script examples when running under Win11 with new notepad.exe. - Added: _GUICtrlTreeView_GetItemByIndex() can retrieve handle of the list of main item ($hItem= -1). - Added: _IsPressed() can be called with numeric value as in "WinAPIsvkeysConstants.au3". - Added #3909: _DebugReportData() to report Array column formatted. - Added: libExamples referring MemoWrite() now refer to _MemoWrite() defined in Extras\HelpFileInternals.au3. - Added: _WinAPI_WaitSystemIdle(), _WinAPI_QueryDiskUsage(), _WinAPI_QueryProcessorUsage(), _WinAPI_QueryProcessCycleTime() - Added: Doc _WinAPI_GetWindowSubclass() example (Thanks pixelSearch). - Added: _WinAPI_GetKeyboardLayout() default value for the running thread. - Added: _WinAPI_GetUserDefaultLCID() example. - Added: _WinAPI_GetKeyboardLayoutLocale(). - Added: _WinAPI_GetKeyboardState() example (Thanks AutoXenon). - Added #3932: Try to use file in HelpFile\Extras instead of @ScriptDir. - Added #3934: _WinAPI_SetTimer() example. - Added: _IsPressed() can wait on one of several keys. - Added: _WinAPI_SendInput(). - Added #3960: _Div() integer division. - Added #3963: _WinAPI_OpenEvent(). - Added: _GDIPlus_ImageSaveToFile() doc precision for compression level. - Added: _WinAPI_GetCursorSize() and _WinAPI_SetCursorSize(). - Added: $FOLDERID_Documents Constants in APIShellExConstants.au3. - Added: Support _GUIToolTip*() to be used to external process. - Added: Support _GUICtrlHeader*() to be used to external process. - Added: Support _GUICtrlStatusBar*() to be used to external process. - Added #3988: _WinAPI_GetSystemPowerStatus() return Battery status saver. - Added #3985: _ArrayDisplay() + $WS_EX_TOPMOST. - Added #3991: _SQLite_ForeignKeys() and Add a parameter in _SQLite_Open() to set it also. - Added #3990: _IsPressed() return in @extended if the key is still pressed. - Added: _DebugSetup(..., 1) does not interact with script being debug, Report infos copied to clipboard - Added: _WinAPI_SetWindowTheme() example to demonstrate Checkbox or Radio controls coloring. - Added #3997: _WinAPI_RegisterShellHookWindow() example improvement. - Added #3999: _WinAPI_OemToChar() performance improvement. - Added #3946: _ChooseFont() updated defaults (thanks argumentum). - Added: _DateDiff(), _DateAdd() using array for [days, hours, minutes, seconds]. - Added: _DebugSetup() Type 6, same as 1 but a timeout to close the report log windows. - Fixed #3894: _WinAPI_GetProcessName() returns incorrect result when process ID is invalid. - Fixed: "Then SetError()" in several standard UDF. - Fixed #3921: Missing _GUICtrlStatusBar_SetParts() examples. - Fixed: Doc typo $GPIP_ERR* >> $GDIP_ERR*. - Fixed #3926: _GUICtrlTreeView_SetChildren() not set/reset chidren flag. - Fixed: _WinAPI_DisplayStruct() elements containing chr(124). - Fixed #3945: StringRegExp() /s include VT. - Fixed #3949: _ArrayDisplay() does show multiple subscript of an array. - Fixed #3954: links in libfunction constants. - Fixed: missing doc description $iSubItem = - 1 in _GUICtrlListView_SetItemText(). - Fixed #3959: _WinAPI_ShellUserAuthenticationDlg() example. - Fixed #3975: unrelated link in Pcre doc. - Fixed #3903: _GuiCtrlTab_GetItem() does work on external process. - Fixed #3992: _WinAPI_DwmSetWindowAttribute() does not support all MSDN attributes. - Fixed #4001: _GUICtrlListView_*() example ($tagNMITEMACTIVATE). - Fixed #4003: _ArrayPush() doc precision. - Fixed: _GUICtrlButton_SetSplitInfo() example crash. - Fixed: Support of Notepad under Win11 for _DebugSetup(). - Fixed #4022: Various doc duplicated words. - Fixed #4031: _DebugArrayDisplay() buttons display. - Fixed: _DebugArrayDisplay() not executed if @error on entering ($ARRAYDISPLAY_CHECKERROR if no display wanted on @error). - Fixed #4033: _DateTimeSplit() setting $aTimePart[0] whem no time defined. - Fixed #4024: _DebugSetup(,, 5) (notepad window) not working under Windows 11. - Fixed: _WinAPI_IsElevated() @extended return value (Thanks Argumentum). - Fixed #4039: _GUICtrlTreeView_Delete() with $hWnd. - Fixed #4038: _GUICtrlRichEdit_StreamToFile() extra new paragraph. - Fixed #4029: _Date_Time_SystemTimeToDateTimeStr() Wrong output. - Fixed #4040: _GUICtrlRichEdit_SetZoom() parameter limitation bug. - Fixed #4041: _GUICtrlStatusBar_SetIcon() not shown. Submitter Jon Submitted 07/08/2025 Category Beta  
    10 points
  2. AutoIt was never really built for speed — it’s an interpreted language, great for scripting and automation, but not exactly a high-performance engine under the hood. So trying to make it handle things like fast array slicing or inserting elements mid-array feels a bit like teaching a car to fly or haul 30 tons. Sure, maybe you could pull it off with enough creativity (and duct tape), but if you want to fly, you take a plane. If you want to haul heavy stuff, get a truck. Same with programming — sometimes it's better to just pick a faster compiled language for the job. That said, I love seeing people push the boundaries of what AutoIt can do. Using FASM, COM, and clever hacks to get more out of it is impressive, and if it helps you learn or build something cool — go for it! Just don’t forget the core strengths of AutoIt: simplicity, ease of use, and rapid development. Sometimes it’s okay to let the car be a car. 😊
    6 points
  3. 1.8.5 released! This contains fix for the issue caused by UDF documentation headers with an empty newline in their content, found by @seadoggie01 I also found and fixed a related issue, where the capture regex did not capture the text after the empty newline for the tool-tip content.
    5 points
  4. MattyD

    WinRT - WinUI3

    Hi all - This is an offshoot of the WinRT Project. I'm posting my progress here while I'm bumbling around with WinUI3 - just so the main project doesn't get too cluttered. If I get things working I'll merge the two projects back together. That's the plan anyway! ATM all I have is a blank Window (thrilling I know!), but if you wish to try it out you'll need to: download and extract the example (obviously!) WindowTest.zip Go here and download the latest Redistributable package of the Windows App SDK. Currently this is 1.7.3 (look in the table for the link.). Once you've extracted that, go to the MSIX > win10-x64 folder It seems the x86 libraries don't work at the moment. (thanks for testing Gianni) . So ensure you're running Autiot_x64 on the autoit side! (#AutoIt3Wrapper_UseX64=Y directive in script) Extract the contents of Microsoft.WindowsAppRuntime.1.7.msix. (7-Zip works fine) I also installed the msix - This is not necessary for now (thanks again Gianni). At some point we'll probably reference our dlls from the installed runtime location. Grab all the .dll files and put then in the same folder as "WindowTest.au3" If you plan to make use of the Class Explorer script, grab all the .winmd files and put them in the same folder as "ClassExplorer v2.3.1.au3" I also found AppxManifest.xml is handy for mapping objects to physical dll files. Cheers, Matt
    4 points
  5. UEZ

    why no array pointer

    Just made a quick test for 2D struct array: ;Code by UEZ #AutoIt3Wrapper_UseX64=y #include <WinAPIDiag.au3> #include <Memory.au3> Global Const $iWidth = 1000, $iHeight = 4000 Global Const $iTotal = $iWidth * $iHeight ConsoleWrite("Total: " & $iTotal & @CRLF) Global $t2DArray = DllStructCreate("uint a[" & $iTotal & "]") ;2D array Global $pArray = DllStructGetPtr($t2DArray) Global $x, $y, $t, $index ;2D For $y = 0 To $iHeight - 1 ;0 1 2 3 4 $t = $y * $iWidth ;10 11 12 13 14 For $x = 0 To $iWidth - 1 ;20 21 22 23 24 $index = $t + $x ;30 31 32 33 34 $t2DArray.a(($index + 1)) = $y & $x ; Next ;1D -> 0 1 2 3 4 10 11 12 13 14 20 21 22 23 24 30 31 32 33 34 Next Global $fTimer = TimerInit() ;~ Print2DArray($t2DArray, $iWidth, $iHeight) InsertValue2D(99, 0, 0, $t2DArray, $pArray, $iWidth, $iHeight, "uint") ;~ ConsoleWrite(@CRLF & "Result (add 99 at 0, 0):" & @CRLF) ConsoleWrite(TimerDiff($fTimer) & @CRLF) ;~ Print2DArray($t2DArray, $iWidth, $iHeight + 1) DeleteValue2D(2, 2, $t2DArray, $pArray, $iWidth, $iHeight + 1, "uint") ConsoleWrite(TimerDiff($fTimer) & @CRLF) ;~ ConsoleWrite(@CRLF & "Result (del 2, 2 -> 21):" & @CRLF) ;~ Print2DArray($t2DArray, $iWidth, $iHeight) Func InsertValue2D($value, $xPos, $yPos, ByRef $tStruct, ByRef $pArray, $cols, $rows, $type) Local $oldElements = $cols * $rows Local $newRows = $rows + 1 Local $newElements = $cols * $newRows Local $elementSize Switch $type Case "ushort", "short", "word" $elementSize = 2 Case "uint", "int", "float" $elementSize = 4 Case "double", "int64", "uint64" $elementSize = 8 Case Else Return SetError(1, 0, 0) EndSwitch Local $tNew = DllStructCreate($type & " a[" & $newElements & "]") Local $pNew = DllStructGetPtr($tNew) Local $insertIndex = $yPos * $cols + $xPos If $insertIndex < 0 Or $insertIndex > $oldElements Then Return SetError(1, 0, 0) _MemMoveMemory($pArray, $pNew, $insertIndex * $elementSize) $tNew.a($insertIndex + 1) = $value Local $bytesAfter = ($oldElements - $insertIndex) * $elementSize _MemMoveMemory($pArray + ($insertIndex * $elementSize), $pNew + (($insertIndex + 1) * $elementSize), $bytesAfter) $tStruct = $tNew $pArray = $pNew Return 1 EndFunc Func DeleteValue2D($xPos, $yPos, ByRef $tStruct, ByRef $pArray, $cols, $rows, $type) Local $oldElements = $cols * $rows If $rows < 2 Then Return SetError(1, 0, 0) Local $newElements = $oldElements - 1 Local $elementSize Switch $type Case "ushort", "short", "word" $elementSize = 2 Case "uint", "int", "float" $elementSize = 4 Case "double", "int64", "uint64" $elementSize = 8 Case Else Return SetError(2, 0, 0) EndSwitch Local $deleteIndex = $yPos * $cols + $xPos If $deleteIndex < 0 Or $deleteIndex >= $oldElements Then Return SetError(3, 0, 0) Local $tNew = DllStructCreate($type & " a[" & $newElements & "]") Local $pNew = DllStructGetPtr($tNew) _MemMoveMemory($pArray, $pNew, $deleteIndex * $elementSize) Local $bytesAfter = ($oldElements - $deleteIndex - 1) * $elementSize _MemMoveMemory($pArray + (($deleteIndex + 1) * $elementSize), $pNew + ($deleteIndex * $elementSize), $bytesAfter) $tStruct = $tNew $pArray = $pNew Return 1 EndFunc Func Print2DArray($t2DArray, $cols, $rows) Local $x, $y, $index For $y = 0 To $rows - 1 For $x = 0 To $cols - 1 $index = $y * $iWidth + $x ConsoleWrite($t2DArray.a($index + 1) & @TAB) Next ConsoleWrite(@CRLF) Next EndFunc It took 13 seconds to execute insert and delete operation for one element each for an array with 4.000.000 elements. I don't know how long it would take using ASM... I'm pretty rusty when it comes to ASM. ¯\_(ツ)_/¯
    4 points
  6. UEZ

    why no array pointer

    Something like that: 1D: ;coded by UEZ #include <WinAPIDiag.au3> #include <Memory.au3> Global $iElements = 2^5 ConsoleWrite("Number of entries: " & $iElements & @CRLF) Global $tArray = DllStructCreate("uint a[" & $iElements & "]") Global $pArray = DllStructGetPtr($tArray) For $i = 1 To $iElements $tArray.a(($i)) = $i Next Global $iPos = Int($iElements * 0.667) ConsoleWrite("Insert to position " & $iPos & @CRLF) InsertValue(123456789, $iPos, $tArray, $pArray, "uint") _WinAPI_DisplayStruct($tArray, "uint a[" & $iElements + 1 & "]") Func InsertValue($value, $iPos, ByRef $tArray, ByRef $pArray, $type) If Not IsDllStruct($tArray) Then Return SetError(1, 0, 0) Local $iUB, $iBytes Switch $type Case "wchar", "short", "ushort", "word" $iBytes = 2 $iUB = DllStructGetSize($tArray) / $iBytes Case "float", "int", "long", "bool", "uint", "ulong" $iBytes = 4 $iUB = DllStructGetSize($tArray) / $iBytes Case "int64", "uint64", "double" $iBytes = 8 $iUB = DllStructGetSize($tArray) / $iBytes Case Else Return SetError(2, 0, 0) EndSwitch If $iPos < 1 Or $iPos > $iUB Then SetError(3, 0, 0) $iUB += 1 Local $tArray_new = DllStructCreate($type & " a[" & $iUB & "]") $pArray = DllStructGetPtr($tArray_new) _MemMoveMemory(DllStructGetPtr($tArray), $pArray, ($iPos - 1) * $iBytes) $tArray_new.a(($iPos)) = $value _MemMoveMemory(DllStructGetPtr($tArray) + ($iPos - 1) * $iBytes, $pArray + $iPos * $iBytes , ($iUB - $iPos) * $iBytes) $tArray = $tArray_new Return 1 EndFunc 2D: #include <WinAPIDiag.au3> #include <Memory.au3> Global Const $iWidth = 5, $iHeight = 4 Global Const $iTotal = $iWidth * $iHeight Global $t2DArray = DllStructCreate("uint a[" & $iTotal & "]") ;2D array Global $pArray = DllStructGetPtr($t2DArray) Global $x, $y, $t, $index ;2D For $y = 0 To $iHeight - 1 ;0 1 2 3 4 $t = $y * $iWidth ;10 11 12 13 14 For $x = 0 To $iWidth - 1 ;20 21 22 23 24 $index = $t + $x ;30 31 32 33 34 $t2DArray.a(($index + 1)) = $y & $x ; Next ;1D -> 0 1 2 3 4 10 11 12 13 14 20 21 22 23 24 30 31 32 33 34 Next Print2DArray($t2DArray, $iWidth, $iHeight) InsertValue2D(99, 0, 0, $t2DArray, $pArray, $iWidth, $iHeight, "uint") ConsoleWrite(@CRLF & "Result (add 99 at 0, 0):" & @CRLF) Print2DArray($t2DArray, $iWidth, $iHeight + 1) DeleteValue2D(2, 2, $t2DArray, $pArray, $iWidth, $iHeight + 1, "uint") ConsoleWrite(@CRLF & "Result (del 2, 2 -> 21):" & @CRLF) Print2DArray($t2DArray, $iWidth, $iHeight) Func InsertValue2D($value, $xPos, $yPos, ByRef $tStruct, ByRef $pArray, $cols, $rows, $type) Local $oldElements = $cols * $rows Local $newRows = $rows + 1 Local $newElements = $cols * $newRows Local $elementSize Switch $type Case "ushort", "short", "word" $elementSize = 2 Case "uint", "int", "float" $elementSize = 4 Case "double", "int64", "uint64" $elementSize = 8 Case Else Return SetError(1, 0, 0) EndSwitch Local $tNew = DllStructCreate($type & " a[" & $newElements & "]") Local $pNew = DllStructGetPtr($tNew) Local $insertIndex = $yPos * $cols + $xPos If $insertIndex < 0 Or $insertIndex > $oldElements Then Return SetError(1, 0, 0) _MemMoveMemory($pArray, $pNew, $insertIndex * $elementSize) $tNew.a($insertIndex + 1) = $value Local $bytesAfter = ($oldElements - $insertIndex) * $elementSize _MemMoveMemory($pArray + ($insertIndex * $elementSize), $pNew + (($insertIndex + 1) * $elementSize), $bytesAfter) $tStruct = $tNew $pArray = $pNew Return 1 EndFunc Func DeleteValue2D($xPos, $yPos, ByRef $tStruct, ByRef $pArray, $cols, $rows, $type) Local $oldElements = $cols * $rows If $rows < 2 Then Return SetError(1, 0, 0) Local $newElements = $oldElements - 1 Local $elementSize Switch $type Case "ushort", "short", "word" $elementSize = 2 Case "uint", "int", "float" $elementSize = 4 Case "double", "int64", "uint64" $elementSize = 8 Case Else Return SetError(2, 0, 0) EndSwitch Local $deleteIndex = $yPos * $cols + $xPos If $deleteIndex < 0 Or $deleteIndex >= $oldElements Then Return SetError(3, 0, 0) Local $tNew = DllStructCreate($type & " a[" & $newElements & "]") Local $pNew = DllStructGetPtr($tNew) _MemMoveMemory($pArray, $pNew, $deleteIndex * $elementSize) Local $bytesAfter = ($oldElements - $deleteIndex - 1) * $elementSize _MemMoveMemory($pArray + (($deleteIndex + 1) * $elementSize), $pNew + ($deleteIndex * $elementSize), $bytesAfter) $tStruct = $tNew $pArray = $pNew Return 1 EndFunc Func Print2DArray($t2DArray, $cols, $rows) Local $x, $y, $index For $y = 0 To $rows - 1 For $x = 0 To $cols - 1 $index = $y * $iWidth + $x ConsoleWrite($t2DArray.a($index + 1) & @TAB) Next ConsoleWrite(@CRLF) Next EndFunc
    4 points
  7. I found this on my drive: #include <GUIComboBox.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> #include <BorderConstants.au3> #include <WinAPI.au3> Global Const $ODT_MENU = 1 Global Const $ODT_LISTBOX = 2 Global Const $ODT_COMBOBOX = 3 Global Const $ODT_BUTTON = 4 Global Const $ODT_STATIC = 5 Global Const $ODT_HEADER = 100 Global Const $ODT_TAB = 101 Global Const $ODT_LISTVIEW = 102 Global Const $ODA_DRAWENTIRE = 1 Global Const $ODA_SELECT = 2 Global Const $ODA_FOCUS = 4 Global Const $ODS_SELECTED = 1 Global Const $ODS_GRAYED = 2 Global Const $ODS_DISABLED = 4 Global Const $ODS_CHECKED = 8 Global Const $ODS_FOCUS = 16 Global Const $ODS_DEFAULT = 32 Global Const $ODS_HOTLIGHT = 64 Global Const $ODS_INACTIVE = 128 Global Const $ODS_NOACCEL = 256 Global Const $ODS_NOFOCUSRECT = 512 Global Const $ODS_COMBOBOXEDIT = 4096 Global Const $clrWindowText = _WinAPI_GetSysColor($COLOR_WINDOWTEXT) Global Const $clrHighlightText = _WinAPI_GetSysColor($COLOR_HIGHLIGHTTEXT) Global Const $clrHighlight = _WinAPI_GetSysColor($COLOR_HIGHLIGHT) Global Const $clrWindow = _WinAPI_GetSysColor($COLOR_WINDOW) Global Const $tagDRAWITEMSTRUCT = _ 'uint CtlType;' & _ 'uint CtlID;' & _ 'uint itemID;' & _ 'uint itemAction;' & _ 'uint itemState;' & _ 'hwnd hwndItem;' & _ 'hwnd hDC;' & _ $tagRECT & _ ';ulong_ptr itemData;' Global Const $tagMEASUREITEMSTRUCT = _ 'uint CtlType;' & _ 'uint CtlID;' & _ 'uint itemID;' & _ 'uint itemWidth;' & _ 'uint itemHeight;' & _ 'ulong_ptr itemData;' Global $iItemWidth, $iItemHeight Global $hGUI Global $ComboBox Global $hBrushNorm = _WinAPI_CreateSolidBrush($clrWindow) Global $hBrushSel = _WinAPI_CreateSolidBrush($clrHighlight) GUIRegisterMsg($WM_MEASUREITEM, '_WM_MEASUREITEM') GUIRegisterMsg($WM_DRAWITEM, '_WM_DRAWITEM') ;GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND') $hGUI = GUICreate('Test', 220, 300) $ComboBox = GUICtrlCreateCombo('', 10, 10, 200, 300, BitOR($WS_CHILD, $CBS_OWNERDRAWVARIABLE, $CBS_HASSTRINGS, $CBS_DROPDOWNLIST)) GUICtrlSetData($ComboBox, "Medabi|V!c†o®|joelson0007-|JScript|Belini|Jonatas-|AutoIt v3|www.autoitbrasil.com-|www.autoitscript.com", "Medabi") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hBrushSel) _WinAPI_DeleteObject($hBrushNorm) GUIDelete() Func _WM_MEASUREITEM($hWnd, $iMsg, $iwParam, $ilParam) Local $stMeasureItem = DllStructCreate($tagMEASUREITEMSTRUCT, $ilParam) If DllStructGetData($stMeasureItem, 1) = $ODT_COMBOBOX Then Local $iCtlType, $iCtlID, $iItemID Local $ComboBoxBox Local $tSize Local $sText $iCtlType = DllStructGetData($stMeasureItem, 'CtlType') $iCtlID = DllStructGetData($stMeasureItem, 'CtlID') $iItemID = DllStructGetData($stMeasureItem, 'itemID') $iItemWidth = DllStructGetData($stMeasureItem, 'itemWidth') $iItemHeight = DllStructSetData($stMeasureItem, "itemHeight", DllStructGetData($stMeasureItem, 'itemHeight') + 4) ;$iItemHeight = DllStructGetData($stMeasureItem, 'itemHeight') $ComboBoxBox = GUICtrlGetHandle($iCtlID) EndIf $stMeasureItem = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_MEASUREITEM Func _WM_DRAWITEM($hWnd, $iMsg, $iwParam, $ilParam) Local $tDIS = DllStructCreate($tagDRAWITEMSTRUCT, $ilParam) Local $iCtlType, $iCtlID, $iItemID, $iItemAction, $iItemState Local $clrForeground, $clrBackground Local $hWndItem, $hDC, $hOldPen, $hOldBrush Local $tRect Local $sText Local $iLeft, $iTop, $iRight, $iBottom $iCtlType = DllStructGetData($tDIS, 'CtlType') $iCtlID = DllStructGetData($tDIS, 'CtlID') $iItemID = DllStructGetData($tDIS, 'itemID') $iItemAction = DllStructGetData($tDIS, 'itemAction') $iItemState = DllStructGetData($tDIS, 'itemState') $hWndItem = DllStructGetData($tDIS, 'hwndItem') $hDC = DllStructGetData($tDIS, 'hDC') $tRect = DllStructCreate($tagRECT) If $iCtlType = $ODT_COMBOBOX And $iCtlID = $ComboBox Then Switch $iItemAction Case $ODA_DRAWENTIRE For $i = 1 To 4 DllStructSetData($tRect, $i, DllStructGetData($tDIS, $i + 7)) Next _GUICtrlComboBox_GetLBText($hWndItem, $iItemID, $sText) Local $iTop = DllStructGetData($tRect, 2), $iBottom = DllStructGetData($tRect, 4) DllStructSetData($tRect, 2, $iTop + 2) DllStructSetData($tRect, 4, $iBottom - 1) If BitAND($iItemState, $ODS_SELECTED) Then $clrForeground = _WinAPI_SetTextColor($hDC, $clrHighlightText) $clrBackground = _WinAPI_SetBkColor($hDC, $clrHighlight) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrushSel) Else $clrForeground = _WinAPI_SetTextColor($hDC, $clrWindowText) $clrBackground = _WinAPI_SetBkColor($hDC, $clrWindow) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrushNorm) EndIf DllStructSetData($tRect, 2, $iTop) DllStructSetData($tRect, 4, $iBottom) If $sText <> "" Then If StringInStr($sText, "-", 0, -1) Then ; Draw a "line" for a separator item If Not BitAND($iItemState, $ODS_COMBOBOXEDIT) Then DllStructSetData($tRect, 2, $iTop + ($iItemHeight)) _WinAPI_DrawEdge($hDC, DllStructGetPtr($tRect), $EDGE_ETCHED, $BF_TOP) EndIf $sText = StringTrimRight($sText, 1) EndIf DllStructSetData($tRect, 2, $iTop + 4) _WinAPI_DrawText($hDC, $sText, $tRect, $DT_LEFT) _WinAPI_SetTextColor($hDC, $clrForeground) _WinAPI_SetBkColor($hDC, $clrBackground) EndIf _WinAPI_SetBkMode($hDC, $TRANSPARENT) Case $ODA_SELECT, $ODA_FOCUS For $i = 1 To 4 DllStructSetData($tRect, $i, DllStructGetData($tDIS, $i + 7)) Next _GUICtrlComboBox_GetLBText($hWndItem, $iItemID, $sText) Local $iTop = DllStructGetData($tRect, 2), $iBottom = DllStructGetData($tRect, 4) DllStructSetData($tRect, 2, $iTop + 2) DllStructSetData($tRect, 4, $iBottom - 1) If BitAND($iItemState, $ODS_SELECTED) Then $clrForeground = _WinAPI_SetTextColor($hDC, $clrHighlightText) $clrBackground = _WinAPI_SetBkColor($hDC, $clrHighlight) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrushSel) Else $clrForeground = _WinAPI_SetTextColor($hDC, $clrWindowText) $clrBackground = _WinAPI_SetBkColor($hDC, $clrWindow) _WinAPI_FillRect($hDC, DllStructGetPtr($tRect), $hBrushNorm) EndIf DllStructSetData($tRect, 2, $iTop) DllStructSetData($tRect, 4, $iBottom) If $sText <> "" Then If StringInStr($sText, "-", 0, -1) Then ; Draw a "line" for a separator item If Not BitAND($iItemState, $ODS_COMBOBOXEDIT) Then DllStructSetData($tRect, 2, $iTop + ($iItemHeight)) _WinAPI_DrawEdge($hDC, DllStructGetPtr($tRect), $EDGE_ETCHED, $BF_TOP) EndIf $sText = StringTrimRight($sText, 1) EndIf DllStructSetData($tRect, 2, $iTop + 4) _WinAPI_DrawText($hDC, $sText, $tRect, $DT_LEFT) _WinAPI_SetTextColor($hDC, $clrForeground) _WinAPI_SetBkColor($hDC, $clrBackground) EndIf _WinAPI_SetBkMode($hDC, $TRANSPARENT) EndSwitch EndIf $tRect = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_DRAWITEM Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo If Not IsHWnd($ComboBox) Then $hWndCombo = GUICtrlGetHandle($ComboBox) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case $ComboBox, $hWndCombo Switch $iCode Case $CBN_CLOSEUP ; Sent when the list box of a combo box has been closed _DebugPrint("$CBN_CLOSEUP" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_DBLCLK ; Sent when the user double-clicks a string in the list box of a combo box _DebugPrint("$CBN_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_DROPDOWN ; Sent when the list box of a combo box is about to be made visible _DebugPrint("$CBN_DROPDOWN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_EDITUPDATE ; Sent when the edit control portion of a combo box is about to display altered text _DebugPrint("$CBN_EDITUPDATE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_ERRSPACE ; Sent when a combo box cannot allocate enough memory to meet a specific request _DebugPrint("$CBN_ERRSPACE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_KILLFOCUS ; Sent when a combo box loses the keyboard focus _DebugPrint("$CBN_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box _DebugPrint("$CBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; Select Item ;_GUICtrlComboBox_SetCurSel($ComboBox, _GUICtrlComboBox_GetCurSel($ComboBox)) ; no return value Case $CBN_SELENDCANCEL ; Sent when the user selects an item, but then selects another control or closes the dialog box _DebugPrint("$CBN_SELENDCANCEL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_SELENDOK ; Sent when the user selects a list item, or selects an item and then closes the list _DebugPrint("$CBN_SELENDOK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $CBN_SETFOCUS ; Sent when a combo box receives the keyboard focus _DebugPrint("$CBN_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint It's buried somewhere in this forum...
    4 points
  8. Uploaded a fix for that issue to Beta Tidy v 25.205.1420.6
    4 points
  9. I've created a label based solution for a simple status bar. May be it's interesting 4u. https://github.com/BugFix/AutoIt-Scripts/blob/main/Statusbar/statusbar_small.md#gallery
    3 points
  10. Using Melba23 post here as a guide (Thanks for the enlightenment) I managed to get this far A Autocomplete selector for existing tags #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <WinAPI.au3> #include <GuiListBox.au3> ; Global Variables Global $g_hMainGUI Global $g_idEditInputTags Global $g_idListboxSuggestions Global $g_hListboxSuggestionsHWND Global $g_aAvailableTags Global $g_iCurrentSuggestionIndex = -1 ; Dummy control IDs for accelerators (Listbox Navigation Key) Global $g_idAccelUp, $g_idAccelDown, $g_idAccelEnter, $g_idAccelEscape ; Load all unique tags from database $g_aAvailableTags = _GetAllUniqueTags() If @error Then MsgBox(16, "Error", "Failed to load unique tags from database.") _CreateGUI() ; Create Main GUI Exit ;--------------------------------------------------------------------------------------- Func _GetAllUniqueTags() ; This function should retrieve your actual unique tags from a database or file. ; For demonstration, it reads words from a text file. Local $sString = StringLower(FileRead("C:\Program Files (x86)\AutoIt3\SciTE\SciTE Jump\License.txt")) ; matches sequences of letters that are at least 4 characters long Local $aWords = StringRegExp($sString, '[a-zA-Z]{4,}', 3) $aWords = _ArrayUnique($aWords) ; This removes the count element from the array returned by StringRegExp with flag 3. If UBound($aWords) > 0 Then _ArrayDelete($aWords, 0) _ArraySort($aWords) Return $aWords EndFunc ;==>_GetAllUniqueTags ;--------------------------------------------------------------------------------------- Func _CreateGUI() $g_hMainGUI = GUICreate("Main GUI", 700, 300) GUICtrlCreateLabel("Title:", 10, 20, 50, 20) Local $idTitle = GUICtrlCreateInput("", 70, 20, 600, 25) GUICtrlCreateLabel("Tags:", 10, 60, 50, 20) $g_idEditInputTags = GUICtrlCreateInput("", 70, 60, 600, 25, $ES_AUTOVSCROLL) GUICtrlSetLimit($g_idEditInputTags, 250) Local $aPos = ControlGetPos($g_hMainGUI, "", $g_idEditInputTags) If @error Then Exit MsgBox(16, "Error", "Failed to get position of Tags input control. Exiting.") ; Suggestions Listbox $g_idListboxSuggestions = GUICtrlCreateList("", $aPos[0], $aPos[1] + $aPos[3], $aPos[2], 150, BitOR($LBS_NOTIFY, $WS_VSCROLL, $WS_BORDER, $WS_TABSTOP)) GUICtrlSetState($g_idListboxSuggestions, $GUI_HIDE) $g_hListboxSuggestionsHWND = GUICtrlGetHandle($g_idListboxSuggestions) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND_Handler") GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL_Handler") $g_idAccelUp = GUICtrlCreateDummy() $g_idAccelDown = GUICtrlCreateDummy() $g_idAccelEnter = GUICtrlCreateDummy() $g_idAccelEscape = GUICtrlCreateDummy() Local $AccelKeys[4][2] = [ _ ["{UP}", $g_idAccelUp], _ ["{DOWN}", $g_idAccelDown], _ ["{ENTER}", $g_idAccelEnter], _ ["{ESCAPE}", $g_idAccelEscape] _ ] GUISetAccelerators($AccelKeys) Local $idExit = GUICtrlCreateButton("Exit", 300, 250, 100, 30) GUISetState(@SW_SHOW) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE, $idExit ExitLoop Case $g_idAccelUp _ListboxNavigationKey($g_idAccelUp) Case $g_idAccelDown _ListboxNavigationKey($g_idAccelDown) Case $g_idAccelEnter _ListboxNavigationKey($g_idAccelEnter) Case $g_idAccelEscape _ListboxNavigationKey($g_idAccelEscape) EndSwitch WEnd GUIDelete($g_hMainGUI) EndFunc ;==>_CreateGUI ;--------------------------------------------------------------------------------------- Func _ApplySelectedTag($sSelectedTag) If $sSelectedTag = "" Then Return Local $sCurrentTags = GUICtrlRead($g_idEditInputTags) If @error Then Return Local $iLastCommaPos = StringInStr($sCurrentTags, ",", 0, -1) ; Find the last comma Local $sPrefixToKeep = "" If $iLastCommaPos > 0 Then $sPrefixToKeep = StringLeft($sCurrentTags, $iLastCommaPos) $sPrefixToKeep = StringStripWS($sPrefixToKeep, $STR_STRIPTRAILING) & " " EndIf Local $sNewTags = $sPrefixToKeep & $sSelectedTag & ", " GUICtrlSetData($g_idEditInputTags, $sNewTags) If @error Then Return _HideSuggestions() GUICtrlSetState($g_idEditInputTags, $GUI_FOCUS) If @error Then Return _WinAPI_PostMessage(GUICtrlGetHandle($g_idEditInputTags), $EM_SETSEL, StringLen($sNewTags), StringLen($sNewTags)) $g_iCurrentSuggestionIndex = -1 EndFunc ;==>_ApplySelectedTag ;--------------------------------------------------------------------------------------- Func _ShowSuggestions($sCurrentInput) Local $sTrimmedInput = StringStripWS($sCurrentInput, $STR_STRIPLEADING + $STR_STRIPTRAILING) If $sTrimmedInput = "" Then Return _HideSuggestions() Local $aInputParts = StringSplit($sTrimmedInput, ",", $STR_NOCOUNT) Local $sLastPart = "" If UBound($aInputParts) > 0 Then $sLastPart = StringStripWS($aInputParts[UBound($aInputParts) - 1], $STR_STRIPLEADING + $STR_STRIPTRAILING) Else $sLastPart = $sTrimmedInput EndIf If $sLastPart = "" Then Return _HideSuggestions() Local $aFilteredSuggestions[0] Local $iCount = 0 Local $iLenLastPart = StringLen($sLastPart) For $sTag In $g_aAvailableTags If $sTag <> "" And StringLen($sTag) >= $iLenLastPart And StringLeft($sTag, $iLenLastPart) = $sLastPart Then _ArrayAdd($aFilteredSuggestions, $sTag) $iCount += 1 EndIf Next If $iCount > 0 Then GUICtrlSendMsg($g_idListboxSuggestions, $LB_RESETCONTENT, 0, 0) For $sSuggestion In $aFilteredSuggestions If $sSuggestion <> "" Then GUICtrlSendMsg($g_idListboxSuggestions, $LB_ADDSTRING, 0, $sSuggestion) EndIf Next GUICtrlSetState($g_idListboxSuggestions, $GUI_SHOW) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETCURSEL, 0, 0) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETTOPINDEX, 0, 0) $g_iCurrentSuggestionIndex = 0 Else _HideSuggestions() EndIf EndFunc ;==>_ShowSuggestions ;--------------------------------------------------------------------------------------- Func _HideSuggestions() GUICtrlSetState($g_idListboxSuggestions, $GUI_HIDE) GUICtrlSendMsg($g_idListboxSuggestions, $LB_RESETCONTENT, 0, 0) $g_iCurrentSuggestionIndex = -1 EndFunc ;==>_HideSuggestions ;--------------------------------------------------------------------------------------- Func _ListboxNavigationKey($idKey) If Not BitAND(GUICtrlGetState($g_idListboxSuggestions), $GUI_SHOW) Then Return Local $iCount = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCOUNT, 0, 0) If $iCount = 0 Then Return Switch $idKey Case $g_idAccelUp If $g_iCurrentSuggestionIndex <= 0 Then $g_iCurrentSuggestionIndex = $iCount - 1 Else $g_iCurrentSuggestionIndex -= 1 EndIf GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETCURSEL, $g_iCurrentSuggestionIndex, 0) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETTOPINDEX, $g_iCurrentSuggestionIndex, 0) Case $g_idAccelDown If $g_iCurrentSuggestionIndex >= $iCount - 1 Then $g_iCurrentSuggestionIndex = 0 Else $g_iCurrentSuggestionIndex += 1 EndIf GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETCURSEL, $g_iCurrentSuggestionIndex, 0) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETTOPINDEX, $g_iCurrentSuggestionIndex, 0) Case $g_idAccelEnter Local $iIndex = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCURSEL, 0, 0) If $iIndex <> $LB_ERR Then Local $sSelectedTag = _GUICtrlListBox_GetText($g_idListboxSuggestions, $iIndex) If $sSelectedTag <> "" Then _ApplySelectedTag($sSelectedTag) EndIf Else _HideSuggestions() EndIf $g_iCurrentSuggestionIndex = -1 Case $g_idAccelEscape _HideSuggestions() $g_iCurrentSuggestionIndex = -1 EndSwitch EndFunc ;==>_ListboxNavigationKey ;--------------------------------------------------------------------------------------- Func _WM_COMMAND_Handler($hWnd, $iMsg, $wParam, $lParam) Local $iControlID = _WinAPI_LoWord($wParam) Local $iNotificationCode = _WinAPI_HiWord($wParam) Switch $iMsg Case $WM_COMMAND Switch $iControlID Case $g_idEditInputTags Switch $iNotificationCode Case $EN_CHANGE Local $sCurrentInput = GUICtrlRead($g_idEditInputTags) _ShowSuggestions($sCurrentInput) Case $EN_KILLFOCUS Sleep(50) Local $hFocusedWindow = _WinAPI_GetFocus() Local $hListboxSuggestionsHandle = GUICtrlGetHandle($g_idListboxSuggestions) Local $hEditInputTagsHandle = GUICtrlGetHandle($g_idEditInputTags) If $hFocusedWindow <> $hListboxSuggestionsHandle And $hFocusedWindow <> $hEditInputTagsHandle Then _HideSuggestions() Local $sCurrentTags = GUICtrlRead($g_idEditInputTags) If StringRight($sCurrentTags, 2) = ", " Then GUICtrlSetData($g_idEditInputTags, StringTrimRight($sCurrentTags, 2)) ElseIf StringRight($sCurrentTags, 1) = "," Then GUICtrlSetData($g_idEditInputTags, StringTrimRight($sCurrentTags, 1)) EndIf EndIf EndSwitch Case $g_idListboxSuggestions Switch $iNotificationCode Case $LBN_SELCHANGE Local $iIndex = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCURSEL, 0, 0) If $iIndex <> $LB_ERR Then Local $sSelectedTag = _GUICtrlListBox_GetText($g_idListboxSuggestions, $iIndex) If $sSelectedTag <> "" Then _ApplySelectedTag($sSelectedTag) EndIf EndIf Case $LBN_DBLCLK Local $iIndex = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCURSEL, 0, 0) If $iIndex <> $LB_ERR Then Local $sSelectedTag = _GUICtrlListBox_GetText($g_idListboxSuggestions, $iIndex) If $sSelectedTag <> "" Then _ApplySelectedTag($sSelectedTag) EndIf EndIf EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND_Handler ;--------------------------------------------------------------------------------------- Func _WM_MOUSEWHEEL_Handler($hWnd, $iMsg, $wParam, $lParam) ; Using GUIGetCursorInfo to find the control under the mouse Local $aCursorInfo = GUIGetCursorInfo($g_hMainGUI) ; Check if the mouse is over the suggestions ListBox and if the ListBox is visible If Not @error And IsArray($aCursorInfo) And UBound($aCursorInfo) >= 5 And $aCursorInfo[4] = $g_idListboxSuggestions And BitAND(GUICtrlGetState($g_idListboxSuggestions), $GUI_SHOW) Then Local $iDelta = _WinAPI_HiWord($wParam) ; How much the wheel turned (120 for a "click" up, -120 for a "click" down) Local $iNumLinesToScroll = 1 ; We scroll one line at a time with the wheel Local $iCurrentSelection = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCURSEL, 0, 0) Local $iTotalItems = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCOUNT, 0, 0) If $iTotalItems <= 0 Then Return 1 ; No items, nothing to scroll or select If $iDelta > 0 Then ; Scroll Up (wheel up) If $iCurrentSelection > 0 Then $g_iCurrentSuggestionIndex = $iCurrentSelection - $iNumLinesToScroll If $g_iCurrentSuggestionIndex < 0 Then $g_iCurrentSuggestionIndex = 0 Else $g_iCurrentSuggestionIndex = 0 ; Already at the top EndIf Else ; Scroll Down (wheel down) If $iCurrentSelection < $iTotalItems - 1 Then $g_iCurrentSuggestionIndex = $iCurrentSelection + $iNumLinesToScroll If $g_iCurrentSuggestionIndex >= $iTotalItems Then $g_iCurrentSuggestionIndex = $iTotalItems - 1 Else $g_iCurrentSuggestionIndex = $iTotalItems - 1 ; Already at the bottom EndIf EndIf ; We define the new option GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETCURSEL, $g_iCurrentSuggestionIndex, 0) ; Also, make the selected element visible (if it isn't already) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETTOPINDEX, $g_iCurrentSuggestionIndex, 0) Return 1 ; Message has been handled EndIf Return $GUI_RUNDEFMSG ; Let AutoIt handle the message for other controls EndFunc ;==>_WM_MOUSEWHEEL_Handler Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    3 points
  11. I tried to add these 2 controls (combo & input box) to my script found in this post with good results, on a maximizable / resizable GUI : These are the lines modified / added to the script, so you can try them too : 1) Lines modified : ; Local $iW = 300, $iH = 100 Local $iW = 600, $iH = 200 ; Local $aParts[3] = [90, 180, 280] Local $aParts[3] = [200, 400, 580] ; Local $idChangeText = GUICtrlCreateLabel("Change Text", 110, 25, 80, 30, $SS_CENTER + $SS_CENTERIMAGE), $iInc Local $idChangeText = GUICtrlCreateLabel("Change Text", $iW / 2 - 40, 50, 80, 30, $SS_CENTER + $SS_CENTERIMAGE), $iInc 2) Lines added : #include <ComboConstants.au3> ... Local $idComboBox = GUICtrlCreateCombo("Install", 100, 180, 100, 18, $CBS_DROPDOWNLIST) GUICtrlSetData($idComboBox, "Uninstall") GUICtrlSetBkColor(-1, 0xFF0000) ; red _WinAPI_SetParent(GUICtrlGetHandle($idComboBox), $g_hGUI) Local $idInput = GUICtrlCreateInput("Input in part 1", 300, 181, 100, 18) GUICtrlSetBkColor(-1, 0x00FF00) ; green _WinAPI_SetParent(GUICtrlGetHandle($idInput), $g_hGUI) * Please create $idComboBox and $idInput just after the label $idChangeText * IIRC your StatusBar height got a higher value, so you'll probably have to lower a bit the Y coord of both controls * Lucky me, I tried the _WinAPI_SetParent() on each control (combo & input), indicating... the GUI as parent and it "woke" them up both. Without this instruction, they didn't react, as you indicated. Hope it will work on your side, fingers crossed
    3 points
  12. WildByDesign

    DwmColorBlurMica

    I promised myself that I was not going to make another GUI because the attention to detail drives me a little crazy. 🙃 But here we are. This was especially complicated because I wanted to make a GUI that was 100% receptive to the features that DwmColorBlurMica represents. It had to have transparent controls to show the underlying backdrop material (Mica, Acrylic, Blur, etc.) through the controls. This meant making custom ComboBox because AutoIt ComboBox are not normally transparent. Anyway, I think I am around 50% complete with the GUI. Below is a W.I.P. screenshot of where I am at right now: It works better than I expected. There are color pickers too. I will probably get rid of the menubar. I will likely add a custom transparent statusbar to show all of the Global settings to compare to the per-app settings. Lots of things to consider still. I hate making GUIs.
    3 points
  13. Updated to WebP v0.3.7 build 2025-07-03 beta You can now create WebP anim files from WebP image files and you can extract frames from a WebP anim file to WebP image file format. Supported GDIPlus image formats: "bmp", "gif", "jpg", "tif", "png"
    3 points
  14. Updated to: WebP v0.3.5 build 2025-06-27 beta You can now create WebP animated files. Examples8 encodes GDI+ supported image files to an animation. Example9 captures the desktop screen to an WebP anim file.
    3 points
  15. You can simply try this code: It uses GDI+ to draw a red circle with centered text, creates a 32-bit ARGB icon, and sets it as a taskbar overlay using ITaskbarList3::SetOverlayIcon. It updates the icon every second. You can easily adjust it to fit your own needs. Let me know if it works for you! #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPIIcons.au3> Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " Line: " & $oError.scriptline & " - " & $oError.windescription & @CRLF) EndFunc ; Define ITaskbarList3 COM interface Global Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" Global Const $sIID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" Global Const $tagITaskbarList3 = _ "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" & _ "MarkFullscreenWindow hresult(hwnd;boolean);" & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" ; Global variables Global $hGraphic, $hTextBrush, $hFormat, $hFamily, $hFont, $hBackgroundBrush, $hPen Global $oList, $hWnd Global $iWidth = 32, $iHeight = 32, $iFontSize = 12 Global $iCounter = 0 Main() Func Main() _GDIPlus_Startup() $hWnd = GUICreate("Taskbar Overlay Icon Test", 400, 300) Local $label = GUICtrlCreateLabel("Starting...", 10, 10, 380, 100) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) $hTextBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize) $hBackgroundBrush = _GDIPlus_BrushCreateSolid(0xFFFF0000) $hPen = _GDIPlus_PenCreate(0xFF000000, 2) $oList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $tagITaskbarList3) If Not IsObj($oList) Then MsgBox(16, "Error", "Failed to initialize ITaskbarList3.") Exit EndIf $oList.HrInit() If @error Then MsgBox(16, "Error", "HrInit failed: " & @error) Exit EndIf GUICtrlSetData($label, "$oList.AddTab") $oList.AddTab($hWnd) If @error Then MsgBox(16, "Error", "Failed to add taskbar tab: " & @error) Exit EndIf _UpdateOverlayIcon($iCounter) GUICtrlSetData($label, "Overlay icon initialized with counter: " & $iCounter) Local $hTimer = TimerInit() While 1 If TimerDiff($hTimer) > 1000 Then $iCounter += 1 If $iCounter > 99 Then $iCounter = 99 _UpdateOverlayIcon($iCounter) GUICtrlSetData($label, "Counter: " & $iCounter) $hTimer = TimerInit() EndIf If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop Sleep(10) WEnd GUICtrlSetData($label, "Removing overlay icon and tab") _Taskbar_SetOverlayIcon($oList, $hWnd, Null, "") $oList.DeleteTab($hWnd) $oList = 0 _GDIPlus_FontDispose($hFont) _GDIPlus_PenDispose($hPen) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hTextBrush) _GDIPlus_BrushDispose($hBackgroundBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc Func _UpdateOverlayIcon($iCount) Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $GDIP_PXF32ARGB) Local $hGraphicBitmap = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphicBitmap, 2) _GDIPlus_GraphicsClear($hGraphicBitmap, 0x00000000) _GDIPlus_GraphicsFillEllipse($hGraphicBitmap, 0, 0, $iWidth - 2, $iHeight - 2, $hBackgroundBrush) _GDIPlus_GraphicsDrawEllipse($hGraphicBitmap, 0, 0, $iWidth - 2, $iHeight - 2, $hPen) Local $tLayout = _GDIPlus_RectFCreate(2, 2, $iWidth - 4, $iHeight - 8) DrawStringCentered($hGraphicBitmap, $iCount, $hFont, $tLayout, $hFormat, $hTextBrush) Local $hIcon = _GDIPlus_HICONCreateFromBitmap($hBitmap) If @error Then MsgBox(16, "Error", "Failed to create HICON: " & @error) Exit EndIf _Taskbar_SetOverlayIcon($oList, $hWnd, $hIcon, "Counter: " & $iCount) _WinAPI_DestroyIcon($hIcon) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphicBitmap) EndFunc Func DrawStringCentered($hGraphic, $iIndex, $hFont, $tLayout, $hFormat, $hTextBrush) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $iIndex, $hFont, $tLayout, $hFormat) Local $tIndex = $aInfo[0] $tIndex.X = $tLayout.X + (($tLayout.Width - $tIndex.Width) / 2) $tIndex.Y = $tLayout.Y + (($tLayout.Height - _GDIPlus_FontGetHeight($hFont, $hGraphic)) / 2) _GDIPlus_GraphicsDrawStringEx($hGraphic, $iIndex, $hFont, $tIndex, $hFormat, $hTextBrush) EndFunc Func _Taskbar_SetOverlayIcon(ByRef $oTB, $hWnd, $hIcon, $sAltText = "") Local $vRet = $oTB.SetOverlayIcon($hWnd, $hIcon, $sAltText) If @error Then Return SetError(@error, @extended, False) If $vRet = 0 Then Return True Return SetError($vRet, 0, False) EndFunc
    3 points
  16. I have thought again and this is simpler and the better solution. #NoTrayIcon ;#RequireAdmin #include <WinAPISys.au3> #include <GDIPlus.au3> #include <WinAPIShellEx.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> Example() Func Example() Local $hGUI, $hGraphic, $hIcon, $hBitmap, $iX = 768, $iY = 525 $hGUI = GUICreate("GDI+", $iX, $iY) _GDIPlus_Startup() ; Create GUI Global $idPic = GUICtrlCreatePic("", 0, 0, $iX, $iY) Global $sFileName = @ScriptDir& "\MAIN.png" $hImage = _GDIPlus_ImageLoadFromFile($sFileName) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) $hBGImage = _GDIPlus_BitmapCreateFromScan0($iX, $iY) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBGImage) _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0) $btnx = 250 $btny = 150 ;_GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 221, 48, 48) $hBitmap = _GDIPlus_BitmapCreateFromHICON32($hIcon) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, $btnx, $btny) $shBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBGImage) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, 0x0172, 0, $shBitmap)) ; STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 GUICtrlSetState($idPic, $gui_disable) GUICtrlSetState(-1, $GUI_ONTOP) GUICtrlSetCursor(-1, 0) $hIcon = GUICtrlCreateIcon(@SystemDir & '\shell32.dll', -1, $btnx, $btny, 48, 48, BitOR($SS_NOTIFY, $SS_BLACKRECT)) GUISetState() ; Loop until user exits Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hIcon ConsoleWrite("Icon clicked" & @CRLF) EndSwitch Until False ; Clean up resources _WinAPI_DestroyIcon($hIcon) _WinAPI_DeleteObject($shBitmap) _GDIPlus_BitmapDispose($hImage) _GDIPlus_BitmapDispose($hBGImage) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example
    3 points
  17. ioa747

    _Msg

    _Msg($iUI, $sText, $sTitle = @ScriptName, $iTimeout = 3, $iOption = 0) Displays a message using different UI elements based on the specified $iUI parameter. ; https://www.autoitscript.com/forum/topic/212945-_msg/ #include <MsgBoxConstants.au3> #include <TrayConstants.au3> #include <AutoItConstants.au3> ; #FUNCTION# ==================================================================================================================== ; Name...........: _Msg ; Description....: Displays a message using different UI elements based on the specified $iUI parameter. ; Syntax.........: _Msg($iUI, $sText, $sTitle = @ScriptName, $iTimeout = 3, $iOption = 0) ; Parameters.....: $iUI - Specifies the UI element to use: ; 0 - Return - nothing ; 1 - ConsoleWrite ; 2 - MsgBox ; 3 - ToolTip ; 4 - TrayTip ; $sText - The message text to be displayed. ; $sTitle - [optional] The title of the UI element. (Default is @ScriptName) ; $iTimeout - [optional] Timeout in seconds for displaying the message. (Default is 3) ; $iOption - [optional] Options for MsgBox, ToolTip, and TrayTip. (Default is 0) ; Return values .: Success: No specific return value, function exits after display. ; Failure: None ; Example .......: _Msg(1, "Hello, this is a test message.", @ScriptName, 5) ; =============================================================================================================================== Func _Msg($iUI, $sText, $sTitle = Default, $iTimeout = 3, $iOption = 0) If $sTitle = Default Then $sTitle = @ScriptName Switch $iUI Case 0 ; ### 0 Return - Does nothing, just exits the function. Return Case 1 ; ### 1 ConsoleWrite ConsoleWrite($sTitle & ": " & $sText & @CRLF) Case 2 ; ### 2 MsgBox MsgBox($iOption, $sTitle, $sText, $iTimeout) Case 3 ; ### 3 ToolTip ToolTip($sText, Default, Default, $sTitle, $iOption) Sleep($iTimeout * 1000) ; ToolTip doesn't have built-in timeout, so we use Sleep ToolTip("") ; Clear the tooltip after the timeout Case 4 ; ### 4 TrayTip TrayTip($sTitle, $sText, $iTimeout, $iOption) Sleep($iTimeout * 1000) ; give time to display it Case Else ; ### Else case - Does nothing, just exits the function. Return EndSwitch EndFunc ;==>_Msg ; Example Usage of _Msg Function ; ### ConsoleWrite ############################################### ; ConsoleWrite Example _Msg(1, "This message appears in the AutoIt console.", "Console Output") ; ConsoleWrite Example - Information-sign icon consisting of an 'i' in a circle _Msg(1, "This is an informational message.", "> Info") ; ConsoleWrite Example - Stop-sign icon _Msg(1, "This is a error message.", "! Error") ; ConsoleWrite Example - Question-mark icon _Msg(1, "This is a question message.", "+ Question") ; ConsoleWrite Example - Exclamation-point icon _Msg(1, "This is a warning message.", "- Warning") ; ### MsgBox ############################################### ; MsgBox Example - Information-sign icon consisting of an 'i' in a circle _Msg(2, "This is an informational message box.", "Info", 3, $MB_ICONINFORMATION) ; MsgBox Example - Stop-sign icon _Msg(2, "This is a error message box.", "Error", 3, $MB_ICONERROR) ; MsgBox Example - Question-mark icon _Msg(2, "This is a question message box.", "Question", 3, $MB_ICONQUESTION) ; MsgBox Example - Exclamation-point icon _Msg(2, "This is a warning message box.", "Warning", 3, $MB_ICONWARNING) ; ### ToolTip ############################################### ; ToolTip Example - no icon _Msg(3, "This is a question ToolTip.", "noicon", 3, $TIP_NOICON) ; ToolTip Example - Information-sign icon consisting of an 'i' in a circle _Msg(3, "This is an informational ToolTip.", "Info", 3, $TIP_INFOICON) ; ToolTip Example - error icon _Msg(3, "This is a error ToolTip.", "Error", 3, $TIP_ERRORICON) ; ToolTip Example - Warning icon _Msg(3, "This is a warning ToolTip.", "Warning", 3, $TIP_WARNINGICON) ; ### TrayTip ############################################### ; TrayTip Example - no icon _Msg(4, "This is a question TrayTip.", "noicon", 3, $TIP_ICONNONE) ; TrayTip Example - Information-sign icon consisting of an 'i' in a circle _Msg(4, "This is an informational TrayTip.", "Info", 3, $TIP_ICONASTERISK) ; TrayTip Example - error icon _Msg(4, "This is a error TrayTip.", "Error", 3, $TIP_ICONHAND) ; TrayTip Example - Warning icon _Msg(4, "This is a warning TrayTip.", "Warning", 3, $TIP_ICONEXCLAMATION) ; ################################################## ; Return Example (does nothing visible) _Msg(0, "This message will not be displayed.", "No Output") ; MsgBox Example $iTimeout = 0 _Msg(2, "All message examples have been executed.", "Examples Finished", 0)
    3 points
  18. Hey guys. Sorry for the lapse in updates. Been pecking away little by little at some RPG stuff, slow progress but still progress. Situation with my daughter is nearing it's foreseeable end, she'll be home in a couple weeks and once she gets settled in and the final motions are filed things will ease up greatly and I'll be able to focus more on RPG stuff and programming stuff in general. I've been jotting things down and working on some little things lately as I've been very busy in life lately, but its been for a good cause and worth the effort! Do not worry, I've not stopped or forgotten about RPGenerator! Just been slow moving as I've had to move this project down my priority list more than I anticipated.
    3 points
  19. This works on my Win10 machine. #include <GUIConstantsEx.au3> #include <WinApi.au3> #include <WindowsConstants.au3> Global $hDeskWin = _WinGetDesktopHandle() Global $h_Desktop_SysListView32 = HWnd(@extended) Main() Func Main() Local $this = GUICreate("", 400, 400, @DesktopWidth - (400) - 20, 100, $WS_POPUP, $WS_EX_NOACTIVATE + $WS_EX_TRANSPARENT) _WinAPI_SetParent($this, $h_Desktop_SysListView32) Local $iPic = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 400, 400) ;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) WinSetTrans($this, "", 200) _GuiRoundCorners($this, 16, 16) _WinAPI_SetWindowLong($this, $GWL_HWNDPARENT, ControlGetHandle("[CLASS:Progman]", "", "SysListView321")) ;hide in taskbar GUISetState(@SW_SHOWNOACTIVATE, $this) ;_WinAPI_SetWindowPos($this, $HWND_BOTTOM, Default, Default, Default, Default, BitOR($SWP_NOACTIVATE, $SWP_SHOWWINDOW, $SWP_NOMOVE, $SWP_NOSIZE )) ;not worked While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($this) EndFunc ;==>Main Func _GuiRoundCorners($h_win, $ixR, $iyR) Local $aPos = WinGetPos($h_win) If @error Then Return 0 Local $iW = $aPos[2] Local $iH = $aPos[3] Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, $ixR, $iyR) _WinAPI_SetWindowRgn($h_win, $hRgn) EndFunc ;==>_GuiRoundCorners ; http://www.autoitscript.com/forum/topic/119783-desktop-class-workerw/page__view__findpost__p__903081 ; =============================================================================================================================== ; <_WinGetDesktopHandle.au3> ; ; Function to get the Windows' Desktop Handle. ; Since this is no longer a simple '[CLASS:Progman]' on Aero-enabled desktops, this method uses a slightly ; more involved method to find the correct Desktop Handle. ; ; Author: Ascend4nt, credits to Valik for pointing out the Parent->Child relationship: Desktop->'SHELLDLL_DefView' ; =============================================================================================================================== ; Example use: #cs #include <GuiListView.au3> $iTimer = TimerInit() $hDeskWin = _WinGetDesktopHandle() $hListView = HWnd(@extended) ConsoleWrite("Time elapsed:" & TimerDiff($iTimer) & " ms" & @CRLF) $iDeskItems = _GUICtrlListView_GetItemCount($hListView) ConsoleWrite("Handle to desktop: " & $hDeskWin & ", Title: '" & WinGetTitle($hDeskWin) & "', Handle to Listview: " & $hListView & ", # Items:" & $iDeskItems & ", Title: " & WinGetTitle($hListView) & @CRLF) MsgBox(0, "Desktop handle (with ListView) found", "Handle to desktop: " & $hDeskWin & ", Title: '" & WinGetTitle($hDeskWin) & "'," & @CRLF & "Handle to Listview: " & $hListView & @CRLF & "# Desktop Items:" & $iDeskItems) #ce Func _WinGetDesktopHandle() Local $i, $hDeskWin, $hSHELLDLL_DefView, $hListView ; The traditional Windows Classname for the Desktop, not always so on newer O/S's $hDeskWin = WinGetHandle("[CLASS:Progman]") ; Parent->Child relationship: Desktop->SHELLDLL_DefView $hSHELLDLL_DefView = ControlGetHandle($hDeskWin, '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]') ; No luck with finding the Desktop and/or child? If $hDeskWin = '' Or $hSHELLDLL_DefView = '' Then ; Look through a list of WorkerW windows - one will be the Desktop on Windows 7+ O/S's $aWinList = WinList("[CLASS:WorkerW]") For $i = 1 To $aWinList[0][0] $hSHELLDLL_DefView = ControlGetHandle($aWinList[$i][1], '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]') If $hSHELLDLL_DefView <> '' Then $hDeskWin = $aWinList[$i][1] ExitLoop EndIf Next EndIf ; Parent->Child relationship: Desktop->SHELDLL_DefView->SysListView32 $hListView = ControlGetHandle($hSHELLDLL_DefView, '', '[CLASS:SysListView32; INSTANCE:1]') If $hListView = '' Then Return SetError(-1, 0, '') Return SetExtended($hListView, $hDeskWin) EndFunc ;==>_WinGetDesktopHandle
    2 points
  20. This did it. This solved my problem. It's funny, too, because _WinAPI_SetParent() was problematic at one point causing issues by destroying the theming. And now here comes _WinAPI_SetParent() to save the day by restoring the lovely theming. It blows my mind! Thank you so much for your help and for your time with this. I appreciate it, as always. You've saved me a few times now already. Now I can move on to the not-so-fun DPI awareness control sizing stuff.
    2 points
  21. ...so, yes. It should work everywhere. When he claimed that something changed drastically ( not sure what ) I jumped into getting the latest to test and not make a fool of my self calling Bill to give him a piece of my mind !. Fortunately, I didn't have to 😇
    2 points
  22. Hi @pixelsearch thank again for your feedback. Regarding 1) my bad. The example 08 doesn't contain a check if creation fails - it just proceeds. Easy to fix: Global $sFile = @ScriptDir & "\TestAnim.webp" Global $iResult = WebP_CreateWebPCreateAnim($aFrames, $sFile) If $iResult < 1 Or @error Then ConsoleWrite($iResult & " / " & @error & @CRLF) _GDIPlus_Shutdown() Exit MsgBox($MB_ICONERROR, "Error", "Something went wrong creating the animation!") EndIf 2) to be honest - I'm too lazy to create a GUI with all parameters. I'm not sure if all the parameters are required or will ever be needed, but I'm happy to include this as Example08.1.au3. It would only make sense if the value range per parameter was listed in the GUI. The ranges should be described in the UDF header.
    2 points
  23. Updated to v0.3.8 build 2025-07-04 beta added loop count parameter for the 3 animation functions. Default = 0 which is endless. added WebP_GetImagesDiffFromFile() which can compare two WebP files which same dimension
    2 points
  24. There are some great responses and creative ideas here. Thank you all so much. I apologize for my delay in responding. I hope that I don’t seem rude for the delay. I had moved forward with other parts of the GUI while my mind (and ideas) was fresh. Later today I am going to return to this important part of my GUI and I will try the various ideas. Once I get a chance to try them, I will respond here to each of your ideas. As always, I am grateful for your time and your help.
    2 points
  25. following the instructions of argumentum I got this far #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Global $g_idListView Global $g_bListViewVisible = False Global $g_InputCombo _MainGUI() Func _MainGUI() Local $hGUI = GUICreate("fake combo", 364, 250) Local $iX = 65, $iY = 30, $iW = 150, $iH = 21 ; fake combo $g_InputCombo = GUICtrlCreateInput("", $iX, $iY, $iW, $iH) Local $idBtnCombo = GUICtrlCreateButton("🔻", $iX + $iW, $iY - 1, $iH + 2, $iH + 2) ; ListView $g_idListView = GUICtrlCreateListView("", $iX, $iY + $iH, $iW + $iH, 180, BitOR($LVS_NOCOLUMNHEADER, $LVS_REPORT), BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_TRACKSELECT)) GUICtrlSetState($g_idListView, $GUI_HIDE) ; hidden ; Add columns _GUICtrlListView_AddColumn($g_idListView, "", $iW) ; Enable group view _GUICtrlListView_EnableGroupView($g_idListView) ; Group 1 _GUICtrlListView_InsertGroup($g_idListView, -1, 1, "Fruits") _GUICtrlListView_AddItem($g_idListView, "Apple") _GUICtrlListView_SetItemGroupID($g_idListView, _GUICtrlListView_GetItemCount($g_idListView) - 1, 1) _GUICtrlListView_AddItem($g_idListView, "Banana") _GUICtrlListView_SetItemGroupID($g_idListView, _GUICtrlListView_GetItemCount($g_idListView) - 1, 1) ; Group 2 _GUICtrlListView_InsertGroup($g_idListView, -1, 2, "Vegetables") _GUICtrlListView_AddItem($g_idListView, "Carrot") _GUICtrlListView_SetItemGroupID($g_idListView, _GUICtrlListView_GetItemCount($g_idListView) - 1, 2) _GUICtrlListView_AddItem($g_idListView, "Spinach") _GUICtrlListView_SetItemGroupID($g_idListView, _GUICtrlListView_GetItemCount($g_idListView) - 1, 2) ; Group 3 _GUICtrlListView_InsertGroup($g_idListView, -1, 3, "Dairy") _GUICtrlListView_AddItem($g_idListView, "Milk") _GUICtrlListView_SetItemGroupID($g_idListView, _GUICtrlListView_GetItemCount($g_idListView) - 1, 3) ; Register the message handler GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idBtnCombo ; Toggle ListView visibility If Not $g_bListViewVisible Then GUICtrlSetState($g_idListView, $GUI_SHOW + $GUI_FOCUS) $g_bListViewVisible = True Else GUICtrlSetState($g_idListView, $GUI_HIDE) $g_bListViewVisible = False EndIf EndSwitch WEnd EndFunc ;==>_MainGUI ;--------------------------------------------------------------------------------------- Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndListView = GUICtrlGetHandle($g_idListView) Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK Local $iIndex = _GUICtrlListView_GetSelectionMark($g_idListView) ; Get the index of the last selected item ; Ensure a valid item was selected If $iIndex <> -1 Then Local $sItemText = _GUICtrlListView_GetItemText($g_idListView, $iIndex, 0) If $sItemText <> "" Then GUICtrlSetData($g_InputCombo, $sItemText) GUICtrlSetState($g_idListView, $GUI_HIDE) GUICtrlSetState($g_InputCombo, $GUI_FOCUS) $g_bListViewVisible = False EndIf EndIf Return 0 Case $NM_DBLCLK Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;--------------------------------------------------------------------------------------- Edit: Normally it would require handling $WM_KILLFOCUS and keyboard navigation, but the code would grow. Just the central idea
    2 points
  26. Hello everyone, I'm pleased to share a UDF I developed to work with IWICImagingFactory from the Windows Imaging Component (WIC), focused exclusively on reading and writing image metadata. 🔍 Why this UDF? IWICImagingFactory is a powerful API but can also be particularly confusing when working with metadata. Its layers of abstraction, data formats, and interface complexity can easily distract you from your goals without a clear structure. 🧩 Key Features: 🔄 Read and write metadata using WIC interfaces (IWICMetadataQueryReader, IWICMetadataQueryWriter) 💾 Supports common formats (JPEG, PNG, TIFF, etc.) 🧠 Built using an object-oriented model via AutoItObject to encapsulate complexity and avoid side effects ⚠️ Full support for PROPVARIANT and VARIANT types, essential for COM interaction 🔗 Handles the WIC metadata query language (e.g., /app1/ifd/exif:{ushort=36867} for Date Taken) 📜 Works with WIC-compliant hierarchical metadata queries 🧠 Prerequisites / Recommended Knowledge Solid understanding of COM programming in AutoIt Familiarity with PROPVARIANT/VARIANT (types, conversion, init/cleanup) Knowledge of WIC metadata schema and hierarchy Comfortable with object-oriented programming in AutoIt (using AutoItObject) 🧪 Why use an object-oriented approach? IWICImagingFactory is as flexible as it is tricky. Exploring it directly can lead to unexpected behaviors or technical detours. The object-oriented approach helps contain this complexity, structure features properly, and avoid common pitfalls when dealing with raw COM interfaces. 📁 What’s Included in the UDF A main object WICImageMeta (or similar) that encapsulates the image, reader/writer, and associated interfaces Straightforward methods like .ReadMeta($sPath), .WriteMeta($sPath, $vValue, $sType), .Save($sDest), etc. Automatic resource management (Release, Cleanup) Examples for reading/writing EXIF, XMP, and other metadata 📷 Quick Usage Example #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <Array.au3> #include "IWICImagingMetadata.au3" ; This is your custom UDF for WIC metadata ; Path to a test image (replace with your own file path) Local $sFilename = @DesktopDir & "\screenshot.png" ; === 1. Create the WIC Imaging Factory === ; This is the entry point for all WIC operations Local $oFactory = _WIC_ImagingFactory() If Not IsObj($oFactory) Then MsgBox(0, "Error", "Failed to create WIC Imaging Factory") Exit EndIf ; === 2. Create a decoder from the image file === ; This will analyze the image format and prepare for frame extraction Local $oDecoder = $oFactory.createDecoderFromFileName($sFilename) If Not IsObj($oDecoder) Then MsgBox(0, "Error", "Failed to create image decoder: @error=" & @error) $oFactory = 0 Exit EndIf ; === 3. Get the first frame of the image === ; Most still images have a single frame; this retrieves it from the decoder Local $oFrame = $oFactory.createBitmapFrameDecode($oDecoder) If Not IsObj($oFrame) Then MsgBox($MB_ICONERROR, "Error", "Failed to retrieve image frame: @error=" & @error) $oDecoder = 0 $oFactory = 0 Exit EndIf ; === 4. Get a metadata query reader from the frame === ; This reader allows you to query metadata values using WIC metadata paths Local $oQueryReader = $oFactory.getMetadataQueryReader($oFrame) If Not IsObj($oQueryReader) Then MsgBox(0, "Error", "Failed to get metadata query reader: @error=" & @error) $oFrame = 0 $oDecoder = 0 $oFactory = 0 Exit EndIf ; === 5. Enumerate available metadata names === ; This step is crucial to explore what metadata is actually present. ; It returns an array of metadata query paths that can be used. Local $aNames = $oFactory.enumerateMetaDataNames($oQueryReader) If @error Then ConsoleWrite("Error: Failed to enumerate metadata names: @error=" & @error & @CRLF) Else ConsoleWrite("Available metadata names: " & _ArrayToString($aNames, "|") & @CRLF) EndIf ; === 6. Read a specific metadata value === ; In this case, we're trying to read a textual field: "Creation Time" in a PNG tEXt chunk Local $sQuery = "/tEXt/{str=Creation Time}" Local $vData = $oFactory.queryMetadataByName($oQueryReader, $sQuery) If Not @error Then ConsoleWrite("Metadata read: " & $sQuery & " = " & $vData & @CRLF) Else ConsoleWrite("Error: Failed to read " & $sQuery & " : @error=" & @error & @CRLF) EndIf ; === NOTE === ; If your query selects a metadata **block**, then `vData` may be another IWICMetadataQueryReader object. ; In that case, you must call `queryMetadataByName` again, passing this sub-reader to reach nested values. 💬 Conclusion If you've worked with image metadata using WIC before, you know it's a technical challenge. This UDF aims to simplify the process while preserving full control for those who need fine-grained access. Feel free to try it out, give feedback, or suggest improvements. Enjoy digging into the hidden data of your images! 📸 IWICImagingMetadata.au3
    2 points
  27. Updated to WebP v0.3.6 build 2025-07-02 beta -> you can convert now GIF animated files to WebP animated files (see Example10.au3 on my 1Drv).
    2 points
  28. One way to launch other tools while a compiled program is running would be to use a tool like this: Scite Plusbar
    2 points
  29. Understand the request, but this is how the internals work in SciTE to be able to capture the output generated by the Script. These are things I won't be trying to change unless it is changed in the Core version supported by Neil.
    2 points
  30. Yes, I forgot to removed these lines for the other functions but I need to add the code also for the other function with callbacks. Currently only function "WebP_CreateWebPCreateAnimFromScreenCapture" in the dll is implemented (example 9) for callback but it should be easy to add also for the other functions. I think tomorrow I will add it to the other functions, too.
    2 points
  31. vs. If you would like to pin the script to the taskbar ( or the start menu ), it can be done with a link. This script is an example and demonstration. The way that I go about it, is to have the script and icon with the same name. The easiest way to test this is if the post had it all in a ZIP file so, there: Example AutoIt v3 Script_v2.zip Also, it's easier to find in task manager given that you can see your icon.
    2 points
  32. Jon

    GimageX updates

    I've updated GImageX with the latest version of the ADK. (Dec 2024 version). Don't think the ADK version was the OP's issue. But updated it anyway.
    2 points
  33. I dont see $btny used anywhere, $btnx appears to be used for both X and Y positions.
    2 points
  34. I misunderstood the value but it's easy, too: Local $iIntensity = '80' ;% of the alpha channel Local $iTintColor = '0x0078D4' $iIntensity = Int($iIntensity) * 255 / 100 Local $iColor = BitOR(BitShift($iIntensity > 255 ? 255 : $iIntensity < 0 ? 0: $iIntensity, -24), Int($iTintColor)) ConsoleWrite(Hex($iColor, 8) & @CRLF) _WinAPI_DwmEnableBlurBehindWindow10($hGUI, True, $iColor)
    2 points
  35. If all this is for coloring, there is code for all that in https://www.autoitscript.com/forum/files/file/489-my-fine-tuned-high-contrast-theme/ If is for Hex, do give the user 255% because, why not. It'd simplify your code, enlighten the user, and gives fine control ( other wise you'd have to calculate "value * 2.55" each step ) for those that are very picky with colors. I look at it as from zero to Maximum Effort !
    2 points
  36. Would it instead be possible to have some sort of state such that you enable or disable the possibility of having ".Property" as valid? It seems like nested rules would be much more difficult/annoying to implement. Then again, I know very little of parsers having only ever made ~1/2 to 3/4 of one myself After skimming your parser: I might look up PegJS later tonight, but I don't think that my idea will work there. This. Is. Fantastic! 1.8.5 does fix my issue, thank you!
    2 points
  37. Hi @seadoggie01! Thanks for the heads up! This is due to the incomplete parser. Currently With...EndWith blocks are not supported. Anything inside the block will fail, since i haven't added any rules to it yet. The reason is that EVERY rule needs to be copied with the small change, that ".property" is a valid syntax within that or child code blocks. It is low priority, since With...EndWith is rarely seen used, but will be supported in the future at some point (depending on how urgent it is). That's an interesting bug! From quick testing, the issue seems to be caused by the empty line in the remarks: ; Remarks .......: Use like: _Acro_DocBookmarkProperties($oBookmark) to get an array of values ; ; Default means values won't be changed. My guess is some of my code is stuck in an infinite loop... I will look into it and fix it soon, since it can deadlock the extension. "Legacy" documentation blocks was implemented quick, since I'm trying to move towards the more cross language familiar docBlock syntax, but that still does not mean the code should fail this spectacularly😅 >Developer: Reload Window Should be your solution. It's not great, but faster than restarting the entire application 😉 Thank you for the kind words and the bug reporting! 😄 Edit: found the line causing problems with the function documentation: https://github.com/genius257/vscode-autoit/blob/0f1bb89f8af77ee7a005d1d5a9da429e5f344700/server/src/autoit/docBlock/DocBlockFactory.ts#L84 It's my regular expression to test if the content matches the UDF documentation format. It causes catastrophic backtracking, never getting past that regex check. Prevention in JS seems to time a new worker, child-process or a regex library, from a quick google search... I don't want to do any of that currently, so I've updated the regex, so it no longer has issues with your example, and if my test parses, I will push the change, and hope this issue does not come back 😜
    2 points
  38. I think I have two bugs to report. I'm currently using VS Code 1.101.0 and v1.8.4 of your extension. The extension gives an error about the With syntax found in Excel.au3 in _Excel_BookNew. The error is: Syntax error: Expected "_", [\t ], or end of line but "I" found. The extension will silently stop displaying suggestions and won't load any function documentation if you reference a file that contains function documentation that is incorrectly formatted. In my case, I was referencing my Acro.au3 file which has a split Syntax line and an empty remarks line. It requires both to stop functioning, but I haven't been able to figure out exactly what the conditions are. It looks like this: I don't always follow the "proper" documentation (due to laziness about learning it), but I don't think the extension should crash because of it It'd be fantastic if it reported an error, great if it displayed just the information it understood, and perfectly acceptable if it displayed nothing and waited for me to update the documentation to something valid (hahahahaha!) Also, if anyone knows how to quickly restart extensions, I'd love to know. I spent a while testing by deleting some code, closing, and then reopening VS Code to find this bug. The "Extensions: Refresh" does nothing in the case of this not-quite-an-error. Disabling and enabling the extension via the menu is slow, but works -- as I found out later. As always, thank you so much for your work on this extension!
    2 points
  39. Numeric1

    IUserNotification

    Hey, could you try this code and let me know if it works for you? Here's the optimized version. Thanks!" #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <WinAPIIcons.au3> #include <WinAPIShellEx.au3> ; Constants for SetBalloonInfo ;Global Const $NIIF_NONE = 0x00000000, $NIIF_USER = 0x00000004, $NIIF_NOSOUND = 0x00000010, $NIIF_RESPECT_QUIET_TIME = 0x00000080 ; Function to create and display the notification Func CreateSystemNotification($sTitle, $sMessage, $iTimeout = 2000, $iIconIndex = 13, $sSound = "") Local $hIcon = 0, $oNotif = 0, $bSuccess = False Local Const $sCLSID_IUserNotification = "{0010890E-8789-413C-ADBC-48F5B511B3AF}" Local Const $sIID_IUserNotification = "{BA9711BA-5893-4787-A7E1-41277151550B}" Local Const $tagIUserNotification = "SetBalloonInfo long(wstr;wstr;dword);" & _ "SetBalloonRetry long(dword;dword;uint);" & _ "SetIconInfo long(ptr;wstr);" & _ "Show long(ptr;dword);" & _ "PlaySound long(wstr);" ; Create COM instance $oNotif = ObjCreateInterface($sCLSID_IUserNotification, $sIID_IUserNotification, $tagIUserNotification) If Not IsObj($oNotif) Then ConsoleWrite("Error: Failed to create COM object." & @CRLF) Return False EndIf ; Load icon Local $dwFlags = $NIIF_USER If Not IsInt($iIconIndex) Or $iIconIndex < 0 Then $iIconIndex = 13 ; Default icon Else Local $iTotal = _WinAPI_ExtractIconEx(@SystemDir & '\shell32.dll', -1, 0, 0, 0) If $iIconIndex >= $iTotal Then $iIconIndex = 13 ; Fallback to default if index is out of range EndIf EndIf $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', $iIconIndex, 32, 32) If Not $hIcon Then ConsoleWrite("Error: Failed to load icon. Switching to NIIF_NONE." & @CRLF) $dwFlags = $NIIF_NONE EndIf ; Configure notification If $sSound Then $oNotif.PlaySound($sSound) $oNotif.SetBalloonInfo($sTitle, $sMessage, BitOR($NIIF_RESPECT_QUIET_TIME, $dwFlags)) $oNotif.SetBalloonRetry(0, 0, 0) $oNotif.SetIconInfo($hIcon, $sTitle) $oNotif.Show(0, $iTimeout) $bSuccess = True ; Mark success if we reach this point ; Cleanup If $hIcon Then _WinAPI_DestroyIcon($hIcon) $oNotif = 0 ; AutoIt handles COM cleanup automatically Return $bSuccess EndFunc ;==>CreateSystemNotification ; Example usage If CreateSystemNotification("Notification Title", "This is an AutoIt message", 2000) Then ConsoleWrite("Notification displayed successfully." & @CRLF) Else ConsoleWrite("Failed to display notification." & @CRLF) EndIf
    2 points
  40. different approach #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WinAPIDlg.au3> _Main() Func _Main() Local $hGUI = GUICreate("Example", 250, 100) GUICtrlCreateLabel("Type name here (max 12 chars)", 20, 20) Local $idEditName = GUICtrlCreateEdit("", 20, 40, 160, 20, $ES_AUTOHSCROLL) GUICtrlSetLimit($idEditName, 12) Local $idEditResult = GUICtrlCreateEdit("", 20, 65, 160, 20, $ES_READONLY, 0) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch ; Check if the active control is $idEditName If _WinAPI_GetDlgCtrlID(ControlGetHandle($hGUI, "", ControlGetFocus($hGUI))) = $idEditName Then Local $sValue = _InputLimiter($idEditName) If $sValue <> "" Then GUICtrlSetData($idEditResult, $sValue) EndIf WEnd EndFunc Func _InputLimiter($iCtrlInput, $iMaxBaseLength = 12, $sSuffix = "-PC") Local Static $sLastValue Local $sCurrentValue = GUICtrlRead($iCtrlInput) If $sCurrentValue <> $sLastValue Then $sLastValue = $sCurrentValue Return StringLeft($sCurrentValue, $iMaxBaseLength) & $sSuffix EndIf Return "" EndFunc Edit: variant with more advanced limiter Func _InputLimiter($iCtrlInput, $iMaxBaseLength = 12, $sSuffix = "-PC") Local Static $sLastValue Local $sCurrentValue = GUICtrlRead($iCtrlInput) Local $sFilteredValue = StringRegExpReplace($sCurrentValue, "[^a-zA-Z0-9]", "") If $sFilteredValue <> $sCurrentValue Then GUICtrlSetData($iCtrlInput, $sFilteredValue) Return "" EndIf If $sFilteredValue <> $sLastValue Then $sLastValue = $sFilteredValue ; Update static ConsoleWrite("$sCurrentValue=" & $sCurrentValue & @CRLF) ; For debugging Return StringLeft($sFilteredValue, $iMaxBaseLength) & $sSuffix EndIf Return "" EndFunc
    2 points
  41. So AutoIt does not have a good (fast) solution for things like: taking part of an array as a new array adding element(s) at the start or middle of the array In general array manipulation requires a loop, not a fast solution in AutoIt. I'm thinking using IDispatch to handle variable transfer between normal variables and the raw variant pointers. And fasm to do the array manipulation, importing the OleAut32 functions for variant manipulation. I expect this solution to be fast, and only require AutoIt and a fasm DLL, to work. My biggest issue currently is my lack of experience with ASM. I could try to throw something together, but would prefer help from someone, who actually knows what they are doing Any feedback on this idea is appreciated
    2 points
  42. WildByDesign

    DwmColorBlurMica

    I'm working on a release that has full support for Visual Studio Code (plus VSCodium in my case) and Visual Studio 2022. Both are working beautifully and reliably. So I should be able to do a release soon after some more testing. Screenshots:
    2 points
  43. Here the version to choose the drive letter: ;Coded by UEZ build 2025-06-11 beta #RequireAdmin #include <WinAPIHObj.au3> #include <WinAPIFiles.au3> Global Const $VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT = '{EC984AEC-A0F9-47E9-901F-71415A66345B}' Global Const $VIRTUAL_STORAGE_TYPE_VENDOR_UNKNOWN = '{00000000-0000-0000-0000-000000000000}' ;VIRTUAL_STORAGE_TYPE -> https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ns-virtdisk-virtual_storage_type Global Enum $VIRTUAL_STORAGE_TYPE_DEVICE_UNKNOWN = 0, $VIRTUAL_STORAGE_TYPE_DEVICE_ISO, $VIRTUAL_STORAGE_TYPE_DEVICE_VHD, $VIRTUAL_STORAGE_TYPE_DEVICE_VHDX ;VIRTUAL_DISK_ACCESS_MASK -> https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ne-virtdisk-virtual_disk_access_mask-r1 Global Enum $VIRTUAL_DISK_ACCESS_NONE = 0, $VIRTUAL_DISK_ACCESS_ATTACH_RO = 0x00010000, $VIRTUAL_DISK_ACCESS_ATTACH_RW = 0x00020000, $VIRTUAL_DISK_ACCESS_DETACH = 0x00040000, _ $VIRTUAL_DISK_ACCESS_GET_INFO = 0x00080000, $VIRTUAL_DISK_ACCESS_CREATE = 0x00100000, $VIRTUAL_DISK_ACCESS_METAOPS = 0x00200000, $VIRTUAL_DISK_ACCESS_READ = 0x000D0000, _ $VIRTUAL_DISK_ACCESS_ALL = 0x003F0000, $VIRTUAL_DISK_ACCESS_WRITABLE = 0x00320000 ;OPEN_VIRTUAL_DISK_FLAG -> https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ne-virtdisk-open_virtual_disk_flag Global Enum $OPEN_VIRTUAL_DISK_FLAG_NONE = 0x00000000, $OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS = 0x00000001, $OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE = 0x00000002, $OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE = 0x00000004, _ $OPEN_VIRTUAL_DISK_FLAG_CACHED_IO = 0x00000008, $OPEN_VIRTUAL_DISK_FLAG_CUSTOM_DIFF_CHAIN = 0x00000010, $OPEN_VIRTUAL_DISK_FLAG_PARENT_CACHED_IO = 0x00000020, $OPEN_VIRTUAL_DISK_FLAG_VHDSET_FILE_ONLY = 0x00000040, _ $OPEN_VIRTUAL_DISK_FLAG_IGNORE_RELATIVE_PARENT_LOCATOR = 0x00000080, $OPEN_VIRTUAL_DISK_FLAG_NO_WRITE_HARDENING = 0x00000100, $OPEN_VIRTUAL_DISK_FLAG_SUPPORT_COMPRESSED_VOLUMES, _ $OPEN_VIRTUAL_DISK_FLAG_SUPPORT_SPARSE_FILES_ANY_FS, $OPEN_VIRTUAL_DISK_FLAG_SUPPORT_ENCRYPTED_FILES ;ATTACH_VIRTUAL_DISK_FLAG -> https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ne-virtdisk-attach_virtual_disk_flag Global Enum $ATTACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000, $ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY = 0x00000001, $ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER = 0x00000002, $ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME = 0x00000004, _ $ATTACH_VIRTUAL_DISK_FLAG_NO_LOCAL_HOST = 0x00000008, $ATTACH_VIRTUAL_DISK_FLAG_NO_SECURITY_DESCRIPTOR = 0x00000010, $ATTACH_VIRTUAL_DISK_FLAG_BYPASS_DEFAULT_ENCRYPTION_POLICY = 0x00000020, _ $ATTACH_VIRTUAL_DISK_FLAG_NON_PNP, $ATTACH_VIRTUAL_DISK_FLAG_RESTRICTED_RANGE, $ATTACH_VIRTUAL_DISK_FLAG_SINGLE_PARTITION, $ATTACH_VIRTUAL_DISK_FLAG_REGISTER_VOLUME, $ATTACH_VIRTUAL_DISK_FLAG_AT_BOOT ;OPEN_VIRTUAL_DISK_VERSION -> https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ne-virtdisk-open_virtual_disk_version Global Enum $OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED = 0, $OPEN_VIRTUAL_DISK_VERSION_1, $OPEN_VIRTUAL_DISK_VERSION_2, $OPEN_VIRTUAL_DISK_VERSION_3 Global Enum $DETACH_VIRTUAL_DISK_FLAG_NONE = 0x00000000 ;DETACH_VIRTUAL_DISK_FLAG -> https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ne-virtdisk-detach_virtual_disk_flag Global Const $tagOPEN_VIRTUAL_DISK_PARAMETERS = "dword Version;dword RWDepth" ;"ulong Data1;ushort Data2;ushort Data3;ubyte Data4[8]" ;https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ns-virtdisk-virtual_storage_type Global Const $tagVIRTUAL_STORAGE_TYPE = "ulong DeviceId;byte VendorId[16]" ;https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-security_descriptor Global Const $tagSECURITY_DESCRIPTOR = "byte Revision;byte Sbz1;ushort Control;ptr Owner;ptr Group;ptr Sacl;ptr Dacl;" ;https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-overlapped ;Global Const $tagOVERLAPPED = "ptr Internal;ptr InternalHigh;dword Offset;dword OffsetHigh;ptr hEvent" ;https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/ns-virtdisk-attach_virtual_disk_parameters Global Const $tagATTACH_VIRTUAL_DISK_PARAMETERS = "dword Version;" & _ ; ATTACH_VIRTUAL_DISK_VERSION enum "uint Reserved;" & _ ; Nur bei Version1 "uint64 RestrictedOffset;" & _ ; Nur bei Version2 "uint64 RestrictedLength;" ; Nur bei Version2 ;https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/nf-virtdisk-openvirtualdisk Func _WinAPI_OpenVirtualDisk($tVIRTUAL_STORAGE_TYPE, $sPath, $VIRTUAL_DISK_ACCESS_MASK = 0, $OPEN_VIRTUAL_DISK_FLAG = 0, $tOPEN_VIRTUAL_DISK_PARAMETERS = 0) If Not FileExists($sPath) Then SetError(1, 0, 0) Local $aReturn = DllCall("VirtDisk.dll", "dword", "OpenVirtualDisk", "struct*", $tVIRTUAL_STORAGE_TYPE, "wstr", $sPath, "ulong", $VIRTUAL_DISK_ACCESS_MASK, "ulong", $OPEN_VIRTUAL_DISK_FLAG, "struct*", $tOPEN_VIRTUAL_DISK_PARAMETERS, "handle*", 0) If @error Then Return SetError(2, 0, 0) Return $aReturn[6] EndFunc ;https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/nf-virtdisk-attachvirtualdisk Func _WinAPI_AttachVirtualDisk($hVD, $tSECURITY_DESCRIPTOR, $ATTACH_VIRTUAL_DISK_FLAG, $ProviderSpecificFlags, $tATTACH_VIRTUAL_DISK_PARAMETERS = Null, $tOVERLAPPED = Null) If Not $hVD Then Return SetError(1, 0, 0) Local $aReturn = DllCall("VirtDisk.dll", "dword", "AttachVirtualDisk", "handle", $hVD, "struct*", $tSECURITY_DESCRIPTOR, "ulong", $ATTACH_VIRTUAL_DISK_FLAG, "ulong", $ProviderSpecificFlags, "struct*", $tATTACH_VIRTUAL_DISK_PARAMETERS, "struct*", $tOVERLAPPED) If @error Then Return SetError(2, 0, 0) Return 1 EndFunc ;https://learn.microsoft.com/en-us/windows/win32/api/virtdisk/nf-virtdisk-detachvirtualdisk Func _WinAPI_DetachVirtualDisk($hVD, $iFlags = $DETACH_VIRTUAL_DISK_FLAG_NONE, $ProviderSpecificFlags = 0) Local $aCall = DllCall("VirtDisk.dll", "dword", "DetachVirtualDisk", "handle", $hVD, "long", $iFlags, "ulong", $ProviderSpecificFlags) If @error Then Return SetError(1, 0, 0) If $aCall[0] <> 0 Then Return SetError(2, $aCall[0], 0) Return 1 EndFunc ;https://learn.microsoft.com/de-de/windows/win32/api/virtdisk/nf-virtdisk-getvirtualdiskphysicalpath Func _WinAPI_GetVirtualDiskPhysicalPath($hVD) If Not $hVD Then Return SetError(1, 0, 0) Local $tPhysicalDrive = DllStructCreate("wchar physicalDrive[260]") Local $aReturn = DllCall("VirtDisk.dll", "dword", "GetVirtualDiskPhysicalPath", "handle", $hVD, "ulong*", DllStructGetSize($tPhysicalDrive), "struct*", $tPhysicalDrive) If @error Then Return SetError(2, 0, 0) Return $tPhysicalDrive.physicalDrive EndFunc Global $sISOFile = FileOpenDialog("Select an ISO file to mount", "", "ISO (*.iso)", BitOR($FD_FILEMUSTEXIST, $FD_PATHMUSTEXIST)) If @error Then Exit Global $tVIRTUAL_STORAGE_TYPE = DllStructCreate($tagVIRTUAL_STORAGE_TYPE) $tVIRTUAL_STORAGE_TYPE.DeviceId = $VIRTUAL_STORAGE_TYPE_DEVICE_ISO $tVIRTUAL_STORAGE_TYPE.VendorId = Binary("0xEC984AECA0F947E9901F71415A66345B") ;$VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT Global $tOPEN_VIRTUAL_DISK_PARAMETERS = DllStructCreate($tagOPEN_VIRTUAL_DISK_PARAMETERS) $tOPEN_VIRTUAL_DISK_PARAMETERS.Version = $OPEN_VIRTUAL_DISK_VERSION_1 $tOPEN_VIRTUAL_DISK_PARAMETERS.RWDepth = 0 Global $tATTACH_VIRTUAL_DISK_PARAMETERS = DllStructCreate($tagATTACH_VIRTUAL_DISK_PARAMETERS) $tATTACH_VIRTUAL_DISK_PARAMETERS.Version = $OPEN_VIRTUAL_DISK_VERSION_1 Global $sDrvLetter = "z:\" Global $hMountISO = _WinAPI_OpenVirtualDisk($tVIRTUAL_STORAGE_TYPE, _ $sISOFile, _ BitOR($VIRTUAL_DISK_ACCESS_READ, $VIRTUAL_DISK_ACCESS_ATTACH_RO, $VIRTUAL_DISK_ACCESS_GET_INFO), _ $OPEN_VIRTUAL_DISK_FLAG_NONE, _ $tOPEN_VIRTUAL_DISK_PARAMETERS) If Not $hMountISO Then Exit MsgBox($MB_ICONERROR, "ERROR", "Something went wrong opening ISO!") If _WinAPI_AttachVirtualDisk($hMountISO, _ 0, _ BitOR($ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY, $ATTACH_VIRTUAL_DISK_FLAG_PERMANENT_LIFETIME, $ATTACH_VIRTUAL_DISK_FLAG_NO_DRIVE_LETTER), _ 0, _ $tATTACH_VIRTUAL_DISK_PARAMETERS) Then Global $sPhysicalDrive = _WinAPI_GetVirtualDiskPhysicalPath($hMountISO) If StringRight($sPhysicalDrive, 1) <> "\" Then $sPhysicalDrive &= "\" Global $sVolumeNameGUID = _WinAPI_GetVolumeNameForVolumeMountPoint($sPhysicalDrive) If StringRight($sVolumeNameGUID, 1) <> "\" Then $sVolumeNameGUID &= "\" _WinAPI_SetVolumeMountPoint($sDrvLetter, $sVolumeNameGUID) MsgBox(0, "TEST ISO Mounting", "ISO mounted to drive letter " & $sDrvLetter & " - checkout Windows Explorer") Else MsgBox($MB_ICONERROR, "ERROR", "Something went wrong attaching ISO!") EndIf If $hMountISO Then _WinAPI_DeleteVolumeMountPoint($sDrvLetter) _WinAPI_DetachVirtualDisk($hMountISO) _WinAPI_CloseHandle($hMountISO) EndIf Check out variable $sDrvLetter
    2 points
  44. I might have a suggestion for an extension: Currently, the user must not make a single typing error for the suggestion to be displayed as such. To be more generous, you could use a fuzzy comparison. I have implemented this accordingly in your script and used >>this UDF<< for the fuzzy search. The script now looks like this: #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <WinAPI.au3> #include <GuiListBox.au3> #include "FuzzyString.au3" ; Global Variables Global $g_hMainGUI Global $g_idEditInputTags Global $g_idListboxSuggestions Global $g_hListboxSuggestionsHWND Global $g_aAvailableTags Global $g_iCurrentSuggestionIndex = -1 ; Dummy control IDs for accelerators (Listbox Navigation Key) Global $g_idAccelUp, $g_idAccelDown, $g_idAccelEnter, $g_idAccelEscape ; Load all unique tags from database $g_aAvailableTags = _GetAllUniqueTags() If @error Then MsgBox(16, "Error", "Failed to load unique tags from database.") _CreateGUI() ; Create Main GUI Exit ;--------------------------------------------------------------------------------------- Func _GetAllUniqueTags() ; This function should retrieve your actual unique tags from a database or file. ; For demonstration, it reads words from a text file. Local $sString = StringLower(FileRead("C:\Program Files (x86)\AutoIt3\SciTE\SciTE Jump\License.txt")) ; matches sequences of letters that are at least 4 characters long Local $aWords = StringRegExp($sString, '[a-zA-Z]{4,}', 3) $aWords = _ArrayUnique($aWords, 0, 0, 1, 0) _ArraySort($aWords) Return $aWords EndFunc ;==>_GetAllUniqueTags ;--------------------------------------------------------------------------------------- Func _CreateGUI() $g_hMainGUI = GUICreate("Main GUI", 700, 300) GUICtrlCreateLabel("Title:", 10, 20, 50, 20) Local $idTitle = GUICtrlCreateInput("", 70, 20, 600, 25) GUICtrlCreateLabel("Tags:", 10, 60, 50, 20) $g_idEditInputTags = GUICtrlCreateInput("", 70, 60, 600, 25, $ES_AUTOVSCROLL) GUICtrlSetLimit($g_idEditInputTags, 250) Local $aPos = ControlGetPos($g_hMainGUI, "", $g_idEditInputTags) If @error Then Exit MsgBox(16, "Error", "Failed to get position of Tags input control. Exiting.") ; Suggestions Listbox $g_idListboxSuggestions = GUICtrlCreateList("", $aPos[0], $aPos[1] + $aPos[3], $aPos[2], 150, BitOR($LBS_NOTIFY, $WS_VSCROLL, $WS_BORDER, $WS_TABSTOP)) GUICtrlSetState($g_idListboxSuggestions, $GUI_HIDE) $g_hListboxSuggestionsHWND = GUICtrlGetHandle($g_idListboxSuggestions) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND_Handler") GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL_Handler") $g_idAccelUp = GUICtrlCreateDummy() $g_idAccelDown = GUICtrlCreateDummy() $g_idAccelEnter = GUICtrlCreateDummy() $g_idAccelEscape = GUICtrlCreateDummy() Local $AccelKeys[4][2] = [ _ ["{UP}", $g_idAccelUp], _ ["{DOWN}", $g_idAccelDown], _ ["{ENTER}", $g_idAccelEnter], _ ["{ESCAPE}", $g_idAccelEscape] _ ] GUISetAccelerators($AccelKeys) Local $idExit = GUICtrlCreateButton("Exit", 300, 250, 100, 30) GUISetState(@SW_SHOW) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE, $idExit ExitLoop Case $g_idAccelUp _ListboxNavigationKey($g_idAccelUp) Case $g_idAccelDown _ListboxNavigationKey($g_idAccelDown) Case $g_idAccelEnter _ListboxNavigationKey($g_idAccelEnter) Case $g_idAccelEscape _ListboxNavigationKey($g_idAccelEscape) EndSwitch WEnd GUIDelete($g_hMainGUI) EndFunc ;==>_CreateGUI ;--------------------------------------------------------------------------------------- Func _ApplySelectedTag($sSelectedTag) If $sSelectedTag = "" Then Return Local $sCurrentTags = GUICtrlRead($g_idEditInputTags) If @error Then Return Local $iLastCommaPos = StringInStr($sCurrentTags, ",", 0, -1) ; Find the last comma Local $sPrefixToKeep = "" If $iLastCommaPos > 0 Then $sPrefixToKeep = StringLeft($sCurrentTags, $iLastCommaPos) $sPrefixToKeep = StringStripWS($sPrefixToKeep, $STR_STRIPTRAILING) & " " EndIf Local $sNewTags = $sPrefixToKeep & $sSelectedTag & ", " GUICtrlSetData($g_idEditInputTags, $sNewTags) If @error Then Return _HideSuggestions() GUICtrlSetState($g_idEditInputTags, $GUI_FOCUS) If @error Then Return _WinAPI_PostMessage(GUICtrlGetHandle($g_idEditInputTags), $EM_SETSEL, StringLen($sNewTags), StringLen($sNewTags)) $g_iCurrentSuggestionIndex = -1 EndFunc ;==>_ApplySelectedTag ;--------------------------------------------------------------------------------------- Func _ShowSuggestions($sCurrentInput) Local $sTrimmedInput = StringStripWS($sCurrentInput, $STR_STRIPLEADING + $STR_STRIPTRAILING) If $sTrimmedInput = "" Then Return _HideSuggestions() Local $aInputParts = StringSplit($sTrimmedInput, ",", $STR_NOCOUNT) Local $sLastPart = "" If UBound($aInputParts) > 0 Then $sLastPart = StringStripWS($aInputParts[UBound($aInputParts) - 1], $STR_STRIPLEADING + $STR_STRIPTRAILING) Else $sLastPart = $sTrimmedInput EndIf If $sLastPart = "" Then Return _HideSuggestions() Local $aFilteredSuggestions = _FS_ArraySearchFuzzy($g_aAvailableTags, $sLastPart, 1, __LS_UntilLength) $aFilteredSuggestions = _ArrayExtract($aFilteredSuggestions, -1, -1, 0, 0) $iCount = UBound($aFilteredSuggestions) If $iCount > 0 Then GUICtrlSendMsg($g_idListboxSuggestions, $LB_RESETCONTENT, 0, 0) For $sSuggestion In $aFilteredSuggestions If $sSuggestion <> "" Then GUICtrlSendMsg($g_idListboxSuggestions, $LB_ADDSTRING, 0, $sSuggestion) EndIf Next GUICtrlSetState($g_idListboxSuggestions, $GUI_SHOW) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETCURSEL, 0, 0) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETTOPINDEX, 0, 0) $g_iCurrentSuggestionIndex = 0 Else _HideSuggestions() EndIf EndFunc ;==>_ShowSuggestions ;--------------------------------------------------------------------------------------- Func _HideSuggestions() GUICtrlSetState($g_idListboxSuggestions, $GUI_HIDE) GUICtrlSendMsg($g_idListboxSuggestions, $LB_RESETCONTENT, 0, 0) $g_iCurrentSuggestionIndex = -1 EndFunc ;==>_HideSuggestions ;--------------------------------------------------------------------------------------- Func _ListboxNavigationKey($idKey) If Not BitAND(GUICtrlGetState($g_idListboxSuggestions), $GUI_SHOW) Then Return Local $iCount = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCOUNT, 0, 0) If $iCount = 0 Then Return Switch $idKey Case $g_idAccelUp If $g_iCurrentSuggestionIndex <= 0 Then $g_iCurrentSuggestionIndex = $iCount - 1 Else $g_iCurrentSuggestionIndex -= 1 EndIf GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETCURSEL, $g_iCurrentSuggestionIndex, 0) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETTOPINDEX, $g_iCurrentSuggestionIndex, 0) Case $g_idAccelDown If $g_iCurrentSuggestionIndex >= $iCount - 1 Then $g_iCurrentSuggestionIndex = 0 Else $g_iCurrentSuggestionIndex += 1 EndIf GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETCURSEL, $g_iCurrentSuggestionIndex, 0) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETTOPINDEX, $g_iCurrentSuggestionIndex, 0) Case $g_idAccelEnter Local $iIndex = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCURSEL, 0, 0) If $iIndex <> $LB_ERR Then Local $sSelectedTag = _GUICtrlListBox_GetText($g_idListboxSuggestions, $iIndex) If $sSelectedTag <> "" Then _ApplySelectedTag($sSelectedTag) EndIf Else _HideSuggestions() EndIf $g_iCurrentSuggestionIndex = -1 Case $g_idAccelEscape _HideSuggestions() $g_iCurrentSuggestionIndex = -1 EndSwitch EndFunc ;==>_ListboxNavigationKey ;--------------------------------------------------------------------------------------- Func _WM_COMMAND_Handler($hWnd, $iMsg, $wParam, $lParam) Local $iControlID = _WinAPI_LoWord($wParam) Local $iNotificationCode = _WinAPI_HiWord($wParam) Switch $iMsg Case $WM_COMMAND Switch $iControlID Case $g_idEditInputTags Switch $iNotificationCode Case $EN_CHANGE Local $sCurrentInput = GUICtrlRead($g_idEditInputTags) _ShowSuggestions($sCurrentInput) Case $EN_KILLFOCUS Sleep(50) Local $hFocusedWindow = _WinAPI_GetFocus() Local $hListboxSuggestionsHandle = GUICtrlGetHandle($g_idListboxSuggestions) Local $hEditInputTagsHandle = GUICtrlGetHandle($g_idEditInputTags) If $hFocusedWindow <> $hListboxSuggestionsHandle And $hFocusedWindow <> $hEditInputTagsHandle Then _HideSuggestions() Local $sCurrentTags = GUICtrlRead($g_idEditInputTags) If StringRight($sCurrentTags, 2) = ", " Then GUICtrlSetData($g_idEditInputTags, StringTrimRight($sCurrentTags, 2)) ElseIf StringRight($sCurrentTags, 1) = "," Then GUICtrlSetData($g_idEditInputTags, StringTrimRight($sCurrentTags, 1)) EndIf EndIf EndSwitch Case $g_idListboxSuggestions Switch $iNotificationCode Case $LBN_SELCHANGE Local $iIndex = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCURSEL, 0, 0) If $iIndex <> $LB_ERR Then Local $sSelectedTag = _GUICtrlListBox_GetText($g_idListboxSuggestions, $iIndex) If $sSelectedTag <> "" Then _ApplySelectedTag($sSelectedTag) EndIf EndIf Case $LBN_DBLCLK Local $iIndex = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCURSEL, 0, 0) If $iIndex <> $LB_ERR Then Local $sSelectedTag = _GUICtrlListBox_GetText($g_idListboxSuggestions, $iIndex) If $sSelectedTag <> "" Then _ApplySelectedTag($sSelectedTag) EndIf EndIf EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND_Handler ;--------------------------------------------------------------------------------------- Func _WM_MOUSEWHEEL_Handler($hWnd, $iMsg, $wParam, $lParam) ; Using GUIGetCursorInfo to find the control under the mouse Local $aCursorInfo = GUIGetCursorInfo($g_hMainGUI) ; Check if the mouse is over the suggestions ListBox and if the ListBox is visible If Not @error And IsArray($aCursorInfo) And UBound($aCursorInfo) >= 5 And $aCursorInfo[4] = $g_idListboxSuggestions And BitAND(GUICtrlGetState($g_idListboxSuggestions), $GUI_SHOW) Then Local $iDelta = _WinAPI_HiWord($wParam) ; How much the wheel turned (120 for a "click" up, -120 for a "click" down) Local $iNumLinesToScroll = 1 ; We scroll one line at a time with the wheel Local $iCurrentSelection = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCURSEL, 0, 0) Local $iTotalItems = GUICtrlSendMsg($g_idListboxSuggestions, $LB_GETCOUNT, 0, 0) If $iTotalItems <= 0 Then Return 1 ; No items, nothing to scroll or select If $iDelta > 0 Then ; Scroll Up (wheel up) If $iCurrentSelection > 0 Then $g_iCurrentSuggestionIndex = $iCurrentSelection - $iNumLinesToScroll If $g_iCurrentSuggestionIndex < 0 Then $g_iCurrentSuggestionIndex = 0 Else $g_iCurrentSuggestionIndex = 0 ; Already at the top EndIf Else ; Scroll Down (wheel down) If $iCurrentSelection < $iTotalItems - 1 Then $g_iCurrentSuggestionIndex = $iCurrentSelection + $iNumLinesToScroll If $g_iCurrentSuggestionIndex >= $iTotalItems Then $g_iCurrentSuggestionIndex = $iTotalItems - 1 Else $g_iCurrentSuggestionIndex = $iTotalItems - 1 ; Already at the bottom EndIf EndIf ; We define the new option GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETCURSEL, $g_iCurrentSuggestionIndex, 0) ; Also, make the selected element visible (if it isn't already) GUICtrlSendMsg($g_idListboxSuggestions, $LB_SETTOPINDEX, $g_iCurrentSuggestionIndex, 0) Return 1 ; Message has been handled EndIf Return $GUI_RUNDEFMSG ; Let AutoIt handle the message for other controls EndFunc ;==>_WM_MOUSEWHEEL_Handler ; comparison function for the fuzzy comparison, which only compares up to the same length and introduces limit values for short strings. Func __LS_UntilLength($sA, $sB, $iMax = Default) Local $iLenA = StringLen($sA) Local $iLenB = StringLen($sB) Local $iLenMin = $iLenA > $iLenB ? $iLenB : $iLenA Local $iLenShort = $iLenMin > 1 ? 2 : $iLenMin Local $aLS[2] ; short exit for performance boost If StringLeft($sA, $iLenShort) <> StringLeft($sB, $iLenShort) Then $aLS[0] = $iMax + 1 Return $aLS EndIf $aLS = _FS_Hamming(StringLeft($sA, $iLenMin), StringLeft($sB, $iLenMin), $iMax) If @error Then Return SetError(@error, @extended) If $aLS[0] > 0 And $aLS[0] > ($iLenMin - 2) Then $aLS[0] = $iMax + 1 Return $aLS EndFunc Enter something like "abose" and you'll see what I mean. This does not come from StringRegExp but from _ArrayUnique. And this behavior can be prevented directly when it is called via _ArrayUnique($aWords, 0, 0, 1, 0).
    1 point
  45. mLipok

    WebDriver and Admin rights

    @n3wbie could you be so nice and check: https://github.com/Danp2/au3WebDriver/issues/532#issuecomment-3054090565
    1 point
  46. This I agree with 100%. This should be the right way to go. However, after many past experiences of reporting things to M$, it is comparable to having a conversation with a goat.
    1 point
  47. @UEZ Thanks for the upload of "WebP Example081.au3", I'm truly honored to see my nickname near yours in a script To achieve this, I just tried the following pattern, it looks promising : (?Usi)WebP_CreateWebPCreateAnim\(.*(; Parameters.*)\R; (?:Return value|Requirement).*Func WebP_CreateWebPCreateAnim\( The string "WebP_CreateWebPCreateAnim" will be replaced by $sFuncName in the final version, to make it portable. Return in array[0] is : ; Parameters ....: $aFilenames - an 2D array of pathes to the image files and delay per frame. ; $sOutfile - filename of WebP animation output file. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 0. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 4. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 1. Number of entropy-analysis passes (in [1..10]). ; $level - [optional] an unknown value. Default is 6. Between 0 (fastest, lowest compression) and 9 (slower, best compression) only valid for lossless = 1! ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 100. Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 1. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPPreset - [optional] an unknown value. Default is $WEBP_PRESET_DEFAULT. ; $iDefaultDelay - [optional] an integer value. Default is 75. Delay in milli seconds. ; $pCallback - [optional] a pointer value. Default is 0. Pointer to a callback address for progress hook. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. After that we'll see if it needs to be splitted into 20 lines (20 tooltips for the 20 labels while creating $hGUIPar) You may ask : "why the need of the non-capturing group ? (?:Return value|Requirement) It's just to make the pattern compatible with some UDF's of other users, for example @Melba23 in GUIListViewEx.au3 , function _GUIListViewEx_Init The same pattern (using $sFuncName etc...) will output this : (?Usi)_GUIListViewEx_Init\(.*(; Parameters.*)\R; (?:Return value|Requirement).*Func _GUIListViewEx_Init\( ; Parameters ....: $hLV - Handle or ControlID of ListView ; $aArray - Name of array used to fill ListView. "" for empty ListView ; $iStart - 0 = ListView data starts in [0] element of array (default) ; 1 = Count in [0] element ; $iColour - RGB colour for insert mark (default = black) ; $fImage - True = Shadow image of dragged item when dragging ; False = No shadow image (default) ; $iAdded - 0 - No added features (default). To get added features add any of the following values ; + 1 - Sortable by clicking on column headers ; + 2 - Do not "select all" when editing item text ; + 4 - Continue edit within same ListView by triple mouse-click on editable column ; + 8 - Headers editable by Ctrl-click (only if column editable) ; + 16 - User coloured header ; + 32 - User coloured items ; + 64 - No external drag ; + 128 - No external drop ; + 256 - No delete on external drag/drop ; + 512 - No internal drag/drop ; + 1024 - Single cell highlight (forces single row selection) This one should be just a bit harder to split into 6 tooltips... but never say never Edit: @UEZ each time the _ShowParams() function will be updated, I'll do it in the same post above, not polluting your thread with new posts. For example, I just updated it now : Gui design (minor) Insensitive flag in one RegEx pattern Return value , @error , @extended : all checkable in main Next step should be to add the tooltips as discussed above (note: it has been done this evening) Thanks for reading and have a great sunday !
    1 point
  48. Here you should find one way how to embed your font (Display Font from Memory):
    1 point
  49. Here modern coding (removed useless code) : #include <WinAPISysWin.au3> #include <WinAPIConstants.au3> #include <GDIPlus.au3> #include <GuiComboBox.au3> #include <File.au3> #include <WindowsConstants.au3> #include <GuiConstants.au3> #include <ButtonConstants.au3> Opt("MustDeclareVars", True) Global Const $AC_SRC_ALPHA = 1 Example() Func Example() ; Load PNG file as GDI bitmap _GDIPlus_Startup() Local $sPngSrc = @ScriptDir & "\LaunchySkin.png" Local $hImage = _GDIPlus_ImageLoadFromFile($sPngSrc) ; Extract image width and height from PNG Local $iWidth = _GDIPlus_ImageGetWidth($hImage) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) ; Create layered window Local $hGUI = GUICreate("", $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_UpdateLayeredWindowEx($hGUI, -1, -1, $hBitmap) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, WM_NCHITTEST) GUISetState() WinSetOnTop($hGUI, "", $WINDOWS_ONTOP) ; As per help file : ; When using $WS_EX_MDICHILD the position is relative to client area of the parent window. ; With $WS_EX_LAYERED it is possible to have a transparent picture on a background picture defined in the parent window. ; To have a transparent picture, create the GUI with the WS_EX_LAYERED extended style. ; The left-top pixel will be used as the transparency color. ; If several pictures are created the last picture defines the transparent color. GUICreate("", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI) GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $iWidth, $iHeight) ; makes the whole child GUI transparent GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Type the name of a file on" & @CR & "your desktop and press Enter", 50, 30, 140, 60) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; combo box listing all items on desktop Local $idCombo = GUICtrlCreateCombo("", 210, 30, 250, -1, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetFont($idCombo, 10) ; set default button for Enter key activation - renders outside GUI window Local $idButton = GUICtrlCreateButton("", 0, 0, 0, 0, $BS_DEFPUSHBUTTON) GUISetState() ; get list of files on desktop, show in combobox Local $aFileList = _FileListToArray(@DesktopDir), $sRun _ArraySort($aFileList, 0, 1) GUICtrlSetData($idCombo, _ArrayToString($aFileList, "|", 1)) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton $sRun = GUICtrlRead($idCombo) ExitLoop EndSwitch WEnd If $sRun And FileExists(@DesktopDir & "\" & $sRun) Then Beep(2000, 50) ShellExecute($sRun, "", @DesktopDir) EndIf _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>Example Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) Return $HTCAPTION EndFunc ;==>WM_NCHITTEST
    1 point
  50. UEZ

    Tester needed ^^

    @argumentum I hope you don't mind me doing something similar in parallel. I would like to test the code on different OS, need your support. It would make sense to have 2+ monitors, if possible with > 96 DPI. I don't know from which os it is possible to set different DPIs per monitor (WIn10+?). I tested it on Win11 22H2 and worked properly on 3 monitors with 3 different DPIs (left 100%, middle 125 % (main), right 150%). Just run the code and move the GUI over all your monitors. Theoretically the GUI should be adjusted accordingly. _WinAPI_DPI.au3: ;Coded by UEZ build 2023-08-15 beta #include-once #include <GDIPlus.au3> #include <Misc.au3> #include <WinAPISysWin.au3> #include <WinAPIsysinfoConstants.au3> #Region DPI Constants ;https://learn.microsoft.com/en-us/windows/win32/api/windef/ne-windef-dpi_awareness Global Enum $DPI_AWARENESS_INVALID = -1, $DPI_AWARENESS_UNAWARE = 0, $DPI_AWARENESS_SYSTEM_AWARE = 1, $DPI_AWARENESS_PER_MONITOR_AWARE = 2 ;https://learn.microsoft.com/en-us/windows/win32/hidpi/dpi-awareness-context Global Const $DPI_AWARENESS_CONTEXT_UNAWARE = $DPI_AWARENESS_UNAWARE - 1 Global Const $DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = $DPI_AWARENESS_UNAWARE - 2 Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = $DPI_AWARENESS_UNAWARE - 3 Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = $DPI_AWARENESS_UNAWARE - 4 Global Const $DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = $DPI_AWARENESS_UNAWARE - 5 ; enum _MONITOR_DPI_TYPE Global Enum $MDT_EFFECTIVE_DPI = 0, $MDT_ANGULAR_DPI, $MDT_RAW_DPI Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI ;Windows Message Codes Global Const $WM_DPICHANGED = 0x02E0, $WM_DPICHANGED_BEFOREPARENT = 0x02E2, $WM_DPICHANGED_AFTERPARENT = 0x02E3, $WM_GETDPISCALEDSIZE = 0x02E4 #EndRegion DPI Constants #Region WinAPI DPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-adjustwindowrectexfordpi Func _WinAPI_AdjustWindowRectExForDpi($dpi, $dwStyle, $dwExStyle, $bMenu = False) Local $tRECT = DllStructCreate($tagRECT) Local $aResult = DllCall("user32.dll", "bool", "AdjustWindowRectExForDpi", "struct*", $tRECT, "dword", $dwStyle, "bool", $bMenu, "dword", $dwExStyle, "int", $dpi) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If $aResult[0] Then Return SetError(2, @extended, 0) Return $tRECT EndFunc ;==>_WinAPI_AdjustWindowRectExForDpi ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfofordpi Func _WinAPI_SystemParametersInfoForDpi($uiAction, $uiParam, $pvParam, $fWinIni, $dpi) Local $aResult = DllCall("user32.dll", "bool", "SystemParametersInfoForDpi", "uint", $uiAction, "uint", $uiParam, "struct*", $pvParam, "uint", $fWinIni, "uint", $dpi) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SystemParametersInfoForDpi ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-inheritwindowmonitor Func _WinAPI_InheritWindowMonitor($hWnd, $hWndInherit) Local $aResult = DllCall("user32.dll", "bool", "InheritWindowMonitor", "hwnd", $hWnd, "hwnd", $hWndInherit) ;requires Win10 v1803+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_InheritWindowMonitor ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-isvaliddpiawarenesscontext Func _WinAPI_IsValidDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "bool", "IsValidDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_IsValidDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-logicaltophysicalpointforpermonitordpi Func _WinAPI_LogicalToPhysicalPointForPerMonitorDPI($hWnd) Local $tPOINT = DllStructCreate($tagPOINT) Local $aResult = DllCall("user32.dll", "bool", "LogicalToPhysicalPointForPerMonitorDPI", "hwnd", $hWnd, "struct*", $tPOINT) ;requires Win 8.1+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $tPOINT EndFunc ;==>_WinAPI_LogicalToPhysicalPointForPerMonitorDPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-physicaltologicalpointforpermonitordpi Func _WinAPI_PhysicalToLogicalPointForPerMonitorDPI($hWnd) Local $tPOINT = DllStructCreate($tagPOINT) Local $aResult = DllCall("user32.dll", "bool", "PhysicalToLogicalPointForPerMonitorDPI", "hwnd", $hWnd, "struct*", $tPOINT) ;requires Win 8.1+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $tPOINT EndFunc ;==>_WinAPI_PhysicalToLogicalPointForPerMonitorDPI Func _GDIPlus_GetDPI($hGUI = 0) _GDIPlus_Startup() Local $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) If @error Then Return SetError(1, @extended, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, 0) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() Return $aResult[2] EndFunc ;==>_GDIPlus_GetDPI Func _WinAPI_GetDPI($hWnd = 0) $hWnd = Not $hWnd ? _WinAPI_GetDesktopWindow() : $hWnd Local Const $hDC = _WinAPI_GetDC($hWnd) If @error Then Return SetError(1, 0, 0) Local Const $iDPI = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSX) If @error Or Not $iDPI Then _WinAPI_ReleaseDC($hWnd, $hDC) Return SetError(2, 0, 0) EndIf _WinAPI_ReleaseDC($hWnd, $hDC) Return $iDPI EndFunc ;==>_WinAPI_GetDPI ;https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getdpiformonitor Func _WinAPI_GetDpiForPrimaryMonitor($hMOnitor = 0, $dpiType = $MDT_DEFAULT) If $hMOnitor = 0 Then Local $aMonitors = _WinAPI_EnumDisplayMonitors() If @error Or Not IsArray($aMonitors) Then Return SetError(1, 0, 0) Local $i For $i = 1 To $aMonitors[0][0] If _WinAPI_GetMonitorInfo($aMonitors[$i][0])[2] = 1 Then $hMOnitor = $aMonitors[$i][0] ExitLoop EndIf Next EndIf Local $tx = DllStructCreate("int dpiX"), $tY = DllStructCreate("int dpiY") Local $aResult = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "handle", $hMOnitor, "long", $dpiType, "struct*", $tx, "struct*", $tY) If @error Or Not IsArray($aResult) Then Return SetError(2, 0, 0) Return $tx.dpiX EndFunc ;==>_WinAPI_GetDpiForPrimaryMonitor ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow Func _WinAPI_GetDpiForWindow($hWnd) Local $aResult = DllCall("user32.dll", "uint", "GetDpiForWindow", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiForWindow ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforsystem Func _WinAPI_GetDpiForSystem() Local $aResult = DllCall("user32.dll", "uint", "GetDpiForSystem") ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiForSystem ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getthreaddpiawarenesscontext Func _WinAPI_GetThreadDpiAwarenessContext() Local $aResult = DllCall("user32.dll", "uint", "GetThreadDpiAwarenessContext") ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetThreadDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpifromdpiawarenesscontext Func _WinAPI_GetDpiFromDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "uint", "GetDpiFromDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1803+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiFromDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getawarenessfromdpiawarenesscontext Func _WinAPI_GetAwarenessFromDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "uint", "GetAwarenessFromDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetAwarenessFromDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiawarenesscontextforprocess Func _WinAPI_GetDpiAwarenessContextForProcess($hProcess) Local $aResult = DllCall("user32.dll", "uint", "GetDpiAwarenessContextForProcess", "handle", $hProcess) ;requires Win10 v1803+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiAwarenessContextForProcess ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemdpiforprocess Func _WinAPI_GetSystemDpiForProcess($hProcess) Local $aResult = DllCall("user32.dll", "uint", "GetSystemDpiForProcess", "handle", $hProcess) ;requires Win10 v1803+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetSystemDpiForProcess ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowdpiawarenesscontext Func _WinAPI_GetWindowDpiAwarenessContext($hWnd) Local $aResult = DllCall("user32.dll", "uint", "GetWindowDpiAwarenessContext", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetWindowDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiawarenesscontext Func _WinAPI_SetProcessDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1703+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetProcessDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setthreaddpiawarenesscontext Func _WinAPI_SetThreadDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "uint", "SetThreadDpiAwarenessContext", @AutoItX64 ? "int64" : "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1703+ / Windows Server 2016+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If Not $aResult[0] Then Return SetError(2, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetThreadDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness Func _WinAPI_SetProcessDpiAwareness($PROCESS_DPI_AWARENESS = $DPI_AWARENESS_PER_MONITOR_AWARE) Local $aResult = DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $PROCESS_DPI_AWARENESS) ;requires Win 8.1+ / Server 2012 R2+ If Not IsArray($aResult) Or @error Then Return SetError(1, @extended, 0) If $aResult[0] Then Return SetError(2, $aResult[0], 0) Return $aResult[0] ;0 is S_OK EndFunc ;==>_WinAPI_SetProcessDpiAwareness Func _WinAPI_SetDPIAwareness($DPIAwareContext = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, $iMode = 1) Switch @OSBuild Case 6000 To 9199 Local $aResult = DllCall("user32.dll", "bool", "SetProcessDPIAware") ;requires Vista+ / Server 2008+ If Not $aResult[0] Then Return SetError(1, 0, 0) Case 9200 To 13999 $DPIAwareContext = ($DPIAwareContext < 0) ? 0 : ($DPIAwareContext > 2) ? 2 : $DPIAwareContext _WinAPI_SetProcessDpiAwareness($DPIAwareContext) If @error Then Return SetError(2, @error, 0) Case @OSBuild > 13999 $DPIAwareContext = ($DPIAwareContext < -5) ? -5 : ($DPIAwareContext > -1) ? -1 : $DPIAwareContext $iMode = ($iMode < 1) ? 1 : ($iMode > 2) ? 2 : $iMode Local $iResult Switch $iMode Case 1 $iResult = _WinAPI_SetProcessDpiAwarenessContext($DPIAwareContext) If Not $iResult Or @error Then Return SetError(3, 0, 0) Case 2 #cs Return DPI_AWARENESS_CONTEXT values $DPI_AWARENESS_CONTEXT_UNAWARE = 0x6010 / 24592 $DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = 0x9011 / 36881 $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = 0x12 / 18 $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = 0x22 / 34 $DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = 0x40006010 / 1073766416 #ce $iResult = _WinAPI_SetThreadDpiAwarenessContext($DPIAwareContext) If Not $iResult Or @error Then Return SetError(4, 0, 0) EndSwitch EndSwitch Local $iDPI If @OSBuild < 9200 Then $iDPI = _WinAPI_GetDPI() If @error Or Not $iDPI Then Return SetError(5, 0, 0) Else $iDPI = _WinAPI_GetDpiForPrimaryMonitor() If @error Or Not $iDPI Then Return SetError(6, 0, 0) EndIf Return $iDPI EndFunc ;==>_WinAPI_SetDPIAwareness #EndRegion WinAPI DPI Example.au3: ; AutoIt GUI Example ; Created: 17/01/2005 - CyberSlug ; Modifed: 05/12/2011 - guinness ; Modifed: 09/06/2014 - mLipok ; Modifed: 15/10/2018 - mLipok ; Modifed: 14/08/2023 - UEZ #AutoIt3Wrapper_Change2CUI=n #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so #AutoIt3Wrapper_Res_HiDpi=n ;must be n otherwise _WinAPI_SetDPIAwareness() function will fail! #AutoIt3Wrapper_UseX64=n #Region INCLUDE #include <AVIConstants.au3> #include <GuiConstantsEx.au3> #include <TreeViewConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIGdiDC.au3> #include <WindowsConstants.au3> #include "_WinAPI_DPI.au3" #EndRegion INCLUDE #Region INITIALIZATION and EXIT Global $aCtrl[43][6], $ahWnd[2][10], $g_iDPI_ratio1, $g_iDPI_ratio2, $iw = 400, $ih = 200 _Example() ; Finished! #EndRegion INITIALIZATION and EXIT Func _Example() Local $AWARENESS Switch @OSBuild Case 9200 To 13999 $AWARENESS = $DPI_AWARENESS_PER_MONITOR_AWARE Case @OSBuild > 13999 $AWARENESS = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 EndSwitch Local $iDPI = _WinAPI_SetDPIAwareness($AWARENESS, 2), $iDPI_def = 96 If $iDPI = 0 Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to set DPI awareness!!!", 10) $g_iDPI_ratio1 = $iDPI / $iDPI_def $g_iDPI_ratio2 = $iDPI_def / $iDPI #Region GUI Local $sPath = RegRead("HKLM\SOFTWARE\" & (@AutoItX64 ? "WOW6432Node\" : "") & "AutoIt v3\AutoIt", "InstallDir") $sPath = ($sPath = "" ? @ProgramFilesDir & "\AutoIt3\" : $sPath & "\") ;assume default path $ahWnd[0][1] = 8.5 * $g_iDPI_ratio1 $ahWnd[0][0] = GUICreate("DPI Sample GUI", 400 * $g_iDPI_ratio1, 400 * $g_iDPI_ratio1) GUISetIcon(@SystemDir & "\mspaint.exe", 0) GUISetFont($ahWnd[0][1], 400, 0, "Arial", $ahWnd[0][0], $CLEARTYPE_QUALITY) #EndRegion GUI #Region MENU $aCtrl[1][0] = GUICtrlCreateMenu("Menu &One") $aCtrl[2][0] = GUICtrlCreateMenu("Menu &Two") $aCtrl[3][0] = GUICtrlCreateMenu("Menu Th&ree") $aCtrl[4][0] = GUICtrlCreateMenu("Menu &Four") GUICtrlCreateMenuItem('SubMenu One &A', $aCtrl[1][0]) GUICtrlCreateMenuItem('SubMenu One &B', $aCtrl[1][0]) #EndRegion MENU #Region CONTEXT MENU $aCtrl[5][0] = GUICtrlCreateContextMenu() GUICtrlCreateMenuItem("Context Menu", $aCtrl[5][0]) GUICtrlCreateMenuItem("", $aCtrl[5][0]) ; Separator GUICtrlCreateMenuItem("&Properties", $aCtrl[5][0]) #EndRegion CONTEXT MENU #Region PIC $aCtrl[6][2] = 0 ;x $aCtrl[6][3] = 0 ;y $aCtrl[6][4] = 169 ;w $aCtrl[6][5] = 68 ;h $aCtrl[6][0] = GUICtrlCreatePic($sPath & "Examples\GUI\logo4.gif", $aCtrl[6][2] * $g_iDPI_ratio1, $aCtrl[6][3] * $g_iDPI_ratio1, $aCtrl[6][4] * $g_iDPI_ratio1, $aCtrl[6][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region PIC') $aCtrl[7][2] = 75 $aCtrl[7][3] = 1 $aCtrl[7][4] = 80 $aCtrl[7][5] = 16 $aCtrl[7][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[7][0] = GUICtrlCreateLabel("Sample Pic", $aCtrl[7][2] * $g_iDPI_ratio1, $aCtrl[7][3] * $g_iDPI_ratio1, $aCtrl[7][4] * $g_iDPI_ratio1, $aCtrl[7][5] * $g_iDPI_ratio1) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetFont(-1, $aCtrl[7][1] * $g_iDPI_ratio1) #EndRegion PIC #Region AVI $aCtrl[8][2] = 180 $aCtrl[8][3] = 10 $aCtrl[8][4] = 32 $aCtrl[8][5] = 32 $aCtrl[8][0] = GUICtrlCreateAvi($sPath & "Examples\GUI\SampleAVI.avi", 0, $aCtrl[8][2] * $g_iDPI_ratio1, $aCtrl[8][3] * $g_iDPI_ratio1, $aCtrl[8][4] * $g_iDPI_ratio1, $aCtrl[8][5] * $g_iDPI_ratio1, $ACS_AUTOPLAY) GUICtrlSetTip(-1, '#Region AVI') ; TODO $aCtrl[9][2] = 175 $aCtrl[9][3] = 50 $aCtrl[9][4] = 50 $aCtrl[9][5] = 12 $aCtrl[9][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[9][0] = GUICtrlCreateLabel("Sample avi", $aCtrl[9][2] * $g_iDPI_ratio1, $aCtrl[9][3] * $g_iDPI_ratio1, $aCtrl[9][4] * $g_iDPI_ratio1, $aCtrl[9][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region AVI - Label') GUICtrlSetFont(-1, $aCtrl[9][1] * $g_iDPI_ratio1) #EndRegion AVI #Region TAB $aCtrl[10][2] = 240 $aCtrl[10][3] = 0 $aCtrl[10][4] = 150 $aCtrl[10][5] = 70 $aCtrl[10][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[10][0] = GUICtrlCreateTab($aCtrl[10][2] * $g_iDPI_ratio1, $aCtrl[10][3] * $g_iDPI_ratio1, $aCtrl[10][4] * $g_iDPI_ratio1, $aCtrl[10][5] * $g_iDPI_ratio1) GUICtrlSetFont(-1, $aCtrl[10][1] * $g_iDPI_ratio1) $aCtrl[11][0] = GUICtrlCreateTabItem("One") GUICtrlSetTip(-1, '#Region TAB1') $aCtrl[12][2] = 244 $aCtrl[12][3] = 35 $aCtrl[12][4] = 140 $aCtrl[12][5] = 24 $aCtrl[12][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[12][0] = GUICtrlCreateLabel("Sample Tab with TabItems", $aCtrl[12][2] * $g_iDPI_ratio1, $aCtrl[12][3] * $g_iDPI_ratio1, $aCtrl[12][4] * $g_iDPI_ratio1, $aCtrl[12][5] * $g_iDPI_ratio1) GUICtrlSetFont(-1, $aCtrl[12][1] * $g_iDPI_ratio1) $aCtrl[13][0] = GUICtrlCreateTabItem("Two") GUICtrlSetTip(-1, '#Region TAB2') $aCtrl[14][0] = GUICtrlCreateTabItem("Three") GUICtrlSetTip(-1, '#Region TAB3') GUICtrlCreateTabItem("") #EndRegion TAB #Region COMBO $aCtrl[15][2] = 250 $aCtrl[15][3] = 80 $aCtrl[15][4] = 120 $aCtrl[15][5] = 100 $aCtrl[15][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[15][0] = GUICtrlCreateCombo("Sample Combo", $aCtrl[15][2] * $g_iDPI_ratio1, $aCtrl[15][3] * $g_iDPI_ratio1, $aCtrl[15][4] * $g_iDPI_ratio1, $aCtrl[15][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region COMBO') GUICtrlSetFont(-1, $aCtrl[15][1] * $g_iDPI_ratio1) #EndRegion COMBO #Region PROGRESS $aCtrl[16][2] = 60 $aCtrl[16][3] = 80 $aCtrl[16][4] = 150 $aCtrl[16][5] = 20 $aCtrl[16][0] = GUICtrlCreateProgress($aCtrl[16][2] * $g_iDPI_ratio1, $aCtrl[16][3] * $g_iDPI_ratio1, $aCtrl[16][4] * $g_iDPI_ratio1, $aCtrl[16][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region PROGRES') GUICtrlSetData(-1, 60) $aCtrl[17][2] = 5 $aCtrl[17][3] = 82 $aCtrl[17][4] = 50 $aCtrl[17][5] = 18 $aCtrl[17][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[17][0] = GUICtrlCreateLabel("Progress:", $aCtrl[17][2] * $g_iDPI_ratio1, $aCtrl[17][3] * $g_iDPI_ratio1, $aCtrl[17][4] * $g_iDPI_ratio1, $aCtrl[17][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region PROGRES - Label') GUICtrlSetFont(-1, $aCtrl[17][1] * $g_iDPI_ratio1) #EndRegion PROGRESS #Region EDIT $aCtrl[18][2] = 10 $aCtrl[18][3] = 110 $aCtrl[18][4] = 150 $aCtrl[18][5] = 70 $aCtrl[18][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[18][0] = GUICtrlCreateEdit(@CRLF & " Sample Edit Control", $aCtrl[18][2] * $g_iDPI_ratio1, $aCtrl[18][3] * $g_iDPI_ratio1, $aCtrl[18][4] * $g_iDPI_ratio1, $aCtrl[18][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region EDIT') GUICtrlSetFont(-1, $aCtrl[18][1] * $g_iDPI_ratio1) #EndRegion EDIT #Region LIST $aCtrl[19][2] = 5 $aCtrl[19][3] = 190 $aCtrl[19][4] = 100 $aCtrl[19][5] = 90 $aCtrl[19][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[19][0] = GUICtrlCreateList("", $aCtrl[19][2] * $g_iDPI_ratio1, $aCtrl[19][3] * $g_iDPI_ratio1, $aCtrl[19][4] * $g_iDPI_ratio1, $aCtrl[19][5] * $g_iDPI_ratio1) GUICtrlSetFont(-1, $aCtrl[19][1] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region LIST') GUICtrlSetData(-1, "A.Sample|B.List|C.Control|D.Here", "B.List") #EndRegion LIST #Region ICON $aCtrl[20][2] = 175 $aCtrl[20][3] = 120 $aCtrl[20][4] = 32 $aCtrl[20][5] = 32 $aCtrl[20][0] = GUICtrlCreateIcon("explorer.exe", 0, $aCtrl[20][2] * $g_iDPI_ratio1, $aCtrl[20][3] * $g_iDPI_ratio1, $aCtrl[20][4] * $g_iDPI_ratio1, $aCtrl[20][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region ICON') $aCtrl[21][2] = 180 $aCtrl[21][3] = 160 $aCtrl[21][4] = 50 $aCtrl[21][5] = 20 $aCtrl[21][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[21][0] = GUICtrlCreateLabel("Icon", $aCtrl[21][2] * $g_iDPI_ratio1, $aCtrl[21][3] * $g_iDPI_ratio1, $aCtrl[21][4] * $g_iDPI_ratio1, $aCtrl[21][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region ICON - Label') GUICtrlSetFont(-1, $aCtrl[21][1] * $g_iDPI_ratio1) #EndRegion ICON #Region LIST VIEW $aCtrl[22][2] = 110 $aCtrl[22][3] = 190 $aCtrl[22][4] = 110 $aCtrl[22][5] = 80 $aCtrl[22][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[22][0] = GUICtrlCreateListView("Sample|ListView|", $aCtrl[22][2] * $g_iDPI_ratio1, $aCtrl[22][3] * $g_iDPI_ratio1, $aCtrl[22][4] * $g_iDPI_ratio1, $aCtrl[22][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region LIST VIEW') GUICtrlSetFont(-1, $aCtrl[22][1] * $g_iDPI_ratio1) GUICtrlCreateListViewItem("A|One", $aCtrl[22][0]) GUICtrlCreateListViewItem("B|Two", $aCtrl[22][0]) GUICtrlCreateListViewItem("C|Three", $aCtrl[22][0]) #EndRegion LIST VIEW #Region GROUP WITH RADIO BUTTONS $aCtrl[23][2] = 230 $aCtrl[23][3] = 120 $aCtrl[23][4] = 110 $aCtrl[23][5] = 80 $aCtrl[23][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[23][0] = GUICtrlCreateGroup("Sample Group", $aCtrl[23][2] * $g_iDPI_ratio1, $aCtrl[23][3] * $g_iDPI_ratio1, $aCtrl[23][4] * $g_iDPI_ratio1, $aCtrl[23][5] * $g_iDPI_ratio1) GUICtrlSetFont(-1, $aCtrl[22][1] * $g_iDPI_ratio1) $aCtrl[24][2] = 250 $aCtrl[24][3] = 140 $aCtrl[24][4] = 80 $aCtrl[24][5] = 32 $aCtrl[24][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[24][0] = GUICtrlCreateRadio("Radio One", $aCtrl[24][2] * $g_iDPI_ratio1, $aCtrl[24][3] * $g_iDPI_ratio1, $aCtrl[24][4] * $g_iDPI_ratio1, $aCtrl[24][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region GROUP WITH RADIO BUTTONS- RADIO1') GUICtrlSetFont(-1, $aCtrl[24][1] * $g_iDPI_ratio1) GUICtrlSetState(-1, $GUI_CHECKED) $aCtrl[25][2] = 250 $aCtrl[25][3] = 165 $aCtrl[25][4] = 80 $aCtrl[25][5] = 32 $aCtrl[25][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[25][0] = GUICtrlCreateRadio("Radio Two", $aCtrl[25][2] * $g_iDPI_ratio1, $aCtrl[25][3] * $g_iDPI_ratio1, $aCtrl[25][4] * $g_iDPI_ratio1, $aCtrl[25][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region GROUP WITH RADIO BUTTONS- RADIO2') GUICtrlSetFont(-1, $aCtrl[25][1] * $g_iDPI_ratio1) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group #EndRegion GROUP WITH RADIO BUTTONS #Region UPDOWN $aCtrl[26][2] = 350 $aCtrl[26][3] = 113 $aCtrl[26][4] = 40 $aCtrl[26][5] = 12 $aCtrl[26][1] = 8 * $g_iDPI_ratio2 $aCtrl[26][0] = GUICtrlCreateLabel("UpDown", $aCtrl[26][2] * $g_iDPI_ratio1, $aCtrl[26][3] * $g_iDPI_ratio1, $aCtrl[26][4] * $g_iDPI_ratio1, $aCtrl[26][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region UPDOWN - Label') GUICtrlSetFont(-1, $aCtrl[26][1] * $g_iDPI_ratio1) $aCtrl[27][2] = 350 $aCtrl[27][3] = 130 $aCtrl[27][4] = 40 $aCtrl[27][5] = 20 $aCtrl[27][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[27][0] = GUICtrlCreateInput("42", $aCtrl[27][2] * $g_iDPI_ratio1, $aCtrl[27][3] * $g_iDPI_ratio1, $aCtrl[27][4] * $g_iDPI_ratio1, $aCtrl[27][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region UPDOWN - Input') GUICtrlSetFont(-1, $aCtrl[27][1] * $g_iDPI_ratio1) $aCtrl[28][0] = GUICtrlCreateUpdown(-1) GUICtrlSetTip(-1, '#Region UPDOWN - Updown') #EndRegion UPDOWN #Region LABEL $aCtrl[29][2] = 350 $aCtrl[29][3] = 165 $aCtrl[29][4] = 40 $aCtrl[29][5] = 40 $aCtrl[29][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[29][0] = GUICtrlCreateLabel("Green" & @CRLF & "Label", $aCtrl[29][2] * $g_iDPI_ratio1, $aCtrl[29][3] * $g_iDPI_ratio1, $aCtrl[29][4] * $g_iDPI_ratio1, $aCtrl[29][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region LABEL') GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetFont(-1, $aCtrl[29][1] * $g_iDPI_ratio1) #EndRegion LABEL #Region SLIDER $aCtrl[30][2] = 235 $aCtrl[30][3] = 215 $aCtrl[30][4] = 40 $aCtrl[30][5] = 16 $aCtrl[30][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[30][0] = GUICtrlCreateLabel("Slider:", $aCtrl[30][2] * $g_iDPI_ratio1, $aCtrl[30][3] * $g_iDPI_ratio1, $aCtrl[30][4] * $g_iDPI_ratio1, $aCtrl[30][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region SLIDER - Label') GUICtrlSetFont(-1, $aCtrl[30][1] * $g_iDPI_ratio1) $aCtrl[31][2] = 270 $aCtrl[31][3] = 210 $aCtrl[31][4] = 120 $aCtrl[31][5] = 30 $aCtrl[31][0] = GUICtrlCreateSlider($aCtrl[31][2] * $g_iDPI_ratio1, $aCtrl[31][3] * $g_iDPI_ratio1, $aCtrl[31][4] * $g_iDPI_ratio1, $aCtrl[31][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region SLIDER') GUICtrlSetData(-1, 30) #EndRegion SLIDER #Region INPUT $aCtrl[32][2] = 235 $aCtrl[32][3] = 255 $aCtrl[32][4] = 130 $aCtrl[32][5] = 20 $aCtrl[32][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[32][0] = GUICtrlCreateInput("Sample Input Box", $aCtrl[32][2] * $g_iDPI_ratio1, $aCtrl[32][3] * $g_iDPI_ratio1, $aCtrl[32][4] * $g_iDPI_ratio1, $aCtrl[32][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region INPUT') GUICtrlSetFont(-1, $aCtrl[32][1] * $g_iDPI_ratio1) #EndRegion INPUT #Region DATE $aCtrl[33][2] = 5 $aCtrl[33][3] = 280 $aCtrl[33][4] = 200 $aCtrl[33][5] = 20 $aCtrl[33][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[33][0] = GUICtrlCreateDate("", $aCtrl[33][2] * $g_iDPI_ratio1, $aCtrl[33][3] * $g_iDPI_ratio1, $aCtrl[33][4] * $g_iDPI_ratio1, $aCtrl[33][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region DATE') GUICtrlSetFont(-1, $aCtrl[33][1] * $g_iDPI_ratio1) $aCtrl[34][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[34][2] = 10 $aCtrl[34][3] = 305 $aCtrl[34][4] = 200 $aCtrl[34][5] = 20 $aCtrl[34][0] = GUICtrlCreateLabel("(Date control expands into a calendar)", $aCtrl[34][2] * $g_iDPI_ratio1, $aCtrl[34][3] * $g_iDPI_ratio1, $aCtrl[34][4] * $g_iDPI_ratio1, $aCtrl[34][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region DATE - Label') GUICtrlSetFont(-1, $aCtrl[34][1] * $g_iDPI_ratio1) #EndRegion DATE #Region BUTTON $aCtrl[35][2] = 10 $aCtrl[35][3] = 330 $aCtrl[35][4] = 100 $aCtrl[35][5] = 30 $aCtrl[35][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[35][0] = GUICtrlCreateButton("Click me :-)", $aCtrl[35][2] * $g_iDPI_ratio1, $aCtrl[35][3] * $g_iDPI_ratio1, $aCtrl[35][4] * $g_iDPI_ratio1, $aCtrl[35][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region BUTTON') GUICtrlSetFont(-1, $aCtrl[35][1] * $g_iDPI_ratio1) #EndRegion BUTTON #Region CHECKBOX $aCtrl[36][2] = 130 $aCtrl[36][3] = 335 $aCtrl[36][4] = 80 $aCtrl[36][5] = 20 $aCtrl[36][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[36][0] = GUICtrlCreateCheckbox("Checkbox", $aCtrl[36][2] * $g_iDPI_ratio1, $aCtrl[36][3] * $g_iDPI_ratio1, $aCtrl[36][4] * $g_iDPI_ratio1, $aCtrl[36][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region CHECKBOX') GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetFont(-1, $aCtrl[36][1] * $g_iDPI_ratio1) #EndRegion CHECKBOX #Region TREEVIEW ONE $aCtrl[37][2] = 210 $aCtrl[37][3] = 290 $aCtrl[37][4] = 80 $aCtrl[37][5] = 80 $aCtrl[37][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[37][0] = GUICtrlCreateTreeView($aCtrl[37][2] * $g_iDPI_ratio1, $aCtrl[37][3] * $g_iDPI_ratio1, $aCtrl[37][4] * $g_iDPI_ratio1, $aCtrl[37][5] * $g_iDPI_ratio1) GUICtrlSetTip(-1, '#Region TREEVIEW ONE') GUICtrlSetFont(-1, $aCtrl[37][1] * $g_iDPI_ratio1) $aCtrl[38][0] = GUICtrlCreateTreeViewItem("TreeView", $aCtrl[37][0]) GUICtrlCreateTreeViewItem("Item1", $aCtrl[38][0]) GUICtrlCreateTreeViewItem("Item2", $aCtrl[38][0]) GUICtrlCreateTreeViewItem("Foo", -1) GUICtrlSetState($aCtrl[38][0], $GUI_EXPAND) #EndRegion TREEVIEW ONE #Region TREEVIEW TWO $aCtrl[39][2] = 295 $aCtrl[39][3] = 290 $aCtrl[39][4] = 103 $aCtrl[39][5] = 80 $aCtrl[39][1] = 8.5 * $g_iDPI_ratio2 $aCtrl[39][0] = GUICtrlCreateTreeView($aCtrl[39][2] * $g_iDPI_ratio1, $aCtrl[39][3] * $g_iDPI_ratio1, $aCtrl[39][4] * $g_iDPI_ratio1, $aCtrl[39][5] * $g_iDPI_ratio1, $TVS_CHECKBOXES) GUICtrlSetTip(-1, '#Region TREEVIEW TWO') GUICtrlSetFont(-1, $aCtrl[39][1] * $g_iDPI_ratio1) GUICtrlCreateTreeViewItem("TreeView", $aCtrl[39][0]) GUICtrlCreateTreeViewItem("With", $aCtrl[39][0]) GUICtrlCreateTreeViewItem("$TVS_CHECKBOXES", $aCtrl[39][0]) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateTreeViewItem("Style", $aCtrl[39][0]) #EndRegion TREEVIEW TWO #Region GUI MESSAGE LOOP GUISetState(@SW_SHOW) If @OSBuild > 9599 Then GUIRegisterMsg($WM_DPICHANGED, "WM_DPICHANGED") ;requires Win 8.1+ / Server 2012 R2+ GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") GUIRegisterMsg($WM_SIZE, "WM_SIZE") Local $hGUI_child, $hImage, $hGDIBitmap, $hGfx, $hPath, $hFamily, $hFormat, $tLayout, $hPen, $hBrush, $hB, $aGUIGetMsg _GDIPlus_Startup() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _GDIPlus_PathDispose($hPath) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_ImageDispose ($hImage) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() GUIRegisterMsg($WM_DPICHANGED, "") GUIRegisterMsg(WM_GETMINMAXINFO, "") GUIRegisterMsg(WM_SIZE, "") GUIDelete() Exit Case $aCtrl[35][0] If $hImage Then $hImage = _GDIPlus_ImageDispose($hImage) $hImage = _GDIPlus_BitmapCreateFromScan0($iw * $g_iDPI_ratio1, $ih * $g_iDPI_ratio1) If $hGfx Then _GDIPlus_GraphicsDispose($hGfx) $hGfx = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsSetTextRenderingHint($hGfx, $GDIP_TEXTRENDERINGHINTANTIALIAS) _GDIPlus_GraphicsSetSmoothingMode($hGfx, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsClear($hGfx, 0xFFF0F0F0) If $hPath Then _GDIPlus_PathDispose($hPath) $hPath = _GDIPlus_PathCreate() If $hFamily Then _GDIPlus_FontFamilyDispose($hFamily) $hFamily = _GDIPlus_FontFamilyCreate("Arial") If $hFormat Then _GDIPlus_StringFormatDispose($hFormat) $hFormat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) $tLayout = _GDIPlus_RectFCreate(0, 0, $iw * $g_iDPI_ratio1, $ih * $g_iDPI_ratio1) _GDIPlus_PathAddString($hPath, "Hello World!", $tLayout, $hFamily, 0, 50 * $g_iDPI_ratio1, $hFormat) If $hPen Then _GDIPlus_PenDispose($hPen) $hPen = _GDIPlus_PenCreate(0xFF000000, 8) _GDIPlus_PenSetLineJoin($hPen, 2) _GDIPlus_GraphicsDrawPath($hGfx, $hPath, $hPen) If $hBrush Then _GDIPlus_BrushDispose($hBrush) $hBrush = _GDIPlus_BrushCreateSolid(0xFF00FF00) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrush) If $hGDIBitmap Then _WinAPI_DeleteObject($hGDIBitmap) $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) Local $aGUI_Pos = WinGetPos($ahWnd[0][0]) $ahWnd[1][0] = GUICreate("GDI+ Child Window", $iw * $g_iDPI_ratio1, $ih * $g_iDPI_ratio1, $aGUI_Pos[0] - ($aGUI_Pos[2] - $iw * $g_iDPI_ratio1) / 2, $aGUI_Pos[1] + $ih * $g_iDPI_ratio1 / 2, $WS_SIZEBOX, -1, $ahWnd[0][0]) $aCtrl[40][2] = 0 $aCtrl[40][3] = 0 $aCtrl[40][4] = $iw $aCtrl[40][5] = $ih $aCtrl[40][0] = GUICtrlCreatePic("", $aCtrl[40][2], $aCtrl[40][3], $aCtrl[40][4] * $g_iDPI_ratio1, $aCtrl[40][5] * $g_iDPI_ratio1) _WinAPI_DeleteObject(GUICtrlSendMsg($aCtrl[40][0], $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap)) GUISetState(@SW_SHOW, $ahWnd[1][0]) While 1 $aGUIGetMsg = GUIGetMsg(1) Switch $aGUIGetMsg[1] Case $ahWnd[1][0] Switch $aGUIGetMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($ahWnd[1][0]) ExitLoop EndSwitch EndSwitch WEnd EndSwitch WEnd #EndRegion GUI MESSAGE LOOP EndFunc ;==>_Example Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Switch $hWnd Case $ahWnd[1][0] Local $aSize = ControlGetPos($ahWnd[1][0], "", $aCtrl[40][0]) $aCtrl[40][2] = $aSize[0] $aCtrl[40][3] = $aSize[1] $aCtrl[40][4] = _WinAPI_LoWord($lParam) $aCtrl[40][5] = _WinAPI_HiWord($lParam) GUICtrlSetPos($aCtrl[40][0], $aCtrl[40][2], $aCtrl[40][3], $aCtrl[40][4], $aCtrl[40][5]) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE Func WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) If $hWnd = $ahWnd[1][0] Then Local $minmaxinfo = DllStructCreate("long ptReservedX;long ptReservedY;long ptMaxSizeX; long ptMaxSizeY;long ptMaxPositionX;long ptMaxPositionY;long ptMinTrackSizeX;long ptMinTrackSizeY;long ptMaxTrackSizeX;long ptMaxTrackSizeY ", $lParam) $minmaxinfo.ptMinTrackSizeX = $iw / 2 $minmaxinfo.ptMinTrackSizeY = $ih / 2 $minmaxinfo.ptMaxTrackSizeX = $iw * 3 $minmaxinfo.ptMaxTrackSizeY = $ih * 3 EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_GETMINMAXINFO Func WM_DPICHANGED($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg Local $iDPI = _WinAPI_LoWord($wParam) ConsoleWrite("DPI change triggered! DPI: " & $iDPI & @CRLF) $g_iDPI_ratio1 = $iDPI / 96 $g_iDPI_ratio2 = $g_iDPI_ratio1 ^ -1 Local $tRECT = DllStructCreate($tagRECT, $lParam) Local $iX = $tRECT.left, $iY = $tRECT.top, $iW = $tRECT.right - $iX, $iH = $tRECT.bottom - $iY, $i Switch $hWnd Case $ahWnd[0][0] _WinAPI_SetWindowPos($ahWnd[0][0], 0, $iX, $iY, $iW, $iH, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) For $i = 0 To 39 If $aCtrl[$i][1] Then GUICtrlSetFont($aCtrl[$i][0], $aCtrl[$i][1] * $g_iDPI_ratio1) If $aCtrl[$i][4] Then GUICtrlSetPos($aCtrl[$i][0], $aCtrl[$i][2] * $g_iDPI_ratio1, $aCtrl[$i][3] * $g_iDPI_ratio1, $aCtrl[$i][4] * $g_iDPI_ratio1, $aCtrl[$i][5] * $g_iDPI_ratio1) Next _WinAPI_UpdateWindow($ahWnd[0][0]) Case $ahWnd[1][0] $i = 40 _WinAPI_SetWindowPos($ahWnd[1][0], 0, $iX, $iY, $iW, $iH, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) GUICtrlSetPos($aCtrl[$i][0], $aCtrl[$i][2], $aCtrl[$i][3], $aCtrl[$i][4], $aCtrl[$i][5]) _WinAPI_UpdateWindow($ahWnd[1][0]) EndSwitch Return 1 EndFunc ;==>WM_DPICHANGED THX.
    1 point
×
×
  • Create New...