Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 11/30/2025 in Posts

  1. ...to be or not to be... ...to theme or not to theme.., that is a good question. I believe that in your project, theme-ing each control will not be possible. Don't worry about themes but do use proper windows coloring if you need to color something: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 400, 100) GUICtrlCreateLabel("Label just as is, will be seen", 10, 10, 380, 17, -1, $WS_EX_STATICEDGE) GUICtrlCreateLabel("Label with COLOR_HIGHLIGHT will be seen as it should", 10, 40, 380, 17, -1, $WS_EX_STATICEDGE) GUICtrlSetColor(-1, _WinAPI_SwitchColor(_WinAPI_GetSysColor($COLOR_HIGHLIGHT))) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit EndSwitch WEnd Therefore, if we respect default coloring, everything should be visible by default. Then give users the ability to use custom colors. But by default, default theme colors should be sufficient.
    3 points
  2. I present to your attention an alternative version of the window dividers CtrlSplitter. The Static element is used as a splitter separator, and the functioning of the separators is fully implemented in their window procedure. Example.au3 CtrlSplitNotify.au3 CtrlSplit.au3 ApiDPI.au3
    3 points
  3. argumentum

    AutoIt Snippets

    How do you translate "Desktop" to the user's language ? #include <WinAPIRes.au3> Exit ConsoleWrite(@CRLF & '>' & _LoadString_shell32(4162) & '<' & @CRLF & @CRLF) Func _LoadString_shell32($iID) ; 4162 = "Desktop" Local $sText = "", $hInstance = _WinAPI_LoadLibraryEx("shell32.dll", $LOAD_LIBRARY_AS_DATAFILE) If $hInstance Then $sText = _WinAPI_LoadString($hInstance, $iID) _WinAPI_FreeLibrary($hInstance) EndIf Return SetError(@error, @extended, $sText) EndFunc ;==>_LoadString_shell32 If your GUI is simple, you may just find all the strings you use in shell32.dll
    3 points
  4. Try powershell : Get-PhysicalDisk | Select-Object FriendlyName, DeviceID, SerialNumber, AdapterSerialNumber AdapterSerialNumber looks good.
    2 points
  5. you can do it like this While True Local $iMsg = GUIGetMsg() Switch $iMsg Case -3 ;$GUI_EVENT_CLOSE __TreeListExplorer_Shutdown() Exit Case -12, -6 ;$GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE Local $aClientSize = WinGetClientSize($hChildLV) ConsoleWrite("SetWindowPos=" & _WinAPI_SetWindowPos($g_hHeader, 0, 0, 0, $aClientSize[0], 25, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) & @CRLF) EndSwitch WEnd Edit: I made some additional changes, so that the width matches the width of the Listview $hChildLV = _GUIFrame_GetHandle($iFrame_A, 2) ConsoleWrite("$hChildLV=" & $hChildLV & @CRLF) $g_hHeader = _GUICtrlHeader_Create($hChildLV) _WinAPI_SetWindowPos($g_hHeader, 0, 4, 0, $aWinSize2[0] - 11, 25, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) ; 👈 _GUICtrlHeader_AddItem($g_hHeader, "Name", 300) _GUICtrlHeader_AddItem($g_hHeader, "Size", 100) _GUICtrlHeader_AddItem($g_hHeader, "Date Created", 150) and, after a little observation, I noticed that after each change of _GUIFrame, it updates the GUI with Msg 4, so While True Local $iMsg = GUIGetMsg() Switch $iMsg Case -3 ;$GUI_EVENT_CLOSE __TreeListExplorer_Shutdown() Exit Case -12, -6, 4 ;$GUI_EVENT_RESIZED, $GUI_EVENT_MAXIMIZE, Frames resizing $aWinSize2 = WinGetClientSize($hChildLV) _WinAPI_SetWindowPos($g_hHeader, 0, 4, 0, $aWinSize2[0] - 11, 25, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) EndSwitch WEnd indeed, this (with Msg 4) updates the GUI after resizing the _GUIFrame, and not during it
    2 points
  6. @pixelsearch That is some seriously incredible work! That real-time resize synchronization is a beautiful thing. Thank you for figuring that out. I don't think I realized how necessary that really was. I have a fix for this as well as a few other things. You also mentioned a script hang at times when reordering columns. I haven't experienced that yet but I'll see if there is something I can do about the timing of it. This is nice. I didn't realize that could be used to measure individual controls. I was using the following: Local $aRect = _GUICtrlHeader_GetItemRect($g_hHeader, 0) $sHeaderHeight = $aRect[3] But yours is less code so that seems better. There were some flickering issues with the horizontal scrolling as well as the resizing of header items. Also the issue with the scrollbars turning gray. I have solved all of those issues and made all of those silky smooth. It took me 2-3 hours to really figure it out. And I may have lost my marbles a few times. But in the end, it is silky smooth. I added a call to _changeExStyles() in function _resizeHeaderItems() and function _resizeLVCols() Func _changeExStyles() ; remove WS_EX_COMPOSITED from GUI __WinAPI_Set_Window_Style($g_hGUI, $WS_EX_COMPOSITED, False, True) ; add LVS_EX_DOUBLEBUFFER to ListView _GUICtrlListView_SetExtendedListViewStyle($g_hListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ; set adlib to reset those values AdlibRegister("_resetExStylesAdlib", 3000) EndFunc Func _resetExStylesAdlib() ; add WS_EX_COMPOSITED to GUI __WinAPI_Set_Window_Style($g_hGUI, $WS_EX_COMPOSITED, True, True) ; remove LVS_EX_DOUBLEBUFFER from ListView _GUICtrlListView_SetExtendedListViewStyle($g_hListview, $LVS_EX_FULLROWSELECT) ; unregister adlib AdlibUnRegister("_resetExStylesAdlib") EndFunc The idea is that the extended styles for the GUI and ListView are changed temporarily (3 seconds by Adlib) before being reset back to default. This way, all of the problems are solved with header and ListView when accessing them. Then reset back to default so that any resizing or separator movement in the main GUI will still be smooth. Silky smooth script in full: #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StructureConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> #include <WinAPISys.au3> ; DPI DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_hChild, $g_hHeader, $g_hListview, $g_bHeaderEndDrag Example() Func Example() $g_hGUI = GUICreate("Example", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) GUISetBkColor(0x202020) GUISetState(@SW_SHOW, $g_hGUI) $g_hChild = GUICreate("ChildWindow", 320, 320, 40, 40, $WS_CHILD, -1, $g_hGUI) GUISetBkColor(0x606060) $g_hHeader = _GUICtrlHeader_Create($g_hChild) Local $iHeaderHeight = _WinAPI_GetWindowHeight($g_hHeader) For $i = 0 To 3 _GUICtrlHeader_AddItem($g_hHeader, "Column" & $i, 100) Next Local $idListview = GUICtrlCreateListView("col0|col1|col2|col3", 0, $iHeaderHeight, 320, 320 - $iHeaderHeight, _ BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER), $LVS_EX_FULLROWSELECT) $g_hListview = GUICtrlGetHandle($idListview) _GUICtrlListView_BeginUpdate($idListview) For $i = 1 To 30 GUICtrlCreateListViewItem("item" & $i & "-0|item" & $i & "-1|item" & $i & "-2|item" & $i & "-3", $idListview) Next _GUICtrlListView_EndUpdate($idListview) ; resize listview columns to match header widths _resizeLVCols() GUISetState(@SW_SHOW, $g_hChild) ; get rid of dotted rectangle in listview, when an item got the focus GUICtrlSendMsg($idListview, $WM_CHANGEUISTATE, 65537, 0) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If $g_bHeaderEndDrag Then $g_bHeaderEndDrag = False _reorderLVCols() EndIf WEnd _GUICtrlHeader_Destroy($g_hHeader) GUIDelete($g_hChild) GUIDelete($g_hGUI) EndFunc ;==>Example Func _changeExStyles() ; remove WS_EX_COMPOSITED from GUI __WinAPI_Set_Window_Style($g_hGUI, $WS_EX_COMPOSITED, False, True) ; add LVS_EX_DOUBLEBUFFER to ListView _GUICtrlListView_SetExtendedListViewStyle($g_hListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER)) ; set adlib to reset those values AdlibRegister("_resetExStylesAdlib", 3000) EndFunc Func _resetExStylesAdlib() ; add WS_EX_COMPOSITED to GUI __WinAPI_Set_Window_Style($g_hGUI, $WS_EX_COMPOSITED, True, True) ; remove LVS_EX_DOUBLEBUFFER from ListView _GUICtrlListView_SetExtendedListViewStyle($g_hListview, $LVS_EX_FULLROWSELECT) ; unregister adlib AdlibUnRegister("_resetExStylesAdlib") EndFunc ;============================================== Func _resizeHeaderItems() ; temporarily change extended styles for GUI and ListView _changeExStyles() Local $aRect For $iCol = 0 To _GUICtrlListView_GetColumnCount($g_hListView) - 1 If $iCol Then $aRect = _GUICtrlListView_GetSubItemRect($g_hListView, 0, $iCol) Else $aRect = _GUICtrlListView_GetItemRect($g_hListView, 0, 2) ; 2 = bounding rectangle of the item text EndIf _GUICtrlHeader_SetItemWidth( $g_hHeader, $iCol, $aRect[2] - (($aRect[0] > 0) ? $aRect[0] : 0) ) Next EndFunc ;==>_resizeHeaderItems ;============================================== Func _resizeLVCols() ; temporarily change extended styles for GUI and ListView _changeExStyles() Local $aRect For $iCol = 0 To _GUICtrlListView_GetColumnCount($g_hListView) - 1 $aRect = _GUICtrlHeader_GetItemRect($g_hHeader, $iCol) _GUICtrlListView_SetColumnWidth($g_hListview, $iCol, $aRect[2] - (($aRect[0] > 0) ? $aRect[0] : 0) ) Next EndFunc ;==>_resizeLVCols ;============================================== Func _reorderLVCols() ; remove LVS_NOCOLUMNHEADER from listview __WinAPI_Set_Window_Style($g_hListView, $LVS_NOCOLUMNHEADER, False, False) ; reorder listview columns order to match header items order Local $aOrder = _GUICtrlHeader_GetOrderArray($g_hHeader) _GUICtrlListView_SetColumnOrderArray($g_hListview, $aOrder) ; add LVS_NOCOLUMNHEADER back to listview __WinAPI_Set_Window_Style($g_hListView, $LVS_NOCOLUMNHEADER, True, False) _resizeHeaderItems() ; avoid a bad behavior if header item on the left is dropped elsewhere when horizontal scrollbar had been moved. EndFunc ;==>_reorderLVCols ;============================================== Func __WinAPI_Set_Window_Style($hWnd, $i_Style, $b_Add, $b_exStyle = False) ; compacted code (from Kafu's original) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $iIndex = $b_exStyle ? $GWL_EXSTYLE : $GWL_STYLE ; $iIndex as named by msdn & help file Local $i_Style_Old = _WinAPI_GetWindowLong($hWnd, $iIndex) If $b_Add Then If BitAND($i_Style_Old, $i_Style) Then Return ; style already applied _WinAPI_SetWindowLong($hWnd, $iIndex, BitOR($i_Style_Old, $i_Style)) Else ; remove If Not BitAND($i_Style_Old, $i_Style) Then Return ; style not set _WinAPI_SetWindowLong($hWnd, $iIndex, BitXOR($i_Style_Old, $i_Style)) EndIf Local $iRet = _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER)) ; +++ If Not $iRet Then MsgBox($MB_TOPMOST, "_WinAPI_SetWindowPos", "Error = " & _WinAPI_GetLastError() & " Message = " & _WinAPI_GetLastErrorMessage()) EndFunc ;==>__WinAPI_Set_Window_Style ;============================================== Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hHeader Switch $iCode Case $HDN_TRACK, $HDN_TRACKW Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) Local $iHeaderItem = $tNMHEADER.Item Local $tHDITEM = DllStructCreate($tagHDITEM, $tNMHEADER.pItem) Local $iHeaderItemWidth = $tHDITEM.XY _GUICtrlHeader_SetItemWidth($g_hHeader, $iHeaderItem, $iHeaderItemWidth) _resizeLVCols() Return False ; to continue tracking the divider Case $HDN_ENDDRAG $g_bHeaderEndDrag = True Return False ; to allow the control to automatically place and reorder the item EndSwitch Case $g_hListView Switch $iCode Case $LVN_ENDSCROLL Local Static $tagNMLVSCROLL = $tagNMHDR & ";int dx;int dy" Local $tNMLVSCROLL = DllStructCreate($tagNMLVSCROLL, $lParam) If $tNMLVSCROLL.dy = 0 Then ; ListView horizontal scrolling _resizeHeaderItems() EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
    2 points
  7. Hey everybody @WildByDesign I hadn't time to test your scripts yet (glad argumentum and ioa747 are helping you for the tests) because I really wanted to improve 2 functionalities of the "detached" header control, which are : 1) Dragging the divider between 2 header items to enlarge a column : I wanted the listview columns to be enlarged at same time (as in a native listview) which wasn't the case in our preceding scripts. To do this I used the $HDN_TRACK notification + $tagNMHEADER + $tagHDITEM to finally reach $tHDITEM.XY which indicated in real time what was the width of the header item being enlarged. This value varies constantly during the tracking. Without this, I wouldn't have made it at all ! 2) Dragging and dropping a header item elsewhere : Notification $HDN_ENDDRAG was used here, with a global variable $g_bHeaderEndDrag, no adlib/timer at all. Glad you found the 3-way steps "remove LVS_NOCOLUMNHEADER from listview" => reorder LV columns => "add LVS_NOCOLUMNHEADER back to listview". But I don't know how secure is this 3-way because, from time to time, the script hangs on my computer, exactly at the time when a header item is dropped elsewhere to reorder columns. Also, if someone knows why both LV scrollbars aren't redrawn correctly after a header item is dropped elsewhere, please indicate your solution. Actually, clicking at the blank place where they are supposed to appear make them immediately visible, that's strange, maybe some window to refresh after the reorder part ? 3) LV horizontal scrolling : no change from the precedent script : $LVN_ENDSCROLL notification is used to check the horizontal scrolling in real-time and have LV columns scroll horizontally while the horizontal scrollbar is moved, thanks to $tNMLVSCROLL.dy ! The scrolling may be a bit different from a "native" LV but it works and that's the good part, especially we didn't install a ListView subclass callback to handle messages related to both Scrollbars controls. I used _WinAPI_GetWindowHeight($g_hHeader) in the script and it seems to work : the LV is placed immediately under the header after you use its value in your LV vertical coords. Ok here is the code, time to rest a bit (a lot !) after these efforts. Have a great evening everybody #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <StructureConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> ; DPI DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_hChild, $g_hHeader, $g_hListview, $g_bHeaderEndDrag Example() Func Example() $g_hGUI = GUICreate("Example", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) GUISetBkColor(0x202020) GUISetState(@SW_SHOW, $g_hGUI) $g_hChild = GUICreate("ChildWindow", 320, 320, 40, 40, $WS_CHILD, -1, $g_hGUI) GUISetBkColor(0x606060) $g_hHeader = _GUICtrlHeader_Create($g_hChild) Local $iHeaderHeight = _WinAPI_GetWindowHeight($g_hHeader) For $i = 0 To 3 _GUICtrlHeader_AddItem($g_hHeader, "Column" & $i, 100) Next Local $idListview = GUICtrlCreateListView("col0|col1|col2|col3", 0, $iHeaderHeight, 320, 320 - $iHeaderHeight, _ BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER), BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) $g_hListview = GUICtrlGetHandle($idListview) _GUICtrlListView_BeginUpdate($idListview) For $i = 1 To 30 GUICtrlCreateListViewItem("item" & $i & "-0|item" & $i & "-1|item" & $i & "-2|item" & $i & "-3", $idListview) Next _GUICtrlListView_EndUpdate($idListview) ; resize listview columns to match header widths _resizeLVCols() GUISetState(@SW_SHOW, $g_hChild) ; get rid of dotted rectangle in listview, when an item got the focus GUICtrlSendMsg($idListview, $WM_CHANGEUISTATE, 65537, 0) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If $g_bHeaderEndDrag Then $g_bHeaderEndDrag = False _reorderLVCols() EndIf WEnd _GUICtrlHeader_Destroy($g_hHeader) GUIDelete($g_hChild) GUIDelete($g_hGUI) EndFunc ;==>Example ;============================================== Func _resizeHeaderItems() Local $aRect For $iCol = 0 To _GUICtrlListView_GetColumnCount($g_hListView) - 1 If $iCol Then $aRect = _GUICtrlListView_GetSubItemRect($g_hListView, 0, $iCol) Else $aRect = _GUICtrlListView_GetItemRect($g_hListView, 0, 2) ; 2 = bounding rectangle of the item text EndIf _GUICtrlHeader_SetItemWidth( $g_hHeader, $iCol, $aRect[2] - (($aRect[0] > 0) ? $aRect[0] : 0) ) Next EndFunc ;==>_resizeHeaderItems ;============================================== Func _resizeLVCols() Local $aRect For $iCol = 0 To _GUICtrlListView_GetColumnCount($g_hListView) - 1 $aRect = _GUICtrlHeader_GetItemRect($g_hHeader, $iCol) _GUICtrlListView_SetColumnWidth($g_hListview, $iCol, $aRect[2] - (($aRect[0] > 0) ? $aRect[0] : 0) ) Next EndFunc ;==>_resizeLVCols ;============================================== Func _reorderLVCols() ; remove LVS_NOCOLUMNHEADER from listview __WinAPI_Set_Window_Style($g_hListView, $LVS_NOCOLUMNHEADER, False, False) ; reorder listview columns order to match header items order Local $aOrder = _GUICtrlHeader_GetOrderArray($g_hHeader) _GUICtrlListView_SetColumnOrderArray($g_hListview, $aOrder) ; add LVS_NOCOLUMNHEADER back to listview __WinAPI_Set_Window_Style($g_hListView, $LVS_NOCOLUMNHEADER, True, False) _resizeHeaderItems() ; avoid a bad behavior if header item on the left is dropped elsewhere when horizontal scrollbar had been moved. EndFunc ;==>_reorderLVCols ;============================================== Func __WinAPI_Set_Window_Style($hWnd, $i_Style, $b_Add, $b_exStyle = False) ; compacted code (from Kafu's original) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $iIndex = $b_exStyle ? $GWL_EXSTYLE : $GWL_STYLE ; $iIndex as named by msdn & help file Local $i_Style_Old = _WinAPI_GetWindowLong($hWnd, $iIndex) If $b_Add Then If BitAND($i_Style_Old, $i_Style) Then Return ; style already applied _WinAPI_SetWindowLong($hWnd, $iIndex, BitOR($i_Style_Old, $i_Style)) Else ; remove If Not BitAND($i_Style_Old, $i_Style) Then Return ; style not set _WinAPI_SetWindowLong($hWnd, $iIndex, BitXOR($i_Style_Old, $i_Style)) EndIf Local $iRet = _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER)) ; +++ If Not $iRet Then MsgBox($MB_TOPMOST, "_WinAPI_SetWindowPos", "Error = " & _WinAPI_GetLastError() & " Message = " & _WinAPI_GetLastErrorMessage()) EndFunc ;==>__WinAPI_Set_Window_Style ;============================================== Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hHeader Switch $iCode Case $HDN_TRACK, $HDN_TRACKW Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) Local $iHeaderItem = $tNMHEADER.Item Local $tHDITEM = DllStructCreate($tagHDITEM, $tNMHEADER.pItem) Local $iHeaderItemWidth = $tHDITEM.XY _GUICtrlHeader_SetItemWidth($g_hHeader, $iHeaderItem, $iHeaderItemWidth) _resizeLVCols() Return False ; to continue tracking the divider Case $HDN_ENDDRAG $g_bHeaderEndDrag = True Return False ; to allow the control to automatically place and reorder the item EndSwitch Case $g_hListView Switch $iCode Case $LVN_ENDSCROLL Local Static $tagNMLVSCROLL = $tagNMHDR & ";int dx;int dy" Local $tNMLVSCROLL = DllStructCreate($tagNMLVSCROLL, $lParam) If $tNMLVSCROLL.dy = 0 Then ; ListView horizontal scrolling _resizeHeaderItems() EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
    2 points
  8. Please make a folder with all the files and then zip the whole folder and upload it, as it is now people have to first make a folder, then download 7 files into it, very few is gonna be bothered with that. Just if you want as much response as possible.
    2 points
  9. Nine

    Shell Application Bar

    I was wondering how to create an Application Bar that would be recognized by the system. Searching on the forum here revealed that there was a few attempts of doing so but none was successful. So here a working example of how to perform it. Notice how maximized windows are shrunk by the application bar. 😎 #NoTrayIcon ;#AutoIt3Wrapper_UseX64=y #include <GUIConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #include <TrayConstants.au3> ; #SHAppBarMessage# ============================================================================================================= ; Name ..........: SHAppBarMessage.AU3 ; Description ...: Create an Application Bar recognized by the system ; Author ........: Nine ; Created .......: 2025-04-04 ; Modified ......: ; Remarks .......: ; Example .......: Yes ; =============================================================================================================================== Opt("MustDeclareVars", True) Opt("GUICloseOnESC", False) Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) Global Enum $ABM_NEW, $ABM_REMOVE, $ABM_QUERYPOS, $ABM_SETPOS, $ABM_GETSTATE, $ABM_GETTASKBARPOS, $ABM_ACTIVATE, $ABM_GETAUTOHIDEBAR, _ $ABM_SETAUTOHIDEBAR, $ABM_WINDOWPOSCHANGED, $ABM_SETSTATE Global Enum $ABS_ONTOP, $ABS_AUTOHIDE, $ABS_ALWAYSONTOP Global Enum $ABE_LEFT, $ABE_TOP, $ABE_RIGHT, $ABE_BOTTOM Global Enum $ABN_STATECHANGE, $ABN_POSCHANGED, $ABN_FULLSCREENAPP, $ABN_WINDOWARRANGE Global Const $CALLBACK = $WM_USER + 0x10 Global Const $tagAPPBARDATA = "dword cbSize;hwnd hWnd;uint uCallbackMessage;uint uEdge;" & $tagRECT & ";lparam lParam" Global $idDummy Example() Func Example() Local $tAppBarData = DllStructCreate($tagAPPBARDATA) $tAppBarData.cbSize = DllStructGetSize($tAppBarData) Local $hGUI = GUICreate("", 80, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0x202020) GUISetFont(11, 0, 0, "Comic Sans MS") Local $idHide = GUICtrlCreateButton(" Hide", 5, 5, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 200, 0) Local $idTask = GUICtrlCreateButton(" Task", 5, 40, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 16739, 0) Local $idDo = GUICtrlCreateButton(" Do", 5, 75, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 16802, 0) Local $idDont = GUICtrlCreateButton(" Don't", 5, 110, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 240, 0) Local $idExit = GUICtrlCreateButton(" Exit", 5, 300, 70, 30) GUICtrlSetImage(-1, "shell32.dll", 290, 0) $tAppBarData.hWnd = $hGUI $tAppBarData.uCallbackMessage = $CALLBACK DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_NEW, "struct*", $tAppBarData) AppBarSetPos($tAppBarData) GUIRegisterMsg($CALLBACK, AppBarProc) GUISetState() $idDummy = GUICtrlCreateDummy() While True Switch GUIGetMsg() Case $idExit ExitLoop Case $idDummy AppBarSetPos($tAppBarData) Case $idHide GUISetState(@SW_HIDE) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_REMOVE, "struct*", $tAppBarData) TraySetIcon("shell32.dll", 255) TraySetState($TRAY_ICONSTATE_SHOW) TraySetToolTip("Left click to restore" & @CRLF & "Right click to Exit") Case $idTask ToggleTaskBar() EndSwitch Switch TrayGetMsg() Case $TRAY_EVENT_PRIMARYDOWN GUISetState(@SW_SHOW) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_NEW, "struct*", $tAppBarData) AppBarSetPos($tAppBarData) TraySetState($TRAY_ICONSTATE_HIDE) Case $TRAY_EVENT_SECONDARYUP Exit EndSwitch WEnd DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_REMOVE, "struct*", $tAppBarData) EndFunc ;==>Example Func AppBarSetPos(ByRef $tAppBar) $tAppBar.uEdge = $ABE_LEFT $tAppBar.left = 0 $tAppBar.top = 0 $tAppBar.Right = 80 $tAppBar.Bottom = @DesktopHeight DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_QUERYPOS, "struct*", $tAppBar) DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_SETPOS, "struct*", $tAppBar) WinMove($tAppBar.hWnd, "", $tAppBar.Left, $tAppBar.Top, $tAppBar.Right, $tAppBar.Bottom) EndFunc ;==>AppBarSetPos Func ToggleTaskBar() Local $tAppBar = DllStructCreate($tagAPPBARDATA) $tAppBar.cbSize = DllStructGetSize($tAppBar) Local $iState = DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_GETSTATE, "struct*", $tAppBar)[0] $tAppBar.lParam = $iState = $ABS_AUTOHIDE ? $ABS_ALWAYSONTOP : $ABS_AUTOHIDE DllCall("shell32.dll", "int", "SHAppBarMessage", "dword", $ABM_SETSTATE, "struct*", $tAppBar) EndFunc ;==>ToggleTaskBar Func AppBarProc($hWnd, $iMsg, $wParam, $lParam) If $wParam = $ABN_POSCHANGED Then GUICtrlSendToDummy($idDummy, $wParam) Return $GUI_RUNDEFMSG EndFunc ;==>AppBarProc
    1 point
  10. Our magical friend must be here UEZ
    1 point
  11. ..there should be. But am not a "programmer", just a "scripter", and the knowledge to turn parts of Ntddstor.h into AutoIt, is beyond me
    1 point
  12. Nine

    Shell Application Bar

    It seems to be a bug in Windows 10 (I was able to reproduce the issue). In Windows 11, the bad behavior has disappeared, as it is working correctly now. At this stage, I have no idea how to recuperate the lost region.
    1 point
  13. Yes but please be careful, $LVN_ENDSCROLL shouldn't be the right place to run _changeExStyles() , I would place it when $LVN_BEGINSCROLL is detected (for vertical scrolling only) Here is a WM_NOTIFY function (just for test purpose) . It indicates how many times each notification occurs. From all notifications found in the function, only 4 are triggered a lot of times (when others are triggered only once. These 4 frequent notifications are : $HDN_TRACK, $HDN_TRACKW, $LVN_BEGINSCROLL, $LVN_ENDSCROLL As you suggested, I added _changeExStyles() in the $LVN_BEGINSCROLL part (when vertical scroll begins). As $LVN_BEGINSCROLL / $LVN_ENDSCROLL are constantly triggered when the scrollbars are moved, you'll have to check on your computer if calling _changeExStyles() so frequently creates an issue... or not. Good luck Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hHeader Switch $iCode Case $HDN_TRACK, $HDN_TRACKW Local Static $iHDN_TRACK = 0 $iHDN_TRACK += 1 ConsoleWrite("$iHDN_TRACK #" & $iHDN_TRACK & @crlf) Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) Local $iHeaderItem = $tNMHEADER.Item Local $tHDITEM = DllStructCreate($tagHDITEM, $tNMHEADER.pItem) Local $iHeaderItemWidth = $tHDITEM.XY _GUICtrlHeader_SetItemWidth($g_hHeader, $iHeaderItem, $iHeaderItemWidth) _resizeLVCols() ; <======================== Return False ; to continue tracking the divider Case $HDN_BEGINTRACK, $HDN_BEGINTRACKW Local Static $iHDN_BEGINTRACK = 0 $iHDN_BEGINTRACK += 1 ConsoleWrite("$iHDN_BEGINTRACK #" & $iHDN_BEGINTRACK & @crlf) Return False ; To allow tracking of the divider Case $HDN_ENDTRACK, $HDN_ENDTRACKW Local Static $iHDN_ENDTRACK = 0 $iHDN_ENDTRACK += 1 ConsoleWrite("$iHDN_ENDTRACK #" & $iHDN_ENDTRACK & @crlf) Case $HDN_BEGINDRAG Local Static $iHDN_BEGINDRAG = 0 $iHDN_BEGINDRAG += 1 ConsoleWrite("$iHDN_BEGINDRAG #" & $iHDN_BEGINDRAG &@crlf) Return False ; To allow the header control to automatically manage drag-and-drop operations Case $HDN_ENDDRAG Local Static $iHDN_ENDDRAG = 0 $iHDN_ENDDRAG += 1 ConsoleWrite("$iHDN_ENDDRAG #" & $iHDN_ENDDRAG & @crlf) $g_bHeaderEndDrag = True ; <======================== Return False ; to allow the control to automatically place and reorder the item Case $HDN_ITEMCLICK, $HDN_ITEMCLICKW Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) Local $iHeaderItem = $tNMHEADER.Item ConsoleWrite("Item " & $iHeaderItem & " clicked" & @crlf) Case $HDN_DIVIDERDBLCLICK, $HDN_DIVIDERDBLCLICKW Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) Local $iHeaderItem = $tNMHEADER.Item ConsoleWrite("Divider " & $iHeaderItem & " double clicked" & @crlf) EndSwitch Case $g_hListView Switch $iCode Case $LVN_BEGINSCROLL, $LVN_ENDSCROLL Local Static $iLVN_BEGINSCROLL_H = 0, $iLVN_ENDSCROLL_H = 0, $iLVN_BEGINSCROLL_V = 0, $iLVN_ENDSCROLL_V = 0 Local Static $tagNMLVSCROLL = $tagNMHDR & ";int dx;int dy" Local $tNMLVSCROLL = DllStructCreate($tagNMLVSCROLL, $lParam) If $tNMLVSCROLL.dy = 0 Then ; ListView horizontal scrolling Switch $iCode Case $LVN_BEGINSCROLL $iLVN_BEGINSCROLL_H += 1 ConsoleWrite("$iLVN_BEGINSCROLL_H #" & $iLVN_BEGINSCROLL_H & @crlf) Case Else ; $LVN_ENDSCROLL $iLVN_ENDSCROLL_H += 1 ConsoleWrite("$iLVN_ENDSCROLL_H #" & $iLVN_ENDSCROLL_H & @crlf) _resizeHeaderItems() ; <======================== EndSwitch Else ; ListView vertical scrolling Switch $iCode Case $LVN_BEGINSCROLL $iLVN_BEGINSCROLL_V += 1 ConsoleWrite("$iLVN_BEGINSCROLL_V #" & $iLVN_BEGINSCROLL_V & @crlf) _changeExStyles() ; <======================== Case Else ; $LVN_ENDSCROLL $iLVN_ENDSCROLL_V += 1 ConsoleWrite("$iLVN_ENDSCROLL_V #" & $iLVN_ENDSCROLL_V & @crlf) EndSwitch EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
    1 point
  14. look at the ListView at linksinspector, maybe you like something
    1 point
  15. This was a very nice contribution. I was starting to think that the only way that I could have those line up properly was to put the ListView right up against the side. So this gives more flexibility in ListView placement and looks much better. Thank you. This is also brilliant. This ensures that the header placement in comparison to the ListView placement stays in sync with any sizing of the GUI or resizing of the frames. Nice work!
    1 point
  16. Thanks for that, my issue with "both LV scrollbars aren't redrawn correctly after a header item is dragged and dropped", well this issue disappeared with the code you indicated in your function _changeExStyles() , well done
    1 point
  17. for changing the size of the window I put this, but for GUIFrame_ I couldn't find where to put it While True Local $iMsg = GUIGetMsg() Switch $iMsg Case -3 ;$GUI_EVENT_CLOSE __TreeListExplorer_Shutdown() Exit Case -12 ;$GUI_EVENT_RESIZED Local $aClientSize = WinGetClientSize($hChildLV) ConsoleWrite("SetWindowPos=" & _WinAPI_SetWindowPos($g_hHeader, 0, 0, 0, $aClientSize[0], 25, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) & @CRLF) EndSwitch WEnd
    1 point
  18. In my opinion, making it themeable would still be best. That way it would still work with custom themes like @argumentum uses, but would also be ideal for users who use default Windows theme (Aero). The vast majority of users use the default Windows theme because Microsoft makes it more difficult for users to apply custom themes. When using the default Windows theme, you can have Guiscape detect whether Windows is set to dark or light theme and you can have Guiscape use dark or light depending on what the user has set on their machine. I am actually a big fan of custom Windows themes (msstyles), but I also recognize that the majority of users just use default Windows theme and therefore I make any of my GUI apps adapt to default Windows settings.
    1 point
  19. 1 point
  20. If I enlarge the window, on the right SysListView32 the header (SysHeader32) does not enlarge as much as the SysListView32
    1 point
  21. Yes, eventually shows the items. Not after. No. The reason for forking the process that gives the data to the treeview, is to avoid unresponsiveness of the GUI. But you'll have to look into it. It is quite responsive if the system returns the data fast.
    1 point
  22. I think that the GUI and the searching should be separated/forked. When listing something slow, like a network share with lots of folders/subfolders, the GUI is "not responsive". Other than that, nice looking.
    1 point
  23. I'd like to say is my awesomeness but is just the theme I use. Makes everything dark mode. Here is a sample of 2 of them : BIB3 Buuf Regular And that is the way it should be. You choose a theme and that's the theme for the OS, but M$ don't do it and I search the net for ways to get it done.
    1 point
  24. Just posting an update of what I have done. Just pretty much brought it back to where it was before I started the rewrites. Guiscape.zip
    1 point
  25. Yes, that is kind of annoying. To test equality, you need to use $SB_UTF16LE but to write in console $SB_UTF16BE prints correctly. Since AscW only checks only the first character, theoretically it could lead to error...
    1 point
  26. I understand your point, and thank you for your time and advice. There was probably a misunderstanding: my intentions were good, just like yours. After checking more carefully, I found that the issue was not related to AutoIt nor to the behavior of my script, but simply to an incorrect tab selection that prevented the code from working properly. From my point of view, if possible, this thread can be removed as well, since it’s not really useful to anyone. I apologize again for opening the topic too hastily without double-checking the code first. Thanks again, and have a nice day!
    1 point
  27. AFAIK, not possible with ConsoleWrite. But if you want to check the wide char, you can use something like this : If StringToBinary(GUICtrlRead($tInfo.IDFrom), $SB_UTF16LE) = 0xE248 Then ; do something here EndIf
    1 point
  28. smartctl.exe will give you what you need and more ( like health status of the NVMe ) "The smartmontools package contains two utility programs (smartctl and smartd) to control and monitor storage systems using the Self-Monitoring, Analysis and Reporting Technology System (SMART) built into most modern ATA/SATA, SCSI/SAS and NVMe disks. In many cases, these utilities will provide advanced warning of disk degradation and failure." ( https://github.com/smartmontools/smartmontools )
    1 point
  29. That sounds more like a non-apology than one. And I'll take offence on his behalf because he did answer your post with good advise ( even if not what you expected ). The best you can do is to ... do what I asked before. Maybe is a problem in AutoIt, maybe is a problem with the your script code. We would welcome a detailed account of, piece by piece of your code, to pin point the exact issue. Do remember that we dedicate time and answer, out of the goodness of our hearts, and nothing else
    1 point
  30. 1 point
  31. Thanks for the kind words Here is an example I just scripted to synchronize in real-time the Listview horizontal scrolling with a "detached" header control. Hope it will work by your side, fingers crossed... #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> ; DPI DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_hChild, $g_hHeader, $g_hListview Example() Func Example() $g_hGUI = GUICreate("Example", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) GUISetBkColor(0x202020) GUISetState(@SW_SHOW, $g_hGUI) $g_hChild = GUICreate("ChildWindow", 320, 320, 40, 40, $WS_CHILD, -1, $g_hGUI) GUISetBkColor(0x606060) ; $g_hHeader = _GUICtrlHeader_Create($g_hChild) $g_hHeader = _GUICtrlHeader_Create($g_hChild, BitOr($HDS_BUTTONS, $HDS_HOTTRACK)) ; without $HDS_DRAGDROP in this example _GUICtrlHeader_AddItem($g_hHeader, "Column1", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column2", 200) _GUICtrlHeader_AddItem($g_hHeader, "Column3", 300) Local $idListview = GUICtrlCreateListView("col1|col2|col3 ", 0, 24, 320, 295, _ BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER), BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) $g_hListview = GUICtrlGetHandle($idListview) For $i = 1 To 30 GUICtrlCreateListViewItem("item" & $i & "-1|item" & $i & "-2|item" & $i & "-3", $idListview) Next ; resize listview columns to match header widths _resizeLVCols() GUISetState(@SW_SHOW, $g_hChild) ; get rid of dotted rectangle in listview, when an item got the focus GUICtrlSendMsg($idListview, $WM_CHANGEUISTATE, 65537, 0) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlHeader_Destroy($g_hHeader) GUIDelete($g_hChild) GUIDelete($g_hGUI) EndFunc ;==>Example Func _resizeLVCols() For $i = 0 To _GUICtrlHeader_GetItemCount($g_hHeader) - 1 _GUICtrlListView_SetColumnWidth($g_hListview, $i, _GUICtrlHeader_GetItemWidth($g_hHeader, $i)) Next EndFunc ;==>_resizeLVCols Func _resizeHeaderItems() Local $aRect For $iSubItem = 0 To _GUICtrlListView_GetColumnCount($g_hListView) - 1 If $iSubItem Then $aRect = _GUICtrlListView_GetSubItemRect($g_hListView, 0, $iSubItem) Else $aRect = _GUICtrlListView_GetItemRect($g_hListView, 0, 2) ; 2 = bounding rectangle of the item text EndIf _GUICtrlHeader_SetItemWidth( $g_hHeader, $iSubItem, $aRect[2] - (($aRect[0] > 0) ? $aRect[0] : 0) ) Next EndFunc ;==>_resizeHeaderItems Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hHeader Switch $iCode Case $HDN_ITEMCHANGED, $HDN_ITEMCHANGEDW _resizeLVCols() EndSwitch Case $g_hListView Switch $iCode Case $LVN_ENDSCROLL Local Static $tagNMLVSCROLL = $tagNMHDR & ";int dx;int dy" Local $tInfo = DllStructCreate($tagNMLVSCROLL, $lParam) If $tInfo.dy = 0 Then ; ListView horizontal scrolling _resizeHeaderItems() EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Edit; it seems to be a good start, unfortunately it's not enough...
    1 point
  32. The good part is that I was able to end up doing all of the dragging, sorting, etc. successfully. It was a fun learning experience and worked really, really well in the end. The bad part is that I was never able to solve this part. I could not even think of any ideas to try. But after some time thinking about it, I was thinking that it may not even be worth doing. At least for the time being, I am going to have to scrap my file manager for AutoIt project. I made no progress in like two or three days, so it's probably time to move on to something else for now and maybe come back to it later. Thank you for everything that you have done to help, @pixelsearch. You've been a great help with so many of my projects.
    1 point
  33. auto-it-tous

    OpenCV v4 UDF

    Thanks for your help. I got it. because i download the file "node-autoit-opencv-com-2.8.0.zip" i think it is sample and all of files. So i can not found it.
    1 point
  34. I thought you were looking for it.
    1 point
  35. Hello. I was trying your penultimate script above and could improve it a bit (no more Adib but $HDN_ENDTRACK changed to $HDN_ITEMCHANGED, added _GUICtrlHeader_Destroy) etc... The problem with a separate header control is that you'll have to add plenty of code in your script to get (nearly) the same results as a native Listview control (which takes care of its native header items), this means sorting listview columns by clicking their headers, changing header items order by dragging a header item at the left or right of another, double-clicking a header separator etc...) For example, in my script below, please notice what will happen when you enlarge a header item : an horizontal scrollbar will appear in the listview. Now when you scroll horizontally, the headers items won't align the listview columns, so you'll have to take care of this part too etc... Of course all these points could be fixed with additional code, it's up to you to decide if you're ready to add all this code to avoid flicker. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> ; DPI DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_hChild Global $g_hHeader, $g_idListview Example() Func Example() $g_hGUI = GUICreate("Example", 400, 400, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) GUISetBkColor(0x202020) GUISetState(@SW_SHOW, $g_hGUI) $g_hChild = GUICreate("ChildWindow", 320, 320, 40, 40, $WS_CHILD, -1, $g_hGUI) GUISetBkColor(0x606060) $g_hHeader = _GUICtrlHeader_Create($g_hChild) _GUICtrlHeader_AddItem($g_hHeader, "Column1", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column2", 100) _GUICtrlHeader_AddItem($g_hHeader, "Column3", 100) $g_idListview = GUICtrlCreateListView("col1|col2|col3 ", 0, 24, 320, 295, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER), BitOR($LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT)) For $i = 1 To 30 GUICtrlCreateListViewItem("item" & $i & "|item" & $i & "|item" & $i, $g_idListview) Next ; resize listview columns to match header widths _resizeLVCols() GUISetState(@SW_SHOW, $g_hChild) ; get rid of dotted rectangle on listview, when an item got the focus GUICtrlSendMsg($g_idListview, $WM_CHANGEUISTATE, 65537, 0) GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GUICtrlHeader_Destroy($g_hHeader) ; added GUIDelete($g_hChild) GUIDelete($g_hGUI) EndFunc ;==>Example Func _resizeLVCols() For $i = 0 To _GUICtrlHeader_GetItemCount($g_hHeader) - 1 _GUICtrlListView_SetColumnWidth($g_idListview, $i, _GUICtrlHeader_GetItemWidth($g_hHeader, $i)) Next EndFunc ;==>_resizeLVCols Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hHeader Switch $iCode Case $HDN_ITEMCHANGED, $HDN_ITEMCHANGEDW _resizeLVCols() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY
    1 point
  36. ioa747

    Windows x64

    As an example of an x86 application, I chose Au3Info.exe and it worked normally without double quotes even though the path has blank characters Here I must emphasize that at the beginning I entered the 4-digit 'Hello PIN' and it did not work, I had to enter the Admin Password With Windows 11 Pro, Version: 25H2 #AutoIt3Wrapper_UseX64=y #include <AutoItConstants.au3> RunAsAdmin() Func RunAsAdmin() ; Change the username and password to the appropriate values for your system. Local $sUserName = "ElevateUser" Local $sDomain = @ComputerName Local $sPassword = "ElevatePassword" Local $sProgram = "C:\Program Files (x86)\AutoIt3\Au3Info.exe" Local $Status $Status = FileExists($sProgram) ConsoleWrite("Program:" & $sProgram & @CRLF) ConsoleWrite("Status: " & $Status & @CRLF) ; Run Notepad with the window maximized. Notepad is run under the user previously specified. Local $iPID = RunAs($sUserName, $sDomain, $sPassword, $RUN_LOGON_PROFILE, $sProgram, "", @SW_SHOWMAXIMIZED) ConsoleWrite("PID: " & $iPID & @CRLF) EndFunc ;==> RunAsAdmin Output : Program:C:\Program Files (x86)\AutoIt3\Au3Info.exe Status: 1 PID: 6756
    1 point
  37. argumentum

    Windows x64

    ..tested in 25H2 and I did not get it do run as admin. In any case, when I need to run as admin, I add it to task scheduler and save the user/pass there. "UAC Pass - bypass UAC prompts only for specific programs" may just do that you need.
    1 point
  38. I recently read How do I find which Dlls contain specific W32 functions ? and I found this: // Source - https://stackoverflow.com/questions/21565739/how-do-i-find-which-dlls-contain-specific-w32-functions // Posted by noseratio, modified by community. See post 'Timeline' for change history // Retrieved 2025-11-30, License - CC BY-SA 3.0 for %f in (%windir%\system32\*.dll) do dumpbin.exe /exports %f >>%temp%\__exports which however gave me a single file with 412000 lines, really, difficult to sort and explore so I used Autoit to extract information only for dlls that have at least one function, (2645 files in total) and to extract, in a subfolder of the script, for each dll a txt file with the name of the dll and the number of functions e.g. for AddressParser.Dll it makes AddressParser(18).txt with the help of dumpbin.exe (external tool from the Visual Studio SDK). for anyone with a curiosity for exploration ; https://www.autoitscript.com/forum/topic/213347-lists-the-system-libraries-dlls-which-have-functions/ ;---------------------------------------------------------------------------------------- ; Title...........: Print-all-dlls.au3 ; Description.....: The script lists the system libraries (DLLs), which have functions, ; using the external tool dumpbin.exe (from the Visual Studio SDK). ; AutoIt Version..: 3.3.18.0 Author: ioa747 Script Version: 0.2 ; Note............: Testet in Windows 11 Pro 24H2 Date:30/11/2025 ; Info............: https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=msvc-170 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #RequireAdmin #include <File.au3> _Print_all_dlls() Func _Print_all_dlls($iNumFunctionsLimit = 0) ; The path to dumpbin.exe. <- Put your own path. 👈 Local Const $sDumpBinPath = "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x86\dumpbin.exe" If Not FileExists($sDumpBinPath) Then Exit MsgBox(16, "Error", "Could not find dumpbin.exe path in " & @CRLF & $sDumpBinPath) Local $sSystemDir = @SystemDir Local $sSystemDirLen = StringLen($sSystemDir) ConsoleWrite("System Directory: " & $sSystemDir & ", Length: " & $sSystemDirLen & @CRLF) ; Remove older output directory if already exist (in ScriptDir) Local Const $sOutputDir = @ScriptDir & "\DllExportsAnalysis\" If FileExists($sOutputDir) Then DirRemove($sOutputDir, $DIR_REMOVE) DirCreate($sOutputDir) ; Find all DLL files in the system directory, recursively searching subfolders. Local $aDllFiles = _FileListToArrayRec($sSystemDir, "*.dll", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT, $FLTAR_FULLPATH) If IsArray($aDllFiles) Then Local $iTotalFiles = $aDllFiles[0] ConsoleWrite("Found " & $iTotalFiles & " DLL files." & @CRLF) ; Loop through each found DLL For $i = 1 To $iTotalFiles ; <- Change $iTotalFiles to 10 for limited testing. 👈️ Local $sFullDllPath = $aDllFiles[$i] Local $iNumFunctions = 0 Local $sTempFile = @ScriptDir & "\temp_dump.tmp" ; Execute dumpbin.exe and capture the output RunWait($sDumpBinPath & ' /exports /OUT:"' & $sTempFile & '" "' & $sFullDllPath & '"', "", @SW_HIDE) Local $sDumpOutput = FileRead($sTempFile) Local $aMatches = StringRegExp($sDumpOutput, '(\d+)\s+number of functions', 3) If IsArray($aMatches) Then ; The first captured group (index 0) is the number of functions $iNumFunctions = Number($aMatches[0]) EndIf If $iNumFunctions > $iNumFunctionsLimit Then Local $sBaseName = StringTrimRight(StringTrimLeft($sFullDllPath, $sSystemDirLen + 1), 4) $sBaseName = StringReplace($sBaseName, "\", "_") Local $sFinalOutputPath = $sOutputDir & $sBaseName & "(" & $iNumFunctions & ").txt" FileWrite($sFinalOutputPath, $sDumpOutput) ConsoleWrite("- SUCCESS - " & $sFullDllPath & " -> Functions: " & $iNumFunctions & @CRLF) Else ConsoleWrite("+ SKIPPED - " & $sFullDllPath & " - Functions: 0" & @CRLF) EndIf FileDelete($sTempFile) Next MsgBox(0, "Script Complete", "Analysis finished. Check the results in: " & $sOutputDir) Else MsgBox(16, "Error", "Could not find DLL files in " & $sSystemDir & ". Check permissions or path.") EndIf EndFunc ;==>_Print_all_dlls Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    1 point
  39. I'm not familiar with webdriver, and I'm unable to test at the moment. But I'll bet that you can encrypt my original helloworld example just fine. One quick test would be to disable the option Remove orphaned globals and UDFs under the SingleBuild tab. You should start by doing a BackTranslate (no encryption), and check MCF0test output from that. Only if that works normally should you attempt encryption. More generally. both in BackTranslate and Encrypt, you can try to identify the problem by working in stages. You start with a working example like helloworld, and gradually add/replace more functionality from the script you wish to process(see Tab Encrypt, button UDFs). If the issue occurs only when encrypting, you can target each individual function for encryption, so with sequential testing you should be able to narrow down where the problem lies. 1.Backtranslate my helloworld, check that output works 2. Encrypt my helloworld, check again 3.Backtranslate webdriver demo, check again if it doesn't work, and you can't tell where it fails, move independent parts into helloworld step by step, and repeat. 4. If BackTr works, but encrypt does not, even with orphan removal disabled, try again with all individual functions unencrypted. When that works, start encrypting the first half of funcs only, if problems, go back a step and do the first quarter only, if still problems, encrypt one function at a time. Two steps forward, one step back, and so on. You'll need patience and perseverance. See also the suggestions in the Q & A pdf (also in the bundle). cannot guarantee that CodeCrypter will always work out of the box for every conceivable script you might throw at it. But it seems to work for most people most of the time.
    1 point
  40. For those who need an AU3-only solution for decoding entities: HTMLentities.au3
    1 point
  41. Here is a rewrite of Wards Curl UDF with the binary portion removed so that it can support external (updated) library's and add support for x64. I added quite a few new header constants and also have included the curl-ca-bundle certificate. I modified the first two "easy" examples to demonstrate using the ca-bundle to verify the SSL peer. I also added a new example showing how to download the certificate chain. The 7.82.0 version dlls are included but they can be replaced with updated versions as they come out in the future. You can find future releases here : https://curl.se/windows/ Let me know if you have any issues. Cheers! 🙂 Curlx64.7z
    1 point
  42. 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
  43. Nine

    Sudoku game 2020

    Yes, I know, another Sudoku game script. I started with a solution finder and progressively it got to a full game. Hope you like it. Version 2020-11-19 * Corrected a bug where grid wasn't displayed correctly after validation on success Version 2020-07-24 * Added icon and wav files for completeness * Added keyboard navigation * Solved a small bug Version 2020-04-14 * 4 levels of difficulty (around 100 grids per level) * Multi-lingual * Allows multiple entries per cell * All grids are solvable by logic only (no trial/error needed) * Remember preferences * Offline playable (SQLite required) * Solution finder works for all grids Enjoy ! Sudoku.zip
    1 point
  44. This can happen when Win10 auto-rescales (see under display settings, I think 125% is default for 1920x1080) to make them easier to read (as hi-res screens make everything that used to look about the right size look tiny now). To make your original script work in full resolution (with macros returning the correct (full) dimensions), while maintaining rescaling for regular programmes, add: DllCall("User32.dll","bool","SetProcessDPIAware") This causes the script to take advantage of the full current resolution, but at the cost of its text and graphics appearing smaller than if running rescaled.
    1 point
  45. Can you try this (GDI+ version only): AutoIt version 3.3.10.0 or higher needed! #include <Array.au3> #include <GDIPlus.au3> #include <MsgBoxConstants.au3> _GDIPlus_Startup() Global $hImage1, $hImage2 Global $sImages = FileOpenDialog("Select 2 images", "", "Image (*.bmp;*.jpg;*.png;*.gif)", $FD_MULTISELECT) If @error Then _Exit("Nothing selected") Global $aFiles = StringSplit($sImages, "|", 2) If (UBound($aFiles) < 3) Then _Exit("Select at least 2 images") $hImage1 = _GDIPlus_ImageLoadFromFile($aFiles[1]) If @error Then _Exit("Unable to load " & $aFiles[1]) $hImage2 = _GDIPlus_ImageLoadFromFile($aFiles[2]) If @error Then _Exit("Unable to load " & $aFiles[2]) If (_GDIPlus_ImageGetWidth($hImage1) <> _GDIPlus_ImageGetWidth($hImage2)) Then _Exit("Width of both images are different") If (_GDIPlus_ImageGetHeight($hImage1) <> _GDIPlus_ImageGetHeight($hImage2)) Then _Exit("Height of both images are different") Global $bFastCmp = True Global $aDiff = _GDIPlus_ImageCompare($hImage1, $hImage2, $bFastCmp) If $bFastCmp Then Exit MsgBox($MB_SYSTEMMODAL, "Compared", "Equal: " & $aDiff & " / " & @extended & " ms") Global $iChk = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_YESNO), "Information", "Found " & Round((UBound($aDiff) - 1) / ($aDiff[0][1] * $aDiff[0][2]) * 100, 2) & " % differences in " & Round($aDiff[0][0], 2) & " ms." & _ @CRLF & @CRLF & _ "Display the array with information") If ($iChk = 6) Then _ArrayDisplay($aDiff, "Differences", Default, Default, Default, "Runtime / Coordinate (x,y)|Image1 Color|Image2 Color") Func _GDIPlus_ImageCompare($hImage1, $hImage2, $bFastCmp = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage1), $iH = _GDIPlus_ImageGetHeight($hImage1) If ($iW <> _GDIPlus_ImageGetWidth($hImage2)) Then Return SetError(1, 0, 0) If ($iH <> _GDIPlus_ImageGetHeight($hImage2)) Then Return SetError(2, 0, 0) Local $t = TimerInit() Local $tBitmapData1 = _GDIPlus_BitmapLockBits($hImage1, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $tBitmapData2 = _GDIPlus_BitmapLockBits($hImage2, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $pScan1 = DllStructGetData($tBitmapData1, "Scan0") Local $tPixel1 = DllStructCreate("uint[" & $iW * $iH & "];", $pScan1) Local $iStride = Abs(DllStructGetData($tBitmapData1, "Stride")) Local $pScan2 = DllStructGetData($tBitmapData2, "Scan0") Local $tPixel2 = DllStructCreate("uint[" & $iW * $iH & "];", $pScan2) If $bFastCmp Then $iResult = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $pScan1, "ptr", $pScan2, "uint", DllStructGetSize($tPixel1))[0] Else If ($iW * $iH + 1) * 3 > 16 * 1024^2 Then Return SetError(3, 0, 0) Local $iX, $iY, $iRowOffset, $iPixel1, $iPixel2, $c = 1, $aDiff[$iW * $iH + 1][3] For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 $iPixel1 = DllStructGetData($tPixel1, 1, $iRowOffset + $iX) ;get pixel color $iPixel2 = DllStructGetData($tPixel2, 1, $iRowOffset + $iX) ;get pixel color If $iPixel1 <> $iPixel2 Then $aDiff[$c][0] = $iX & ", " & $iY $aDiff[$c][1] = "0x" & Hex($iPixel1, 8) $aDiff[$c][2] = "0x" & Hex($iPixel2, 8) $c += 1 EndIf Next Next $aDiff[0][0] = TimerDiff($t) $aDiff[0][1] = $iW $aDiff[0][2] = $iH EndIf _GDIPlus_BitmapUnlockBits($hImage1, $tBitmapData1) _GDIPlus_BitmapUnlockBits($hImage2, $tBitmapData2) If $bFastCmp Then Return SetError(0, Int(TimerDiff($t)), $iResult = 0) ReDim $aDiff[$c][3] Return $aDiff EndFunc Func _Exit($sError = "") If $sError <> "" Then MsgBox($MB_ICONERROR, "ERROR", $sError) If ($hImage1 <> 0) Then _GDIPlus_ImageDispose($hImage1) If ($hImage2 <> 0) Then _GDIPlus_ImageDispose($hImage2) _GDIPlus_Shutdown() Exit EndFunc Br, UEZ
    1 point
×
×
  • Create New...