Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 10/26/2025 in Posts

  1. Hello! I'm working on a new GUI builder that I have been making great progress on! A helpful forum member ioa747 answered a question I had which started me on my journey, and now I'd like to present to you an alpha version of the software. As of now only Form and Button works in a rudimentary fashion. To run this, open Guiscape.au3 and go from there! I'd love to hear your feedback and suggestions. 🙂 Guiscape.zip Downloads: 35
    4 points
  2. This example script is a desktop live wallpaper program. It is a combination of MediaPlayerElement - WinRT Xaml Island by @MattyD and Move window behind desktop icons by @Parsix. It basically creates a GUI layer under the desktop icons but above the wallpaper (eg. in a WorkerW window within Program Manager). Features: Configuration file (LiveWallpaper.ini) Plays .mp4 videos and likely many more formats Light on CPU (uses GPU for video processing) Play/Pause video by double-click (can change to single-click in config) Option to Loop video Transparency level (to blend video with your real wallpaper) Important Note: To run this, the XAML Islands require the following value in the AutoIt binary manifest: <maxversiontested Id="10.0.18362.1"/> There are two options. The first is ExternalManifest.au3 which essentially drops an external manifest file that includes that value beside your existing AutoIt binaries (eg. AutoIt3.exe.manifest and AutoIt3_x64.exe.manifest). This will allow you to run LiveWallpaper.au3 in your file manager by double-clicking on the script. However, the downside to this method is that it will not work through VSCode or SciTE and therefore you cannot get any ConsoleWrite info if you need it. The second option is Update Manifest.au3 which patches your actual AutoIt binary to include the required maxversiontested value. It makes a backup of your original AutoIt binary and you have to copy the modified one over your original. This is the better method if you want to extend the LiveWallpaper code, run through VSCode or SciTE and add/get console output. If you intend to compile as a binary, that compiled binary needs the maxversiontested value. You need to set the "win10" compatibility flag with AutoIt3Wrapper (already at top of LiveWallpaper.au3) and you need to be using the absolute latest beta version of AutoIt3Wrapper.au3 because the maxversiontested value has been added to it. To Do (possibilities): Option for volume level Option for playback rate Hotkeys Start on trigger (when logging in, when clicking Start menu, etc.) etc. Live Wallpaper Videos: I have only tested a bunch of .mp4 videos with this, including 4K. I have included bloom.mp4 which is rather low quality, but I wanted something that people can test with and it's small enough for attachment space. But there are many, many live wallpaper web sites out there. Some videos look good on loop (like a fireplace), while others don't. I'm sure lots of other video formats work. But I have only tested .mp4 and that is the format that most video wallpaper sites use. LiveWallpaper.7z
    4 points
  3. I've done enough editing of image files to know a few things. If you are going to have % of transparency you should have a small input section from 0 - 255 as exacting levels of transparency. Most people cannot tell the difference of 1% to about 5% level of transparency, but some might want the option to have exacting levels for better control. Don't presume that about me. I don't like to lie as much as stretching the truth so far that is snaps back on me like a rubber band that has broke from the stress.
    4 points
  4. Nine

    GIF Animation (cached)

    After giving it some thoughts, I went with a callback function to modify any aspect of the GIF frame by frame. You need to provide a valid callback function receiving a GDI+ image handle (originating from the GIF) and returning a modified GDI+ handle to fit the size of the GIF control creation. A few tests showed me that the callback function seems to be the fastest approach. Added a basic example showing how to use the callback. New version available
    4 points
  5. So you are a real language ✨Universalist ✨
    3 points
  6. A generic map function: ;Coded by UEZ build 2025-10-29 Func Map($val, $source_start, $source_stop, $dest_start, $dest_stop) Return (($val - $source_start) * ($dest_stop - $dest_start) / ($source_stop - $source_start) + $dest_start) EndFunc $iCol = Int(Map(87, 0, 100, 0, 255)) ConsoleWrite($iCol & " - 0x" & Hex($iCol, 2) & @CRLF) ;87% from color value (0 - 255) $iCol = 1 + Int(Map($iCol, 0, 255, 0, 100)) ;and back again ConsoleWrite($iCol & " - 0x" & Hex($iCol, 2) & @CRLF)
    3 points
  7. Updated v25.205.1420.14 available in Beta.
    3 points
  8. Thanks for getting to the bottom of this. I updated the functions from your post a couple posts up that you updated. The functions work which is great. But unfortunately the video just shows black and will not play. I'll have to do some more research into how to get this to work. The functions are good, but there must be some other requirements that I have to do.
    2 points
  9. No worries! This one probably needs a tidy up - but here's a rough snappy-snappy version. If this is useful, I can probably just keep chipping away at it over the weekend if you'd like? - Just proof of concept things like click-to-select, or multi-select with shift & ctrl etc.. Edit: You need to drag out rectangles to create buttons in this example! #include <guiConstants.au3> #include <winapi.au3> Global Const $MK_LBUTTON = 1 Global Const $iSnap = 15 Global $hCursor_Cross = _WinAPI_LoadCursor(0, $IDC_CROSS) Global $hGui = GUICreate("", 300, 200, 100, 100, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX)) Global $hBtnProc = DllCallbackRegister("btnProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") Global $pBtnProc = DllCallbackGetPtr($hBtnProc) Global $hWndProc = DllCallbackRegister("WndProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") Global $pWndProc = DllCallbackGetPtr($hWndProc) _WinAPI_SetWindowSubclass($hGui, $pWndProc, 1000) GUISetState() Local $iMsg While WinExists($hGui) $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass($hGui, $pWndProc, 1000) Func WndProc($hWnd, $iMsg, $wParam, $lParam, $iIdSubclass, $dwRefData) Local $iRet Local Static $bDrawRect, $tRect = DllStructCreate($tagRect) Switch $iMsg Case $WM_SETCURSOR Local $iSrc = BitAND($lParam, 0xFFFF), $iEvent = BitShift($lParam, 16) If $iSrc = $HTCLIENT Then _WinAPI_SetCursor($hCursor_Cross) $iRet = 1 Else $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndIf Case $WM_LBUTTONDOWN $tRect.Left = BitAND($lParam, 0xFFFF) $tRect.Top = BitShift($lParam, 16) $tRect.Left -= Mod($tRect.Left, $iSnap) $tRect.Top -= Mod($tRect.Top, $iSnap) $bDrawRect = True $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Case $WM_MOUSEMOVE ;~ Local $iX = BitAND($lParam, 0xFFFF), $iY = BitShift($lParam, 16) If BitAND($wParam, $MK_LBUTTON) = $MK_LBUTTON Then _WinAPI_InvalidateRect($hWnd, $tRect, True) $tRect.Right = BitAND($lParam, 0xFFFF) $tRect.Bottom = BitShift($lParam, 16) $tRect.Right -= Mod($tRect.Right, $iSnap) $tRect.Bottom -= Mod($tRect.Bottom, $iSnap) _WinAPI_InvalidateRect($hWnd, $tRect, True) $iRet = 0 Else $bDrawRect = False $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndIf Case $WM_PAINT If $bDrawRect Then Local $tPaintStruct = $tagPAINTSTRUCT Local $hDC = _WinAPI_BeginPaint($hWnd, $tPaintStruct) Local $hPen = _WinAPI_CreatePen($PS_DOT, 1, _WinAPI_RGB(0, 0, 0)) Local $hBrush = _WinAPI_GetStockObject($WHITE_BRUSH) _WinAPI_SelectObject($hDC, $hPen) _WinAPI_SelectObject($hDC, $hBrush) _WinAPI_Rectangle($hDC, $tRect) _WinAPI_DeleteObject($hPen) _WinAPI_DeleteObject($hBrush) _WinAPI_EndPaint($hWnd, $tPaintStruct) $iRet = 0 Else $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndIf Case $WM_LBUTTONUP $bDrawRect = False $tRect.Right = BitAND($lParam, 0xFFFF) $tRect.Bottom = BitShift($lParam, 16) $tRect.Right -= Mod($tRect.Right, $iSnap) $tRect.Bottom -= Mod($tRect.Bottom, $iSnap) _WinAPI_InvalidateRect($hWnd, $tRect, True) Local $idBtn = GUICtrlCreateButton("", _ ($tRect.Left < $tRect.Right) ? $tRect.Left : $tRect.Right, _ ($tRect.Top < $tRect.Bottom) ? $tRect.Top : $tRect.Bottom, _ Abs($tRect.Left - $tRect.Right), _ Abs($tRect.Top - $tRect.Bottom)) _WinAPI_SetWindowSubclass(GUICtrlGetHandle($idBtn), $pBtnProc, $idBtn) $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Case $WM_SIZE ;This prevents autoit's docking logic from moving controls around on window restore. $iRet = _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam) Case Else $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndSwitch Return $iRet EndFunc ;==>WndProc Func btnProc($hWnd, $iMsg, $wParam, $lParam, $iIdSubclass, $dwRefData) Local $iRet Local Static $iXOffset, $iYOffset Switch $iMsg Case $WM_NCHITTEST Local $aPoint[2] = [BitAND($lParam, 0xFFFF), BitShift($lParam, 16)] ;Mouse coords can be negative on edge cases! If BitAND($aPoint[0], 0x8000) Then $aPoint[0] = BitOR(0xFFFF0000, $aPoint[0]) If BitAND($aPoint[1], 0x8000) Then $aPoint[1] = BitOR(0xFFFF0000, $aPoint[1]) Local $aPos = WinGetPos($hWnd), $iMar = 10 $iRet = $HTCAPTION If $aPoint[0] - $aPos[0] < $iMar Then $iRet = $HTLEFT If $aPoint[0] - $aPos[0] > ($aPos[2] - $iMar) Then $iRet = $HTRIGHT If $aPoint[1] - $aPos[1] < $iMar Then Switch $iRet Case $HTLEFT $iRet = $HTTOPLEFT Case $HTRIGHT $iRet = $HTTOPRIGHT Case Else $iRet = $HTTOP EndSwitch ElseIf $aPoint[1] - $aPos[1] > ($aPos[3] - $iMar) Then Switch $iRet Case $HTLEFT $iRet = $HTBOTTOMLEFT Case $HTRIGHT $iRet = $HTBOTTOMRIGHT Case Else $iRet = $HTBOTTOM EndSwitch EndIf If $aPoint[0] < 0 Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) If $aPoint[1] < 0 Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) _WinAPI_RedrawWindow($hWnd) Case $WM_NCLBUTTONDBLCLK ;Prevent double-click maximizing in "caption" If $wParam <> $HTCAPTION Then $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Case $WM_SIZING Local $tRect = DllStructCreate($tagRect, $lParam) Local $tRect2 = _WinAPI_GetWindowRect($hWnd) $tRect.Left += Mod($tRect2.Left - $tRect.Left, $iSnap) $tRect.Top += Mod($tRect2.Top - $tRect.Top, $iSnap) $tRect.Right += Mod($tRect2.Right - $tRect.Right, $iSnap) $tRect.Bottom += Mod($tRect2.Bottom - $tRect.Bottom, $iSnap) $iRet = True Case $WM_MOVING Local $tRect = DllStructCreate($tagRect, $lParam) Local $tRect2 = _WinAPI_GetWindowRect($hWnd) $iXOffset += $tRect.Left - $tRect2.Left $iYOffset += $tRect.Top - $tRect2.Top Local $iSnapH = Floor($iXOffset / $iSnap) * $iSnap Local $iSnapV = Floor($iYOffset / $iSnap) * $iSnap $iXOffset -= $iSnapH $iYOffset -= $iSnapV $tRect.Left = $tRect2.Left + $iSnapH $tRect.Right = $tRect2.Right + $iSnapH $tRect.Top = $tRect2.Top + $iSnapV $tRect.Bottom = $tRect2.Bottom + $iSnapV $iRet = 0 Case $WM_EXITSIZEMOVE $iXOffset = 0 $iYOffset = 0 $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Case $WM_SETCURSOR Local $iSrc = BitAND($lParam, 0xFFFF), $iEvent = BitShift($lParam, 16) If $iSrc = $HTCAPTION And $iEvent = $WM_LBUTTONDOWN Then _WinAPI_SetCursor($hCursor_Cross) $iRet = 1 Else $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndIf Case Else $iRet = _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndSwitch Return $iRet EndFunc ;==>btnProc
    2 points
  10. On that point I should confess that I haven't updated my everyday PC to the latest version and that have projects still in v3.3.14.2 on other PCs ( quite shamelessly too ). If I had to start a new project, it'd be advisable to use the latest. In this case, that is so involved with the OS, is more important than just a SQLite script ( for example ), were the GUI is just to have a working interface. So yes, I too am of the opinion that you should focus the project on the updated engine/stub and it's UDFs. And as you've discovered yourself, a portable instance of other versions are quite simple to have. ( suck on that python !. ppl had to invent "Docker" to solve your issues ! )
    2 points
  11. Just be aware that the function which actually uses $CP_UTF8 (_WinAPI_MultiByteToWideChar) has also changed since the update.... The old version of this doesn't work as the strings in the metadata files aren't null-terminated. Not that we're necessarily calling this func in this project - but just FYI!
    2 points
  12. Local. Inside the function.
    2 points
  13. I was just trying to figure out what that extra info really contributes! 😉
    2 points
  14. 2 points
  15. It’s Argumentum who is active here and on the german forum.
    2 points
  16. Because that can make a Pres out of U and Me ... whatever a Pres is ... maybe some kind of Trump thing. Not only that, but the truth can be stretched so much it becomes unrecognizable ... that's when Oranges can be like Apples and Bananas like Sausages ... so Gastronomy suffers and we all end up with a belly ache. I don't know about you, but I prefer to not have sausages in my Fruit Salad ... or Bananas and Mash.
    2 points
  17. The starting digit is 0 not 1, so it is 256 levels of transparency.
    2 points
  18. ConsoleWrite( myPercentThing(200) & @CRLF) ConsoleWrite( myPercentThing(100) & @CRLF) ConsoleWrite( myPercentThing(50) & @CRLF) ConsoleWrite( myPercentThing(0) & @CRLF) ConsoleWrite( myPercentThing(-1000) & @CRLF) Func myPercentThing($vDecimal) $vDecimal = ($vDecimal < 0 ? 0 : $vDecimal) $vDecimal = ($vDecimal > 100 ? 100 : $vDecimal) Return Ceiling($vDecimal * 2.55) ; round up EndFunc 0 visibility is totally transparent. Make a minimum of 50 🤔
    2 points
  19. Your math is always sharp. Thank you so much.
    2 points
  20. Not if you format the function headers in the correct way, then you just need to prepare a few text files and run a script. Please see Simple Library Docs Generator
    2 points
  21. wakillon

    enumicons.au3

    New Version 2.1.0.4 Display modified Left click on an icon for save it with the size you want, regardless of the mode (Ordinal/Name) used The file path is indicated as ioa747 wished enumicons.au3
    2 points
  22. Thank you for your kind words, regarding Date/Time Format, take a look at Free style DateTimeFormat
    2 points
  23. Some 3 month ago examples were added for what I see. Following the examples should show what each function does. I don't use spreadsheets but if I needed to, I'd have to learn that, ... in a hurry. And automate it even faster ( all this while clueless "inexperienced" ) I don't think that there is a way around "the learning curve". Maybe making wrapper functions ala "Word user defined functions" would help for the _LODoc_* functions 🤔 I believe that if something is overwhelming, it is so for the uninitiated, and not because is poorly thought-out. Ok, let's look at me. I push for forking and wrote some wrappers/ideas yet, many find it overwhelming/too much/too difficult. What can I do 🤷‍♂️ Nothing. Each will gain understanding as they gain experience with the concept(s) and the solution(s). Yeah. Nothing you can do other than examples for the functions and that you did.
    2 points
  24. Gotta say, nice looking and with the new includes, right on time too.
    2 points
  25. Because working with multiple monitors was required during the development of ImageSearchUDF , this UDF was created UDF: #include-once #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> ; =============================================================================================================================== ; Title .........: Monitor UDF ; Description ...: Provides advanced monitor management and multi-monitor utilities. ; Author ........: Dao Van Trong - TRONG.PRO ; <MonitorUDF.au3> ; =============================================================================================================================== ; FUNCTIONS SUMMARY ; =============================================================================================================================== ; _Monitor_GetList() - Enumerate connected monitors and fill global info. ; _Monitor_GetCount() - Return total number of monitors. ; _Monitor_GetPrimary() - Get index of the primary monitor. ; _Monitor_GetInfo($iMonitor) - Get detailed info about a monitor. ; _Monitor_GetBounds($iMonitor, ...) - Get full monitor rectangle (including taskbar). ; _Monitor_GetWorkArea($iMonitor, ...) - Get working area of a monitor (excluding taskbar). ; _Monitor_GetDisplaySettings($iMonitor) - Get current display mode. ; _Monitor_GetResolution($iMonitor) - Get monitor resolution. ; _Monitor_GetFromPoint([$x, $y]) - Get monitor from screen point or mouse. ; _Monitor_GetFromWindow($hWnd) - Get monitor containing a specific window. ; _Monitor_GetFromRect(...) - Get monitor overlapping a given rectangle. ; _Monitor_GetVirtualBounds() - Get bounding rectangle of the entire virtual screen. ; _Monitor_ToVirtual($iMonitor, $x, $y) - Convert local monitor coordinates to virtual coordinates. ; _Monitor_FromVirtual($iMonitor, $x, $y)- Convert from virtual to local monitor coordinates. ; _Monitor_IsVisibleWindow($hWnd) - Check if a window is top-level visible. ; _Monitor_MoveWindowToScreen(...) - Move a window to specific monitor (center if unspecified). ; _Monitor_MoveWindowToAll(...) - Move a visible window across all monitors. ; _Monitor_EnumAllDisplayModes($iMonitor)- Enumerate all available display modes. ; _Monitor_ShowInfo() - Show all monitor information in MsgBox. ; =============================================================================================================================== #Region --- Global Variables --- ; =============================================================================================================================== ; Global Monitor Information Array ; =============================================================================================================================== ; $__g_aMonitorList[][] structure: ; ; [0][0] = Number of monitors detected ; [0][1] = Virtual desktop Left coordinate (combined area) ; [0][2] = Virtual desktop Top coordinate ; [0][3] = Virtual desktop Right coordinate ; [0][4] = Virtual desktop Bottom coordinate ; [0][5] = Virtual desktop Width ; [0][6] = Virtual desktop Height ; ; For each monitor index i (1..$__g_aMonitorList[0][0]): ; [i][0] = Monitor handle (HMONITOR) ; [i][1] = Left coordinate of monitor ; [i][2] = Top coordinate of monitor ; [i][3] = Right coordinate of monitor ; [i][4] = Bottom coordinate of monitor ; [i][5] = IsPrimary (1 if primary, 0 otherwise) ; [i][6] = Device name string (e.g. "\\.\DISPLAY1") ; ; Example: ; ;If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() ; $__g_aMonitorList[0][0] = 2 ; $__g_aMonitorList[1] = [0x00010001, 0, 0, 1920, 1080, 1, "\\.\DISPLAY1"] ; $__g_aMonitorList[2] = [0x00020002, 1920, 0, 3840, 1080, 0, "\\.\DISPLAY2"] ; ; =============================================================================================================================== Global $__g_aMonitorList[1][7] = [[0, 0, 0, 0, 0, 0, ""]] #EndRegion --- Global Variables --- ; =============================================================================================================================== ; FUNCTION: _Monitor_GetFromPoint([$iX = -1[, $iY = -1]]) ; PURPOSE : Get the monitor index from a screen coordinate or current mouse position ; RETURN : Monitor index (1..N) or 0 if not found ; =============================================================================================================================== Func _Monitor_GetFromPoint($iX = -1, $iY = -1) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() ; Use WinAPI function if available If $iX = -1 Or $iY = -1 Then Local $aMouse = MouseGetPos() $iX = $aMouse[0] $iY = $aMouse[1] EndIf Local $tPoint = DllStructCreate($tagPOINT) DllStructSetData($tPoint, "X", $iX) DllStructSetData($tPoint, "Y", $iY) Local $hMonitor = _WinAPI_MonitorFromPoint($tPoint, $MONITOR_DEFAULTTONEAREST) ; Find index in our list For $i = 1 To $__g_aMonitorList[0][0] If $__g_aMonitorList[$i][0] = $hMonitor Then Return $i Next ; Fallback to coordinate checking For $i = 1 To $__g_aMonitorList[0][0] If $iX >= $__g_aMonitorList[$i][1] _ And $iX < $__g_aMonitorList[$i][3] _ And $iY >= $__g_aMonitorList[$i][2] _ And $iY < $__g_aMonitorList[$i][4] Then Return $i EndIf Next Return 0 EndFunc ;==>_Monitor_GetFromPoint ; =============================================================================================================================== ; FUNCTION: _Monitor_GetFromWindow($hWnd[, $iFlag = $MONITOR_DEFAULTTONEAREST]) ; PURPOSE : Get the monitor index that contains the specified window ; RETURN : Monitor index (1..N) or 0 if not found ; =============================================================================================================================== Func _Monitor_GetFromWindow($hWnd, $iFlag = $MONITOR_DEFAULTTONEAREST) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If Not IsHWnd($hWnd) Then $hWnd = WinGetHandle($hWnd) If Not $hWnd Then Return SetError(1, 0, 0) Local $hMonitor = _WinAPI_MonitorFromWindow($hWnd, $iFlag) If Not $hMonitor Then Return SetError(2, 0, 0) For $i = 1 To $__g_aMonitorList[0][0] If $__g_aMonitorList[$i][0] = $hMonitor Then Return $i Next Return 0 EndFunc ;==>_Monitor_GetFromWindow ; =============================================================================================================================== ; FUNCTION: _Monitor_GetFromRect($iLeft, $iTop, $iRight, $iBottom[, $iFlag = $MONITOR_DEFAULTTONEAREST]) ; PURPOSE : Get the monitor index that has the largest intersection with the specified rectangle ; RETURN : Monitor index (1..N) or 0 if not found ; =============================================================================================================================== Func _Monitor_GetFromRect($iLeft, $iTop, $iRight, $iBottom, $iFlag = $MONITOR_DEFAULTTONEAREST) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() Local $tRect = DllStructCreate($tagRECT) DllStructSetData($tRect, "Left", $iLeft) DllStructSetData($tRect, "Top", $iTop) DllStructSetData($tRect, "Right", $iRight) DllStructSetData($tRect, "Bottom", $iBottom) Local $hMonitor = _WinAPI_MonitorFromRect($tRect, $iFlag) If Not $hMonitor Then Return SetError(1, 0, 0) For $i = 1 To $__g_aMonitorList[0][0] If $__g_aMonitorList[$i][0] = $hMonitor Then Return $i Next Return 0 EndFunc ;==>_Monitor_GetFromRect ; =============================================================================================================================== ; FUNCTION: _Monitor_GetWorkArea($iMonitor, ByRef $left, ByRef $top, ByRef $right, ByRef $bottom) ; PURPOSE : Get working area of a specific monitor (excluding taskbar) ; RETURN : 1 on success, 0 on failure ; =============================================================================================================================== Func _Monitor_GetWorkArea($iMonitor, ByRef $left, ByRef $top, ByRef $right, ByRef $bottom) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(1, 0, 0) Local $hMonitor = $__g_aMonitorList[$iMonitor][0] Local $aInfo = _WinAPI_GetMonitorInfo($hMonitor) If @error Then Return SetError(2, 0, 0) Local $tWorkArea = $aInfo[1] $left = DllStructGetData($tWorkArea, "Left") $top = DllStructGetData($tWorkArea, "Top") $right = DllStructGetData($tWorkArea, "Right") $bottom = DllStructGetData($tWorkArea, "Bottom") Return 1 EndFunc ;==>_Monitor_GetWorkArea ; =============================================================================================================================== ; FUNCTION: _Monitor_GetBounds($iMonitor, ByRef $left, ByRef $top, ByRef $right, ByRef $bottom) ; PURPOSE : Get full bounds of a specific monitor (including taskbar) ; RETURN : 1 on success, 0 on failure ; =============================================================================================================================== Func _Monitor_GetBounds($iMonitor, ByRef $left, ByRef $top, ByRef $right, ByRef $bottom) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(1, 0, 0) $left = $__g_aMonitorList[$iMonitor][1] $top = $__g_aMonitorList[$iMonitor][2] $right = $__g_aMonitorList[$iMonitor][3] $bottom = $__g_aMonitorList[$iMonitor][4] Return 1 EndFunc ;==>_Monitor_GetBounds ; =============================================================================================================================== ; FUNCTION: _Monitor_GetInfo($iMonitor) ; PURPOSE : Get detailed information about a monitor ; RETURN : Array [Handle, Left, Top, Right, Bottom, WorkLeft, WorkTop, WorkRight, WorkBottom, IsPrimary, DeviceName] ; =============================================================================================================================== Func _Monitor_GetInfo($iMonitor) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(1, 0, 0) Local $hMonitor = $__g_aMonitorList[$iMonitor][0] Local $aInfo = _WinAPI_GetMonitorInfo($hMonitor) If @error Then Return SetError(2, 0, 0) Local $tMonitorRect = $aInfo[0] Local $tWorkRect = $aInfo[1] Local $aResult[11] $aResult[0] = $hMonitor $aResult[1] = DllStructGetData($tMonitorRect, "Left") $aResult[2] = DllStructGetData($tMonitorRect, "Top") $aResult[3] = DllStructGetData($tMonitorRect, "Right") $aResult[4] = DllStructGetData($tMonitorRect, "Bottom") $aResult[5] = DllStructGetData($tWorkRect, "Left") $aResult[6] = DllStructGetData($tWorkRect, "Top") $aResult[7] = DllStructGetData($tWorkRect, "Right") $aResult[8] = DllStructGetData($tWorkRect, "Bottom") $aResult[9] = ($aInfo[2] <> 0) ; IsPrimary $aResult[10] = $aInfo[3] ; DeviceName Return $aResult EndFunc ;==>_Monitor_GetInfo ; =============================================================================================================================== ; FUNCTION: _Monitor_GetDisplaySettings($iMonitor[, $iMode = $ENUM_CURRENT_SETTINGS]) ; PURPOSE : Get display settings for a monitor ; RETURN : Array [Width, Height, BitsPerPixel, Frequency, DisplayMode] ; =============================================================================================================================== Func _Monitor_GetDisplaySettings($iMonitor, $iMode = $ENUM_CURRENT_SETTINGS) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(1, 0, 0) Local $sDevice = $__g_aMonitorList[$iMonitor][6] If $sDevice = "" Then Local $aInfo = _Monitor_GetInfo($iMonitor) If @error Then Return SetError(2, 0, 0) $sDevice = $aInfo[10] EndIf Local $aSettings = _WinAPI_EnumDisplaySettings($sDevice, $iMode) If @error Then Return SetError(3, 0, 0) Return $aSettings EndFunc ;==>_Monitor_GetDisplaySettings ; =============================================================================================================================== ; FUNCTION: _Monitor_GetResolution($iMonitor) ; PURPOSE : Get resolution of a monitor ; RETURN : Array [Width, Height] ; =============================================================================================================================== Func _Monitor_GetResolution($iMonitor) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(1, 0, 0) Local $aSettings = _Monitor_GetDisplaySettings($iMonitor) If @error Then Return SetError(2, 0, 0) Local $aResult[2] = [$aSettings[0], $aSettings[1]] Return $aResult EndFunc ;==>_Monitor_GetResolution ; =============================================================================================================================== ; FUNCTION: _Monitor_GetPrimary() ; PURPOSE : Get the index of the primary monitor ; RETURN : Monitor index (1..N) or 0 if not found ; =============================================================================================================================== Func _Monitor_GetPrimary() If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() For $i = 1 To $__g_aMonitorList[0][0] Local $aInfo = _Monitor_GetInfo($i) If Not @error And $aInfo[9] = 1 Then Return $i Next Return 0 EndFunc ;==>_Monitor_GetPrimary ; =============================================================================================================================== ; FUNCTION: _Monitor_GetCount() ; PURPOSE : Returns total number of monitors ; =============================================================================================================================== Func _Monitor_GetCount() Local $aRet = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_CMONITORS) If @error Or Not IsArray($aRet) Then If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() Return $__g_aMonitorList[0][0] Else Return $aRet[0] EndIf EndFunc ;==>_Monitor_GetCount ; =============================================================================================================================== ; FUNCTION: _Monitor_GetVirtualBounds() ; PURPOSE : Get bounding rectangle of all monitors (the "virtual screen") ; RETURN : Array [Left, Top, Width, Height] ; =============================================================================================================================== Func _Monitor_GetVirtualBounds() Local $aL = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 76) ; SM_XVIRTUALSCREEN Local $aT = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 77) ; SM_YVIRTUALSCREEN Local $aW = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 78) ; SM_CXVIRTUALSCREEN Local $aH = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 79) ; SM_CYVIRTUALSCREEN Local $a[4] = [$aL[0], $aT[0], $aW[0], $aH[0]] Return $a EndFunc ;==>_Monitor_GetVirtualBounds ; =============================================================================================================================== ; FUNCTION: _Monitor_ToVirtual($iMonitor, $x, $y) ; PURPOSE : Convert local monitor coordinates to virtual screen coordinates ; =============================================================================================================================== Func _Monitor_ToVirtual($iMonitor, $x, $y) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(1, 0, 0) Local $aRet[2] = [$__g_aMonitorList[$iMonitor][1] + $x, $__g_aMonitorList[$iMonitor][2] + $y] Return $aRet EndFunc ;==>_Monitor_ToVirtual ; =============================================================================================================================== ; FUNCTION: _Monitor_FromVirtual($iMonitor, $x, $y) ; PURPOSE : Convert virtual coordinates back to local monitor coordinates ; =============================================================================================================================== Func _Monitor_FromVirtual($iMonitor, $x, $y) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(1, 0, 0) Local $aRet[2] = [$x - $__g_aMonitorList[$iMonitor][1], $y - $__g_aMonitorList[$iMonitor][2]] Return $aRet EndFunc ;==>_Monitor_FromVirtual ; =============================================================================================================================== ; FUNCTION: _Monitor_IsVisibleWindow($hWnd) ; PURPOSE : Check if window is visible and top-level ; RETURN : True / False ; =============================================================================================================================== Func _Monitor_IsVisibleWindow($hWnd) If Not IsHWnd($hWnd) Then $hWnd = WinGetHandle($hWnd) If Not $hWnd Or Not WinExists($hWnd) Then Return False Local $style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) If BitAND($style, $WS_VISIBLE) = 0 Then Return False If BitAND($style, $WS_CHILD) <> 0 Then Return False Local $ex = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) If BitAND($ex, $WS_EX_TOOLWINDOW) <> 0 Then Return False Return True EndFunc ;==>_Monitor_IsVisibleWindow ; =============================================================================================================================== ; FUNCTION: _Monitor_MoveWindowToScreen($vTitle, $sText = "", $iMonitor = -1, $x = -1, $y = -1, $bUseWorkArea = True) ; PURPOSE : Move visible window to a monitor (centered if $x=$y=-1) ; =============================================================================================================================== Func _Monitor_MoveWindowToScreen($vTitle, $sText = "", $iMonitor = -1, $x = -1, $y = -1, $bUseWorkArea = True) Local $hWnd = IsHWnd($vTitle) ? $vTitle : WinGetHandle($vTitle, $sText) If Not _Monitor_IsVisibleWindow($hWnd) Then Return SetError(1, 0, 0) If $iMonitor = -1 Then $iMonitor = 1 If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(2, 0, 0) Local $aWinPos = WinGetPos($hWnd) If @error Or Not IsArray($aWinPos) Then Return SetError(3, 0, 0) Local $iLeft, $iTop, $iRight, $iBottom If $bUseWorkArea Then _Monitor_GetWorkArea($iMonitor, $iLeft, $iTop, $iRight, $iBottom) Else _Monitor_GetBounds($iMonitor, $iLeft, $iTop, $iRight, $iBottom) EndIf Local $iWidth = $iRight - $iLeft Local $iHeight = $iBottom - $iTop If $x = -1 Or $y = -1 Then $x = $iLeft + ($iWidth - $aWinPos[2]) / 2 $y = $iTop + ($iHeight - $aWinPos[3]) / 2 Else $x += $iLeft $y += $iTop EndIf WinMove($hWnd, "", $x, $y) Return 1 EndFunc ;==>_Monitor_MoveWindowToScreen ; =============================================================================================================================== ; FUNCTION: _Monitor_MoveWindowToAll($vTitle, $sText = "", $bCenter = True, $iDelay = 1000) ; PURPOSE : Move a visible window sequentially across all monitors ; =============================================================================================================================== Func _Monitor_MoveWindowToAll($vTitle, $sText = "", $bCenter = True, $iDelay = 1000) Local $hWnd = IsHWnd($vTitle) ? $vTitle : WinGetHandle($vTitle, $sText) If Not _Monitor_IsVisibleWindow($hWnd) Then Return SetError(1, 0, 0) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() For $i = 1 To $__g_aMonitorList[0][0] If $bCenter Then _Monitor_MoveWindowToScreen($hWnd, "", $i) Else _Monitor_MoveWindowToScreen($hWnd, "", $i, 50, 50) EndIf Sleep($iDelay) Next Return 1 EndFunc ;==>_Monitor_MoveWindowToAll ; =============================================================================================================================== ; FUNCTION: _Monitor_EnumAllDisplayModes($iMonitor) ; PURPOSE : Enumerate all available display modes for a monitor ; RETURN : 2D array [[Width, Height, BitsPerPixel, Frequency, DisplayMode], ...] ; =============================================================================================================================== Func _Monitor_EnumAllDisplayModes($iMonitor) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() If $iMonitor < 1 Or $iMonitor > $__g_aMonitorList[0][0] Then Return SetError(1, 0, 0) Local $aInfo = _Monitor_GetInfo($iMonitor) If @error Then Return SetError(2, 0, 0) Local $sDevice = $aInfo[10] Local $aModes[1][5] $aModes[0][0] = 0 Local $iIndex = 0 While True Local $aMode = _WinAPI_EnumDisplaySettings($sDevice, $iIndex) If @error Then ExitLoop ReDim $aModes[$aModes[0][0] + 2][5] $aModes[0][0] += 1 $aModes[$aModes[0][0]][0] = $aMode[0] $aModes[$aModes[0][0]][1] = $aMode[1] $aModes[$aModes[0][0]][2] = $aMode[2] $aModes[$aModes[0][0]][3] = $aMode[3] $aModes[$aModes[0][0]][4] = $aMode[4] $iIndex += 1 WEnd If $aModes[0][0] = 0 Then Return SetError(3, 0, 0) Return $aModes EndFunc ;==>_Monitor_EnumAllDisplayModes ; =============================================================================================================================== ; FUNCTION: _Monitor_GetList() ; PURPOSE : Enumerate connected monitors and fill the global list using _WinAPI_EnumDisplayMonitors ; RETURN : Number of monitors, or -1 on error ; =============================================================================================================================== Func _Monitor_GetList() Local $aMonitors = _WinAPI_EnumDisplayMonitors() If @error Then Return SetError(1, 0, -1) ReDim $__g_aMonitorList[$aMonitors[0][0] + 1][7] $__g_aMonitorList[0][0] = $aMonitors[0][0] Local $l_aVirtual = _Monitor_GetVirtualBounds() Local $l_vRight = $l_aVirtual[0] + $l_aVirtual[2] Local $l_vBottom = $l_aVirtual[1] + $l_aVirtual[3] $__g_aMonitorList[0][1] = $l_aVirtual[0] $__g_aMonitorList[0][2] = $l_aVirtual[1] $__g_aMonitorList[0][3] = $l_vRight $__g_aMonitorList[0][4] = $l_vBottom $__g_aMonitorList[0][5] = $l_aVirtual[2] $__g_aMonitorList[0][6] = $l_aVirtual[3] For $i = 1 To $aMonitors[0][0] Local $hMonitor = $aMonitors[$i][0] Local $tRect = $aMonitors[$i][1] $__g_aMonitorList[$i][0] = $hMonitor $__g_aMonitorList[$i][1] = DllStructGetData($tRect, "Left") $__g_aMonitorList[$i][2] = DllStructGetData($tRect, "Top") $__g_aMonitorList[$i][3] = DllStructGetData($tRect, "Right") $__g_aMonitorList[$i][4] = DllStructGetData($tRect, "Bottom") ; Get additional info Local $aInfo = _WinAPI_GetMonitorInfo($hMonitor) If Not @error Then Local $tWorkRect = $aInfo[1] $__g_aMonitorList[$i][5] = DllStructGetPtr($tWorkRect) $__g_aMonitorList[$i][6] = $aInfo[3] ; Device name EndIf Next Return $__g_aMonitorList[0][0] EndFunc ;==>_Monitor_GetList ; =============================================================================================================================== ; FUNCTION: _Monitor_ShowInfo($iTimeout = 10) ; PURPOSE : Show monitor coordinates and detailed information ; =============================================================================================================================== Func _Monitor_ShowInfo($Msg = 1, $iTimeout = 10) If $__g_aMonitorList[0][0] = 0 Then _Monitor_GetList() Local $sMsg = "> Total Monitors: " & $__g_aMonitorList[0][0] & @CRLF & @CRLF $sMsg &= StringFormat("+ Virtual Desktop: " & @CRLF & "Left=%d, Top=%d, Right=%d, Bottom=%d, Width=%d, Height=%d", $__g_aMonitorList[0][1], $__g_aMonitorList[0][2], $__g_aMonitorList[0][3], $__g_aMonitorList[0][4], $__g_aMonitorList[0][5], $__g_aMonitorList[0][6]) & @CRLF & @CRLF ; For $i = 1 To $__g_aMonitorList[0][0] Local $aInfo = _Monitor_GetInfo($i) If @error Then ContinueLoop Local $aSettings = _Monitor_GetDisplaySettings($i) Local $sResolution = @error ? "N/A" : $aSettings[0] & "x" & $aSettings[1] & " @" & $aSettings[3] & "Hz" $sMsg &= StringFormat("+ Monitor %d: %s%s\n", $i, $aInfo[9] ? "(Primary) " : "", $aInfo[10]) $sMsg &= StringFormat(" Bounds: L=%d, T=%d, R=%d, B=%d (%dx%d)\n", _ $aInfo[1], $aInfo[2], $aInfo[3], $aInfo[4], _ $aInfo[3] - $aInfo[1], $aInfo[4] - $aInfo[2]) $sMsg &= StringFormat(" Work Area: L=%d, T=%d, R=%d, B=%d (%dx%d)\n", _ $aInfo[5], $aInfo[6], $aInfo[7], $aInfo[8], _ $aInfo[7] - $aInfo[5], $aInfo[8] - $aInfo[6]) $sMsg &= " Resolution: " & $sResolution & @CRLF & @CRLF Next ConsoleWrite($sMsg) If $Msg Then MsgBox(64 + 262144, "Monitor Information", $sMsg, $iTimeout) Return $sMsg EndFunc ;==>_Monitor_ShowInfo ;~ _Monitor_ShowInfo(1, 3) EG: ; ================================================================================================== ; MonitorUDF_Examples.au3 ; Interactive example tester for MonitorUDF.au3 UDF (fixed: uses GuiListBox functions correctly) ; ================================================================================================== #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> #include <GuiEdit.au3> #include <Array.au3> #include "MonitorUDF.au3" ; make sure this file is In the same folder ; ================================================================================================== ; MonitorUDF_Examples.au3 ; Interactive tester with buttons for each MonitorUDF function + log edit ; Requires: MonitorUDF.au3 in the same folder ; ================================================================================================== ; ----------------------------- ; Create GUI ; ----------------------------- Global $GUI_W = 560, $GUI_H = 540 Global $hGUI = GUICreate("MonitorUDF - Examples (by TRONG.PRO)", $GUI_W, $GUI_H, -1, -1) GUISetBkColor(0xF5F5F5, $hGUI) ; Title GUICtrlCreateLabel("MonitorUDF Example Launcher", 12, 10, 400, 24) GUICtrlSetFont(-1, 12, 800, 0, 'Segoe UI', 5) ; Buttons column 1 Local $x1 = 12, $y1 = 48, $bw = 260, $bh = 36, $gap = 8 Global $iBtn1 = GUICtrlCreateButton("1. Enumerate monitors", $x1, $y1, $bw, $bh) Global $iBtn2 = GUICtrlCreateButton("2. Move Notepad -> Monitor #2 (center)", $x1, $y1 + ($bh + $gap) * 1, $bw, $bh) Global $iBtn3 = GUICtrlCreateButton("3. Move Notepad -> Monitor #2 @ (100,100)", $x1, $y1 + ($bh + $gap) * 2, $bw, $bh) Global $iBtn4 = GUICtrlCreateButton("4. Which monitor is mouse on?", $x1, $y1 + ($bh + $gap) * 3, $bw, $bh) Global $iBtn5 = GUICtrlCreateButton("5. Show virtual desktop bounds", $x1, $y1 + ($bh + $gap) * 4, $bw, $bh) ; Buttons column 2 Local $x2 = $x1 + $bw + 12 Global $iBtn6 = GUICtrlCreateButton("6. Convert coords (local <-> virtual)", $x2, $y1 + ($bh + $gap) * 0, $bw, $bh) Global $iBtn7 = GUICtrlCreateButton("7. Show monitor info (MsgBox)", $x2, $y1 + ($bh + $gap) * 1, $bw, $bh) Global $iBtn8 = GUICtrlCreateButton("8. Check if Notepad is visible", $x2, $y1 + ($bh + $gap) * 2, $bw, $bh) Global $iBtn9 = GUICtrlCreateButton("9. Move all visible windows -> primary", $x2, $y1 + ($bh + $gap) * 3, $bw, $bh) Global $iBtn10 = GUICtrlCreateButton("10. Create small GUI on each monitor", $x2, $y1 + ($bh + $gap) * 4, $bw, $bh) ; Controls: log edit, clear, auto-demo, close Local $logX = 12, $logY = $y1 + ($bh + $gap) * 6 Local $logW = $GUI_W - 24, $logH = 180 Global $idLog = GUICtrlCreateEdit("", $logX, $logY, $logW, $logH, BitOR($ES_READONLY, $WS_HSCROLL, $WS_VSCROLL, $ES_MULTILINE)) GUICtrlSetFont($idLog, 9) Global $idFuncTest__ClearLog = GUICtrlCreateButton("Clear Log", 12, $logY + $logH + 10, 120, 28) Global $idFuncTest__RunAllDemo = GUICtrlCreateButton("Auto Demo (Run 1..10)", 150, $logY + $logH + 10, 220, 28) Global $idFuncTest__Close = GUICtrlCreateButton("Close", $GUI_W - 120, $logY + $logH + 10, 100, 28) Global $pidNotepad = 0 GUISetState(@SW_SHOW) ; Keep a list of created GUIs for Example 10 so we can close them later Global $Msg, $g_createdGUIs = [] ; ----------------------------- ; Main loop ; ----------------------------- While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE, $idFuncTest__Close ; close any GUIs created in example 10 For $i = 0 To UBound($g_createdGUIs) - 1 If IsHWnd($g_createdGUIs[$i]) Then GUIDelete($g_createdGUIs[$i]) Next ExitLoop Case $idFuncTest__ClearLog GUICtrlSetData($idLog, '', '') Case $idFuncTest__RunAllDemo FuncTest_1() Sleep(1000) ; $iBtn2 FuncTest_2() Sleep(2000) ; $iBtn3 ProcessClose($pidNotepad) FuncTest_3() Sleep(2000) ; $iBtn4 ProcessClose($pidNotepad) FuncTest_4() Sleep(1000) ; $iBtn5 FuncTest_5() Sleep(1000) ; $iBtn6 FuncTest_6() Sleep(1000) ; $iBtn7 FuncTest_7() Sleep(1000) ; $iBtn8 FuncTest_8() Sleep(2000) ; $iBtn9 ProcessClose($pidNotepad) FuncTest_9() Sleep(1000) ; $iBtn10 FuncTest_10() Sleep(2000) ; $iBtn10 For $i = 0 To UBound($g_createdGUIs) - 1 If IsHWnd($g_createdGUIs[$i]) Then GUIDelete($g_createdGUIs[$i]) Next Case $iBtn1 FuncTest_1() Case $iBtn2 FuncTest_2() Case $iBtn3 FuncTest_3() Case $iBtn4 FuncTest_4() Case $iBtn5 FuncTest_5() Case $iBtn6 FuncTest_6() Case $iBtn7 FuncTest_7() Case $iBtn8 FuncTest_8() Case $iBtn9 FuncTest_9() Case $iBtn10 FuncTest_10() EndSwitch Sleep(5) WEnd GUIDelete() Exit 0 ; ----------------------------- ; Helper: append to log (with timestamp) ; ----------------------------- Func _Log($s) ConsoleWrite($s & @CRLF) Local $t = @HOUR & ":" & @MIN & ":" & @SEC Local $cur = GUICtrlRead($idLog) If $cur = "" Then GUICtrlSetData($idLog, "[" & $t & "] " & $s) Else GUICtrlSetData($idLog, $cur & @CRLF & "[" & $t & "] " & $s) EndIf ; move caret to end _GUICtrlEdit_LineScroll($idLog, 0, _GUICtrlEdit_GetLineCount($idLog)) EndFunc ;==>_Log Func FuncTest_1() _Log('+ TEST 1: Enumerate monitors -----------------------\') ; Enumerate monitors _Monitor_GetList() Local $cnt = _Monitor_GetCount() _Log("---> Example 1: Monitors detected: " & $cnt) For $i = 1 To $cnt Local $a = _Monitor_GetInfo($i) _Log(" Monitor " & $i & ": Device=" & $a[10] & " Bounds=(" & $a[1] & "," & $a[2] & ")-(" & $a[3] & "," & $a[4] & ") Work=(" & $a[5] & "," & $a[6] & ")-(" & $a[7] & "," & $a[8] & ") Primary=" & $a[9]) Next _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_1 Func FuncTest_2() _Log('+ TEST 2: Move Notepad to monitor #2 centered ------\') ; Move Notepad to monitor #2 centered $pidNotepad = Run("notepad.exe") If Not WinWaitActive("[CLASS:Notepad]", "", 5) Then _Log("---> Example 2: Notepad did not start / focus") Else Sleep(1000) _Monitor_GetList() If _Monitor_GetCount() < 2 Then _Log("---> Example 2: Need at least 2 monitors") Else _Monitor_MoveWindowToScreen("[CLASS:Notepad]", "", 2, -1, -1, True) _Log("---> Example 2: Notepad moved to monitor #2 (centered)") EndIf EndIf _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_2 Func FuncTest_3() _Log('+ TEST 3: Move Notepad to monitor #2 at (100,100 ----\)') ; Move Notepad to monitor #2 at (100,100) $pidNotepad = Run("notepad.exe") If Not WinWaitActive("[CLASS:Notepad]", "", 5) Then _Log("---> Example 3: Notepad did not start / focus") Else Sleep(1000) _Monitor_GetList() If _Monitor_GetCount() < 2 Then _Log("---> Example 3: Need at least 2 monitors") Else _Monitor_MoveWindowToScreen("[CLASS:Notepad]", "", 2, 100, 100, True) _Log("---> Example 3: Notepad moved to monitor #2 at (100,100)") EndIf EndIf _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_3 Func FuncTest_4() _Log('+ TEST 4: Which monitor is mouse on ------------------\') ; Which monitor is mouse on _Monitor_GetList() Local $m = _Monitor_GetFromPoint() _Log("---> Example 4: Mouse is on monitor #" & $m) MsgBox(64, "Example 4", "Mouse is on monitor #" & $m, 2) _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_4 Func FuncTest_5() _Log('+ TEST 5: Virtual desktop bounds -----------------------\') ; Virtual desktop bounds Local $aV = _Monitor_GetVirtualBounds() _Log("---> Example 5: Virtual bounds L=" & $aV[0] & " T=" & $aV[1] & " W=" & $aV[2] & " H=" & $aV[3]) MsgBox(64, "Example 6", "Virtual Desktop Bounds. See log.", 2) _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_5 Func FuncTest_6() _Log('+ TEST 6: Convert coords example (local -> virtual -> back) --\') ; Convert coords example (local -> virtual -> back) _Monitor_GetList() Local $mon = _Monitor_GetCount() If $mon < 1 Then _Log("---> Example 6: No monitors detected") Else For $i = 1 To $mon Local $xLocal = 50, $yLocal = 100 Local $aV = _Monitor_ToVirtual($i, $xLocal, $yLocal) Local $aBack = _Monitor_FromVirtual($i, $aV[0], $aV[1]) _Log("---> Example 6: Mon " & $i & " local(" & $xLocal & "," & $yLocal & ") -> virtual(" & $aV[0] & "," & $aV[1] & ") -> back(" & $aBack[0] & "," & $aBack[1] & ")") Next MsgBox(64, "Example 6", "Converted. See log.", 2) EndIf _Log('- End --------------------------------------------------------/') EndFunc ;==>FuncTest_6 Func FuncTest_7() _Log('+ TEST 7: Show detailed info via MsgBox (calls UDF) ------\') ; Show detailed info via MsgBox (calls UDF) _Monitor_GetList() _Monitor_ShowInfo(2) _Log("---> Example 7: _Monitor_ShowInfo() called") _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_7 Func FuncTest_8() _Log('+ TEST 8: Start notepad, check visible ---------------\') ; Start notepad, check visible $pidNotepad = Run("notepad.exe") If Not WinWaitActive("[CLASS:Notepad]", "", 5) Then _Log("---> Example 8: Notepad did not start/focus") Else Sleep(1000) Local $h = WinGetHandle("[CLASS:Notepad]") Local $b = _Monitor_IsVisibleWindow($h) _Log("---> Example 8: Notepad handle " & $h & " visible? " & ($b ? "Yes" : "No")) MsgBox(64, "Example 8", "Notepad visible? " & ($b ? "Yes" : "No"), 2) EndIf _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_8 Func FuncTest_9() _Log('+ TEST 9: Create small GUI on each monitor -------------\') ; Create small GUI on each monitor _Monitor_GetList() ; close previously created For $i = 0 To UBound($g_createdGUIs) - 1 If IsHWnd($g_createdGUIs[$i]) Then GUIDelete($g_createdGUIs[$i]) Next ReDim $g_createdGUIs[1] ; reset Local $created = 0 For $i = 1 To _Monitor_GetCount() Local $a = _Monitor_GetInfo($i) Local $h = GUICreate("Monitor #" & $i & " - " & $a[10], 260, 120, $a[1] + 40, $a[2] + 40) GUICtrlCreateLabel("Monitor " & $i & ($a[9] ? " (Primary)" : ""), 10, 12, 240, 20) GUISetState(@SW_SHOW, $h) ; store to close later __ArrayAdd($g_createdGUIs, $h) $created += 1 Next _Log("---> Example 9: Created " & $created & " GUI(s) on monitors. Use Close to exit (they will be closed).") MsgBox(64, "Example 9", "Created " & $created & " GUIs (they will be closed when you close this launcher).", 2) _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_9 Func FuncTest_10() _Log('+ TEST 10: Move all visible windows to primary ----------\') ; Move all visible windows to primary _Monitor_GetList() Local $prim = _Monitor_GetPrimary() If $prim = 0 Then _Log("---> Example 10: Primary monitor not found") Else Local $aList = WinList() Local $moved = 0 For $i = 1 To $aList[0][0] If $aList[$i][0] <> "" Then Local $h = WinGetHandle($aList[$i][1]) If _Monitor_IsVisibleWindow($h) Then _Monitor_MoveWindowToScreen($h, "", $prim) $moved += 1 EndIf EndIf Next _Log("---> Example 10: Moved " & $moved & " visible windows to primary monitor #" & $prim) MsgBox(64, "Example 10", "Moved " & $moved & " visible windows to primary monitor #" & $prim, 2) EndIf _Log('- End ------------------------------------------------/') EndFunc ;==>FuncTest_10 ; ----------------------------- ; Small helper to push item into dynamic array (simple) ; ----------------------------- Func __ArrayAdd(ByRef $a, $v) Local $n = 0 If IsArray($a) Then $n = UBound($a) ReDim $a[$n + 1] $a[$n] = $v EndFunc ;==>__ArrayAdd
    1 point
  26. And we welcome back GUI GURU jaberwacky to the GUI front. Oct 27 2025 - Guiscape -- A new GUI builder project! by jaberwacky Added to the first post. Good to see him at it again.
    1 point
  27. Here is the project page where I originally found the version with x64 support: https://github.com/AutoItMicro/AutoItObject
    1 point
  28. I'd say that's more to do with the UWP popup class - so its probably not relevant to our win32 apps. TBH I wouldn't hold my breath given that full screen is explicitly not supported in xaml islands. But happy to be proven wrong though!
    1 point
  29. Ah apologies... so we've all stuffed up well here! - I haven't re-tested, but from looking at things... In the first one, we are: IMediaPlayerElement_GetIsFullWindow($pPlayer) But. $pPlayer is the mediaplayer object. not the mediaplayerelement object! So we think we're calling function #19 in the IMediaPlayerElement vtable. but we're actually calling function #19 in IMediaPlayer. which is IMediaPlayer::GetIsMuted My last demo I'm also using the wrong obj in both the getter and setter. Func _MediaPlayer_SetIsFullWindow($iMPIdx, $bState) If $iMPIdx < 1 Or $iMPIdx >= UBound($__g_apPlayers) Then Return False _WinRT_SwitchInterface($__g_apMPElements[$iMPIdx], $sIID_IMediaPlayerElement) If Not @error Then IMediaPlayerElement_SetIsFullWindow($__g_apPlayers[$iMPIdx], $bState) Return @error = $S_OK EndFunc $__g_apPlayers[$iMPIdx] should be $__g_apMPElements[$iMPIdx].
    1 point
  30. Local Const $CP_UTF8 = 65001 should solve that. For _IsPressed(), people can press F1 to find out what UDF is that in. Easy peasy lemon squeezy
    1 point
  31. You are 100% right, Sven. You made me realize that I haven’t paid any attention at all regarding compatibility between AutoIt versions. I really appreciate that you pointed that out because I never thought about it. I suppose the easiest way for me to test would be to run several versions side by side. I imagine I would need to have the previous version(s) as portable maybe and run by command lines. I’ll have to think about how to set this up. In the meantime, I will update the script later tonight and I will have to pay closer attention to this going forward. Thank you so much.
    1 point
  32. Hi and thank you a lot @WildByDesign for that great work 👌 . I started to have a look at your code and realized it's probably made for the current AutoIt version v3.3.18.0 and not for v3.3.16.1, am I right? I mean you already mentioned the absolute latest beta version of AutoIt3Wrapper.au3, but there are more incompatibilities between the AutoIt versions itself. _IsPressed() has changed from two to three args $CP_UTF8 is unknown in v3.3.16.1 If you simply say: "just update to the new AutoIt version", I am totally fine. But in case there shouldn't be such incompatibilities, this would be easily fixable I guess. Best regards Sven
    1 point
  33. oh no. Your scripts are good. He had a problem with his PC and did not bring clear information to troubleshoot and/or replicate his issue. I loaded Windows and everything as low spec as he has ( even lower CPU wise ) and gave it a try but unable to replicate his issue, added code that we all can share. If the environment variable "TimerInitScite" is there, then we ( the helpers ) can tell the user to: ConsoleWrite(@CRLF & TimerDiff(Int(EnvGet("TimerInitScite"))) & @CRLF & @CRLF) without having to touch the wrapper. Is an idea. If you decided that is not useful then is not. If you find that it don't hurt anything, then add it
    1 point
  34. Not at all! When I get back from work I'll look into this! Thank you! Glancing over it, this is a fffffaaaarrrrr more elegant way than I've done in the past.
    1 point
  35. TheSaint

    Kobo Cover Fixer

    Latest v2.4 update now available, see the first post. This involves several changes and improvements since my last (v1.9) update upload. I've held off while I've done more testing, and kept adding and changing things. That said, testing has been minimal with some elements, so no guarantees. A few new screenshots are included in applicable spoiler sections. Of particular interest for users, is an additional fairly comprehensive 'Instructions.txt' file, which should be very helpful and informative. [Tuesday 2nd September 2025] (v2.0) [Wednesday 8th October 2025] (v2.1) [Monday 27th October 2025] (v2.2) [Tuesday 28th October 2025] (v2.3) [Wednesday 29th October 2025] (v2.4)
    1 point
  36. Nice! When I replace the autoitobject I was using with this version then x64 works too!
    1 point
  37. me ? I don't have an account on German-language websites - I simply don't speak this language, although I'm ashamed to admit I also have German citizenship, but I don't know the language.
    1 point
  38. Yes, the optimization part definitely works. I can see several issues on their GitHub repo where they were going to finally implement a proper fullscreen mode but it seemed to have always gotten delayed, pushed off to another issue or cancelled. So I wont hold my breath on that one. But I am happy with the optimizations. This proved to be correct. I decided to patch my AutoIt binary and sure enough, the console messages are coming though. That is interesting. I guess that is a limitation of the registry (external manifest) method, unfortunately.
    1 point
  39. No. In first place just user should ask how to do some task he wanted. Best in your support topic. Then you/me or other user will be able to explain and show an example. Eventually in the end it can lead us to some kind of helper/wrapper function aka "lite" version, but this still should be based on the default UDF you already created. ps. sorry for the many edits - I feel bad today
    1 point
  40. Very pretty Just FYI, the AutoitObject startup function is crashing for me when it is run as x64. I'm sure I've used it before at some point - but it would've likely been with the physical dll?? Can't really remember sorry, Its been a while!
    1 point
  41. to be in sync with latest autoit release 3.3.18.0 and Au3Check I update the #include Cheers GUIScape.zip
    1 point
  42. Hi folks, here's a bit of a bonus. All the WinRT stuff is crammed into one include file, then there's the beginnings of another "UDF Layer" on top of that. Its all about simplifying things for people wanting to use this media player control in their projects. "Media player 4 all" type vibes . TBH I probably won't be taking this particular thing much further... It'll be the underlying WinRT class/interface libraries (in the folder structure) getting the development time sorry! So if anyone else wants run with this, feel free, and I'm happy to support if need be. I've used up all my attachment space here - so here's a sourceforge link! PS: its really just something that I threw together last night - so I'm sure there's plenty there to improve on!
    1 point
  43. Just curious to know if you used the important 2nd inner While...WEnd loop, to make sure _IsPressed() returns only 1 click, no matter the time you keep the left mouse button pressed : #include <Misc.au3> HotKeySet("{ESC}", Terminate) Local $iCount = 0, $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("01", $hDLL) Then ; left mouse button = "01" While _IsPressed("01", $hDLL) Sleep(10) WEnd $iCount += 1 ConsoleWrite("LMB pressed #" & $iCount & @CRLF) EndIf Sleep(10) WEnd Func Terminate() Exit EndFunc ;==>Terminate Maybe it helps and makes you change your opinion concerning _IsPressed() ... for your many scripts to come
    1 point
  44. Sorry I'm newbie In the forum So. .cursorrules it's specific file format Cursor uses as Main/system prompt it should be placed into project root You can define the AI model howto response. This is mine but you can edit it. Role You are an AutoIt Script Engineer (Windows automation, GUI apps, COM, WinAPI, file/window control, reliable tool-building). Action Understand the task and proactively clarify any gaps. Write AutoIt v3-compatible, robust, well-commented code (with UDFs where helpful). Build an event-driven GUI with status indicators and logging. Implement solid error handling (@error/@extended), return codes, and graceful cleanup. When needed: COM automation (Excel/Word), WinAPI calls, image-based detection (PixelSearch/ImageSearch UDF), window/process control. Provide self-tests per major function and basic timing/metrics. Include build/run instructions and config tips. Steps Requirements summary → inputs/outputs, target OS (Win10/11), permissions. Design → modules, UDFs (#include), GUI flow, logging strategy. Implementation → clear #Region/#EndRegion blocks, consistent naming ($g_s, $a, Func PascalCase). Error handling → guards, fallbacks, resource disposal. Tests → function self-tests, synthetic data, edge cases. Performance → tuned sleeps, correct WinWait/Control* usage. Documentation → README (run, params, known limits), changelog. Release → Aut2Exe build options, versioning, code-sign/AV false positive tips. Context Typical use-cases: desktop automation (form fill, buttons), stable GUI bots, Excel report generation, screen-based detection (icons, buttons, coordinates). Environment: Windows 10/11 x64, AutoIt v3 + SciTE; optional external UDFs (e.g., ImageSearch.au3; if unavailable, provide PixelSearch+tolerance alternative). Non-goal: brittle fixed-delay scripts; prefer state-driven and window-control-based logic. Examples GUI launcher: Start/Stop, log panel, tray icon; workflow: find window → control interaction → verify → log. Excel COM: open workbook, read ranges, export CSV, robust error handling and proper Quit(). Image locate & click: load templates from folder → tolerant search → click coordinates → verification step. WinAPI targeting: focusless ControlSend/ControlClick, class-based selection, DPI-aware settings. Format First: short Summary (goal, inputs/outputs). Then: a single .au3 code file, runnable, richly commented; sections: Config, Utils, GUI, Core, Tests, Main. Finally: README (install, run, troubleshooting, known limitations). Code display: canmore.create_doc (single file, copyable). Output language: English; variable/function names in English; logs may be mixed EN/HU if needed. Next step you should add the Autoit documentation for more robust code and less hallucination into settings Any time if you had any mistake and needs correction, just call in chat.
    1 point
  45. Yeah, it's still single threaded. While you have a msgbox up, Autoit doesn't just drop everything - the message pump and windowproc still needs to do its thing. It's the same reason why you can still minimize, and restore your gui etc... To demonstrate, this will properly lock things up! ConsoleWrite("sleep start" & @CRLF) DllCall("kernel32.dll", "none", "Sleep", "dword", 5000) ConsoleWrite("sleep end" & @CRLF)
    1 point
  46. Ahhhh, these are recently added to AutoIt? I should probably keep up with stuff like that. 😅
    1 point
  47. CODE: ; ============================================ ; Functions to check taskbar visibility and position ; ============================================ ; ------------------------------------------------------------ ; Function: _IsTaskbarVisible ; Purpose : Check whether the Windows taskbar is visible ; Return : True - Taskbar is visible ; False - Taskbar is hidden or not found ; Author : Dao Van Trong - TRONG.PRO ; Example : ; If _IsTaskbarVisible() Then MsgBox(0, "Status", "Visible") ; ------------------------------------------------------------ Func _IsTaskbarVisible() ; Get the handle to the taskbar Local $hTaskbar = WinGetHandle("[CLASS:Shell_TrayWnd]") If @error Then Return False ; Taskbar not found ; Get the position and size of the taskbar Local $aPos = WinGetPos($hTaskbar) If @error Then Return False ; Get the screen dimensions Local $iScreenWidth = @DesktopWidth Local $iScreenHeight = @DesktopHeight ; When the taskbar is hidden, its coordinates may be off-screen: ; Top taskbar: Y < 0 ; Left taskbar: X < 0 ; Right taskbar: X + Width > DesktopWidth ; Bottom taskbar: Y + Height > DesktopHeight ; Check if the taskbar is visible If $aPos[0] < 0 Or $aPos[1] < 0 Or _ $aPos[0] + $aPos[2] > $iScreenWidth Or _ $aPos[1] + $aPos[3] > $iScreenHeight Then Return False ; Taskbar is hidden Else Return True ; Taskbar is visible EndIf EndFunc ;==>_IsTaskbarVisible ; ------------------------------------------------------------ ; Function: _GetTaskbarPosition ; Purpose : Get the position of the Windows taskbar ; Return : SetError(0, code, "position") ; code: 1=top, 2=bottom, 3=left, 4=right ; SetError(3, 0, "unknown") if not determined ; Author : Dao Van Trong - TRONG.PRO ; Example : ; $pos = _GetTaskbarPosition() ; MsgBox(0, "Taskbar Position", $pos & " / code: " & @extended) ; ------------------------------------------------------------ Func _GetTaskbarPosition() Local $hTaskbar = WinGetHandle("[CLASS:Shell_TrayWnd]") If @error Then Return SetError(1, 0, "") ; Taskbar not found Local $aPos = WinGetPos($hTaskbar) If @error Then Return SetError(2, 0, "") ; Error getting taskbar position Local $iScreenWidth = @DesktopWidth Local $iScreenHeight = @DesktopHeight Local $tolerance = 5 ; Tolerance threshold in pixels ; Check top/bottom positions If Abs($aPos[0]) <= $tolerance And Abs($aPos[2] - $iScreenWidth) <= $tolerance Then If Abs($aPos[1]) <= $tolerance Then Return SetError(0, 1, "top") If Abs($aPos[1] + $aPos[3] - $iScreenHeight) <= $tolerance Then Return SetError(0, 2, "bottom") EndIf ; Check left/right positions If Abs($aPos[1]) <= $tolerance And Abs($aPos[3] - $iScreenHeight) <= $tolerance Then If Abs($aPos[0]) <= $tolerance Then Return SetError(0, 3, "left") If Abs($aPos[0] + $aPos[2] - $iScreenWidth) <= $tolerance Then Return SetError(0, 4, "right") EndIf ; If taskbar is hidden, infer its position from off-screen coordinates If Not _IsTaskbarVisible() Then If $aPos[1] < 0 Then Return SetError(0, 1, "top") If $aPos[0] < 0 Then Return SetError(0, 3, "left") If $aPos[1] + $aPos[3] - $iScreenHeight > $tolerance Then Return SetError(0, 2, "bottom") If $aPos[0] + $aPos[2] - $iScreenWidth > $tolerance Then Return SetError(0, 4, "right") EndIf Return SetError(3, 0, "unknown") ; Position could not be determined EndFunc ;==>_GetTaskbarPosition ;~ ; ------------------------------------------------------------ ;~ ; Example usage ;~ ; ------------------------------------------------------------ ;~ Local $sPos = _GetTaskbarPosition() ;~ Local $iCode = @extended ;~ If _IsTaskbarVisible() Then ;~ MsgBox(0, "Taskbar Status", _ ;~ "Taskbar is visible" & @CRLF & _ ;~ "Taskbar position: " & $sPos & @CRLF & _ ;~ "Position code : " & $iCode) ;~ Else ;~ MsgBox(0, "Taskbar Status", _ ;~ "Taskbar is hidden" & @CRLF & _ ;~ "Taskbar position: " & $sPos & @CRLF & _ ;~ "Position code : " & $iCode) ;~ EndIf EG: ; ------------------------------------------------------------ ; Example usage ; ------------------------------------------------------------ Local $sPos = _GetTaskbarPosition() Local $iCode = @extended If _IsTaskbarVisible() Then MsgBox(0, "Taskbar Status", _ "Taskbar is visible" & @CRLF & _ "Taskbar position: " & $sPos & @CRLF & _ "Position code : " & $iCode) Else MsgBox(0, "Taskbar Status", _ "Taskbar is hidden" & @CRLF & _ "Taskbar position: " & $sPos & @CRLF & _ "Position code : " & $iCode) EndIf
    1 point
  48. This is how to do it with the built-in UDF functions: #include <WinAPI.au3> #include <Misc.au3> Local $stPoint=DllStructCreate($tagPOINT),$aPos,$hControl,$hWin,$aLastPos[2]=[-1,-1],$sLastStr='',$sStr While Not _IsPressed('1B') $aPos=MouseGetPos() If $aPos[0]<>$aLastPos[0] Or $aPos[1]<>$aLastPos[1] Then DllStructSetData($stPoint,1,$aPos[0]) DllStructSetData($stPoint,2,$aPos[1]) $hControl=_WinAPI_WindowFromPoint($stPoint) $hWin=_WinAPI_GetAncestor($hControl,2) $sStr='Window at '&$aPos[0]&','&$aPos[1]&': "'&WinGetTitle($hWin)&'"' If $sLastStr<>$sStr Then ToolTip($sStr,0,@DesktopHeight-20) $sLastStr=$sStr EndIf $aLastPos=$aPos EndIf Sleep(15) WEnd On a side note - I'd just like to add that _WinAPI_WindowFromPoint() was poorly thought out - it should take x,y coordinates instead of a structure.
    1 point
  49. cheatera

    Proxy Changer

    RLY nicely done dude! /salute@you...
    1 point
×
×
  • Create New...