Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/20/2023 in all areas

  1. GuiFlatButton is a UDF to easily create regular buttons with different colors for background, foreground, border, hover, focus, etc.. This started as an effort to change the background color of a button and eventually grew into a full UDF. If you've looked around forums for changing button background colors, you have probably noticed that each proposed workaround has its own set of issues/side-effects. The answers usually circle back to 'use ownerdrawn buttons' and 'not worth it'. Well, now it is possible for anyone to easily create ownerdrawn buttons - totally worth it! Some issues with other workarounds such as drawing with GDI+ or using a colored label as a 'button': Not 'real' buttons so you lose built-in functionality that windows gives to buttons Messy / inefficient code in the main while loop to check for mouse position Slow to respond to click, paint, etc... Having to deal with GUIRegisterMsg messages Not straight-forward to implement GuiFlatButton is not a workaround; it is a technique to respond to Windows' built-in owner-drawn button events. With minimal effort, we can now create true simple colored buttons. The idea is to create an owner-drawn button using GUICtrlCreateButton then subclass the GUI and controls to handle the button-specific events to paint it however we want. This UDF magically does all of this for us! No need to worry about event handling or main while loop logic. How to use It couldn't be any easier! Simply create a new button using the familiar syntax. This creates an ownerdrawn button with default colors. $mybutton1 = GuiFlatButton_Create("Button 1", 78, 20, 120, 40) If you want to change the background and text colors: GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) Advanced Usage Set background/text/border all at once GuiFlatButton_SetColors(-1, 0x0000FF, 0xFFFFFF, 0x9999FF) Set ALL colors for ALL button states! (normal, focus, hover, selected) Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetColorsEx(-1, $aColorsEx) Set default colors to apply to any future buttons ;set colors GuiFlatButton_SetDefaultColors(0x0000FF, 0xFFFFFF, 0x9999FF) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Set ALL color defaults ;set colors Local $aColorsEx = [0x0000FF, 0xFFFFFF, -2, 0x4444FF, 0xFFFFFF, 0xAAAAFF, 0x6666FF, 0xFFFFFF, 0xCCCCFF, 0x0000EE, 0xFFFFFF, 0x7777EE] GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;create buttons $mybutton1 = GuiFlatButton_Create("Button 1", 12, 20, 120, 40) $mybutton2 = GuiFlatButton_Create("Button 2", 143, 20, 120, 40) Available Functions Simple Example #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;GUI with one button Func Example() Local $hGUI, $mybutton1 $hGUI = GUICreate("GuiFlatButton Ex0", 275, 120) GUISetBkColor(0x333333) Local $idLabel = GUICtrlCreateLabel("Click the button", 10, 100, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) ;create new button then set the background and foreground colors $mybutton1 = GuiFlatButton_Create("Button 1" & @CRLF & "Line 2", 78, 20, 120, 40, $BS_MULTILINE) GuiFlatButton_SetBkColor(-1, 0x5555FF) GuiFlatButton_SetColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $mybutton1 $i += 1 GUICtrlSetData($idLabel, $i) ConsoleWrite($i & @CRLF) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Menu/Toolbar Example #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "GuiFlatButton.au3" Example() ;Example GUI with toolbar Func Example() Local $hGUI, $idLabel, $aButtons, $iTbSize $hGUI = GUICreate("GuiFlatButton Ex2", 300, 200) GUISetBkColor(0x444444) $idLabel = GUICtrlCreateLabel("Click a button", 10, 180, 150, 30) GUICtrlSetColor(-1, 0xFFFFFF) $aButtons = createToolbar() $iTbSize = UBound($aButtons) GUISetState(@SW_SHOW, $hGUI) Local $i = 0 Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aButtons[0] To $aButtons[$iTbSize - 1] ConsoleWrite("1") GUICtrlSetData($idLabel, GuiFlatButton_Read($iMsg)) EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example Func createToolbar() Local $aButtons[6] Local $bkColor = 0x777777 Local $textColor = 0xFFFFFF Local $borderColor = 0x999999 Local $aBtnClrs[12] = [0x777777, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x888888, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x999999, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT, 0x666666, 0xFFFFFF, $GUI_BKCOLOR_TRANSPARENT] For $i = 0 To UBound($aButtons) - 1 $aButtons[$i] = GuiFlatButton_Create("B" & $i, $i * 50, 0, 50, 17) GuiFlatButton_SetColorsEx($aButtons[$i], $aBtnClrs) Next Return $aButtons EndFunc ;==>createToolbar Icon Example You can even easily add icons to your buttons -- just create a new button and send it an icon! #include <GDIPlus.au3> #include "GuiFlatButton.au3" Example() ;buttons with Icon images Func Example() ;get images for demonstration _GDIPlus_Startup() ;initialize GDI+ Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 258, 24, 24) ;extract the 'Save' icon Local $hBitmap = _GDIPlus_BitmapCreateFromHICON($hIcon) ;Create Bitmap from Icon (for demonstration) Local $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;Create HBitmap from Bitmap _GDIPlus_BitmapDispose($hBitmap) ;dispose the bitmap _GDIPlus_Shutdown() ;done with GDI+ Local $hGUI = GUICreate("GuiFlatButton Ex5", 255, 400) GUISetBkColor(0xEEEEEE) ;set default colors of future buttons Local $aColorsEx = _ [0xE2E5E8, 0X000000, 0x888888, _ ; normal : Background, Text, Border 0xE2E5E8, 0X000000, 0x333333, _ ; focus : Background, Text, Border 0xE8E8E8, 0X000000, 0x666666, _ ; hover : Background, Text, Border 0xDDDDDD, 0X000000, 0xAAAAAA] ; selected : Background, Text, Border GuiFlatButton_SetDefaultColorsEx($aColorsEx) ;normal button with icon $label1 = GUICtrlCreateLabel( "$BS_TOOLBUTTON -->", 5, 10) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) Local $mybutton1 = GuiFlatButton_Create("Save", 130, 5, 50, 48, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybutton1), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top Local $mybuttonT = GuiFlatButton_Create("Top", 5, 65, 120, 55, $BS_TOP) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonT), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-left Local $mybuttonTL = GuiFlatButton_Create("Top-Left", 5, 125, 120, 55, BITOR($BS_TOP, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align top-right Local $mybuttonTR = GuiFlatButton_Create("Top-Right", 5, 185, 120, 55, BITOR($BS_TOP, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonTR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align left Local $mybuttonL = GuiFlatButton_Create("Left", 5, 245, 120, 55, $BS_LEFT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom Local $mybuttonB = GuiFlatButton_Create("Bottom", 130, 65, 120, 55, $BS_BOTTOM) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonB), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-left Local $mybuttonBL = GuiFlatButton_Create("Bottom-Left", 130, 125, 120, 55, BITOR($BS_BOTTOM, $BS_LEFT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBL), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align bottom-right Local $mybuttonBR = GuiFlatButton_Create("Bottom-Right", 130, 185, 120, 55, BITOR($BS_BOTTOM, $BS_RIGHT)) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonBR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) ;align right Local $mybuttonR = GuiFlatButton_Create("Right", 130, 245, 120, 55, $BS_RIGHT) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonR), $BM_SETIMAGE, $IMAGE_ICON, $hIcon)) GuiFlatButton_SetState($mybuttonR, $GUI_DISABLE ) ;disabled Local $mybuttonDisable = GuiFlatButton_Create("Disabled", 130, 310, 120, 55, $BS_TOOLBUTTON) _WinAPI_DeleteObject(_SendMessage(GUICtrlGetHandle($mybuttonDisable), $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) GuiFlatButton_SetState($mybuttonDisable, $GUI_DISABLE ) ;clean up! _WinAPI_DestroyIcon( $hIcon ) _WinAPI_DeleteObject( $hHBitmap ) GUISetState(@SW_SHOW, $hGUI) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Sleep(10) WEnd GUIDelete() EndFunc ;==>Example I'm sure there are some use-cases I've forgotten, so feedback is welcome! Download the latest UDF and several more examples: GuiFlatButton_20220919.zip (1,121) Update 2022-09-19 Added update from 05/25 back in after it was accidentally removed Update 2022-09-01 Added $BS_MULTILINE button style Added ellipses when text is longer than the button Fixed compatibility with Opt("MustDeclareVars", 1) Update 2022-05-25 Fixed issue, buttons disappear when a GUI containing a child window with WS_EX_MDICHILD extended style is moved Update 2022-05-24 Fixed issue releasing subclassing when GUI is deleted but program is not closed Fixed occasional white background flicker Added function GuiFlatButton_GetPos Update 2021-01-02 Fixed bug, not drawing correctly after deleting GUI with GUIDelete() Fixed bug, changing default colors changed all buttons, even previously created buttons Made some internal functions more efficient Update 2019-04-14 Fixed bug, not showing pressed down state when clicking rapidly Added Icon/Bitmap support! Added function GuiFlatButton_SetPos to change the position and/or size of a button Update 2019-02-09 Added 2 new functions to set the button colors globally for all future buttons. GuiFlatButton_SetDefaultColors GuiFlatButton_SetDefaultColorsEx Credits to: Melba23 (UDF template) LarsJ (general subclassing code) 4ggr35510n (TrackMouseEvent example) binhnx (disable dragging with $WS_EX_CONTROLPARENT) GUIRegisterMsg in AutoIt Help (owner-draw button example) funkey (_WinAPI_DrawState example)
    1 point
  2. No. Because if the data it's loaded dynamically it's not actually in the DOM yet. You need to IE UDF or Webdriver or whatever you want to make the server to get your data in the DOM.
    1 point
  3. after some time of use, I added some more functions, and converted it to udf, for simpler use e.g.: _MM_WinMoveOn($hWin, 10, 10, 600, 300, -1, "\\.\DISPLAY2", False) moves the specify win to position 10, 10, 600, 300 on monitor2 MultiMonitors.au3 Moves and arranges with relative coords to the active monitor ; #FUNCTION# ========================================================================================================= ; ==================================================================================================================== MultiMonitors.au3 #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #AutoIt3Wrapper_UseX64=n ; *<- DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; -4=PerMonitorAwareV2 #include-once ; #INDEX# ============================================================================================================ ; Title .........: MultiMonitors.au3 ; AutoIt Version : v3.3.16.1 or higher ; Language ......: English ; Description ...: Moves and arranges with relative coords to the active monitor ; Remarks .......: ; Note ..........: My first UDF :) Tested on Windows 10 Version 22H2 ; Author(s) .....: ioa747 ; Link...........: https://www.autoitscript.com/forum/topic/210826-moves-andor-resizes-and-arrange-windows-between-multi-monitors/ ; ==================================================================================================================== ; #INCLUDES# ========================================================================================================= #include <Array.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> ; #GLOBAL VARIABLES# ================================================================================================= ; ==================================================================================================================== ; Initialization DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; -4=PerMonitorAwareV2 ; #CURRENT# ========================================================================================================== ; _MM_WinBySide: Moves and/or resizes and arrange windows between multi monitors. ; _MM_WinMoveOn: Moves and/or resizes a window between multi monitors. ; _MM_MouseMoveOn: Moves the mouse pointer between multi monitors. ; _MM_ToolTipOn : Creates a tooltip anywhere on multi monitors ; _MM_GetPointPos: Translate the X, Y point, to given monitor X, Y. ; _MM_GetMonitorsArray: Return a 2D array containing the monitors informations ; ==================================================================================================================== ; #FUNCTION# ========================================================================================================= ; Name...........: _MM_WinBySide ; Description ...: Moves and/or resizes and arrange windows between multi monitors. ; Syntax.........: _MM_WinBySide ( $hWin1 [, $hWin2 = 0 [, $iView1 = 65 [, $sDevice = "Primary"]]]) ; Parameters ....: $hWin1 - The title/hWnd/class of the window1, ; $hWin2 - [optional] The title/hWnd/class of the window2. ; $iView1 - [optional] Percentage of the current @DesktopWidth, for window1. Negative value start from the right side ; $sDevice - [optional] The name of the device to move to, e.g. \\.\DISPLAY1 , \\.\DISPLAY2 , "Primary" is the primary monitor ; Return value...: None ; Author ........: ioa747 ; Notes .........: If $hWin2 = 0 then will be ignored, and act only to window1 ; ==================================================================================================================== Func _MM_WinBySide($hWin1, $hWin2 = 0, $iView1 = 65, $sDevice = "Primary") Local Enum $hM, $RX, $RY, $RW, $RH, $Dv, $Pr, $WX, $WY, $WW, $WH, $Sc Local $Cur Local $aMon = _MM_GetMonitorsArray() If IsArray($aMon) Then For $i = 1 To $aMon[0][0] If $sDevice = "Primary" Then If $aMon[$i][$Pr] = 1 Then $Cur = $i Else If $aMon[$i][$Dv] = $sDevice Then $Cur = $i EndIf Next Else Return SetError(1, @extended, 0) EndIf If Not $Cur Then Return SetError(2, @extended, 0) EndIf Local $iScale, $iwX, $iwY, $iwW, $iwH, $awPos $iScale = ($aMon[$Cur][$RW] / 100) ; = 1% ; Win1 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: If $iView1 > 0 Then $iwX = $aMon[$Cur][$WX] - (7 * $aMon[$Cur][$Sc]) $iwY = $aMon[$Cur][$WY] $iwW = ($iScale * $iView1) + (14 * $aMon[$Cur][$Sc]) $iwH = $aMon[$Cur][$WH] + (7 * $aMon[$Cur][$Sc]) Else $iwX = ($aMon[$Cur][$WW] - ($iScale * Abs($iView1))) - (7 * $aMon[$Cur][$Sc]) $iwY = $aMon[$Cur][$WY] $iwW = ($iScale * Abs($iView1)) + (14 * $aMon[$Cur][$Sc]) $iwH = $aMon[$Cur][$WH] + (7 * $aMon[$Cur][$Sc]) EndIf WinMove($hWin1, "", $iwX, $iwY, $iwW, $iwH) Sleep(200) $awPos = WinGetPos($hWin1) If $iwW <> $awPos[2] Then WinMove($hWin1, "", $iwX, $iwY, $iwW, $iwH) Sleep(200) $awPos = WinGetPos($hWin1) EndIf ; Win2 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: If $hWin2 Then If $iView1 > 0 Then $iwX = $aMon[$Cur][$WX] + ($iScale * $iView1) - (7 * $aMon[$Cur][$Sc]) $iwY = $aMon[$Cur][$WY] $iwW = $aMon[$Cur][$RW] + (14 * $aMon[$Cur][$Sc]) - ($iScale * $iView1) $iwH = $aMon[$Cur][$WH] + (7 * $aMon[$Cur][$Sc]) Else $iwX = $aMon[$Cur][$WX] - (7 * $aMon[$Cur][$Sc]) $iwY = $aMon[$Cur][$WY] $iwW = $aMon[$Cur][$RW] + (14 * $aMon[$Cur][$Sc]) - ($iScale * Abs($iView1)) $iwH = $aMon[$Cur][$WH] + (7 * $aMon[$Cur][$Sc]) EndIf WinMove($hWin2, "", $iwX, $iwY, $iwW, $iwH) Sleep(200) $awPos = WinGetPos($hWin2) If $iwW <> $awPos[2] Then WinMove($hWin2, "", $iwX, $iwY, $iwW, $iwH) Sleep(200) $awPos = WinGetPos($hWin2) EndIf EndIf ;give focus to $hWin2 WinActivate($hWin2) ;give focus to $hWin1 WinActivate($hWin1) EndFunc ;==>_MM_WinBySide ; #FUNCTION# ========================================================================================================= ; Name...........: _MM_WinMoveOn ; Description ...: Moves and/or resizes a window between multi monitors. ; Syntax.........: _MM_WinMoveOn ( $hWin, $iX, $iY, [$iWidth = Default [, $iHeigh = Default [, $iSpeed = -1 [, $sDevice = "Primary" [, $Scale = False]]]]] ) ; Parameters ....: $hWin - The title/hWnd/class of the window to move/resize. ; $iX - X coordinate to move to. ; $iY - Y coordinate to move to. ; $iWidth - [optional] New width of the window ; $iHeigh - [optional] New height of the window. ; $iSpeed - [optional] The speed to move the windows in the range 1 (fastest) to 100 (slowest). If not defined the move is instantaneous ; $sDevice - [optional] The name of the device to move to, e.g. \\.\DISPLAY1 , \\.\DISPLAY2 , "Primary" is the primary monitor ; $Scale - [optional] True/False. If True the dimensions will be multiplied with the scale factor ; Return value...: Success: a handle to the window. Failure: 0 if the window is not found. ; Author ........: ioa747 ; Notes .........: In $iX, $iY, $iWidth, $iHeigh parameters can use string expression with the variable $DtW = current @DesktopWidth , $DtH = current @DesktopHeight ; ==================================================================================================================== Func _MM_WinMoveOn($hWin, $iX, $iY, $iWidth = Default, $iHeigh = Default, $iSpeed = -1, $sDevice = "Primary", $Scale = False) Local Enum $hM, $RX, $RY, $RW, $RH, $Dv, $Pr, $WX, $WY, $WW, $WH, $Sc Local $Cur, $iScale, $iwX, $iwY, $iwW, $iwH, $awPos, $DtW, $DtH Local $aMon = _MM_GetMonitorsArray() If IsArray($aMon) Then For $i = 1 To $aMon[0][0] If $sDevice = "Primary" Then If $aMon[$i][$Pr] = 1 Then $Cur = $i Else If $aMon[$i][$Dv] = $sDevice Then $Cur = $i EndIf Next Else Return SetError(1, @extended, 0) EndIf If Not $Cur Then Return SetError(2, @extended, 0) EndIf $DtW = $aMon[$Cur][$RW] $DtH = $aMon[$Cur][$RH] If $Scale = False Then $iScale = 1 Else $iScale = $aMon[$Cur][$Sc] EndIf ; Win1 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: If WinExists($hWin) Then $awPos = WinGetPos($hWin) If VarGetType($iX) = "String" Then $iwX = $aMon[$Cur][$WX] + (Execute($iX) * $iScale) - (7 * $aMon[$Cur][$Sc]) Else $iwX = $aMon[$Cur][$WX] + ($iX * $iScale) - (7 * $aMon[$Cur][$Sc]) EndIf If VarGetType($iY) = "String" Then $iwY = $aMon[$Cur][$WY] + (Execute($iY) * $iScale) Else $iwY = $aMon[$Cur][$WY] + ($iY * $iScale) EndIf If $iWidth = Default Then $iwW = $awPos[2] * $iScale Else If VarGetType($iWidth) = "String" Then $iwW = (Execute($iWidth) * $iScale) + (14 * $aMon[$Cur][$Sc]) Else $iwW = ($iWidth * $iScale) + (14 * $aMon[$Cur][$Sc]) EndIf EndIf If $iHeigh = Default Then $iwH = $awPos[3] * $iScale Else If VarGetType($iHeigh) = "String" Then $iwH = (Execute($iHeigh) * $iScale) + (7 * $aMon[$Cur][$Sc]) Else $iwH = ($iHeigh * $iScale) + (7 * $aMon[$Cur][$Sc]) EndIf EndIf WinMove($hWin, "", $iwX, $iwY, $iwW, $iwH, $iSpeed) Sleep(200) $awPos = WinGetPos($hWin) If $iwW <> $awPos[2] Then WinMove($hWin, "", $iwX, $iwY, $iwW, $iwH) Sleep(200) $awPos = WinGetPos($hWin) EndIf ;give focus to $hWin WinActivate($hWin) Return $hWin Else Return SetError(3, @extended, 0) EndIf EndFunc ;==>_MM_WinMoveOn ; #FUNCTION# ========================================================================================================= ; Name...........: _MM_MouseMoveOn ; Description ...: Moves the mouse pointer between multi monitors. ; Syntax.........: _MM_MouseMoveOn ( $iX, $iY [, $iSpeed = 10 [, $sDevice = "Primary" [, $Scale = False]]] ) ; Parameters ....: $iX - X coordinate to move to. ; $iY - Y coordinate to move to. ; $iSpeed - [optional] The speed to move the windows in the range 0 (fastest) to 100 (slowest). ; $sDevice - [optional] The name of the device to move to, e.g. \\.\DISPLAY1 , \\.\DISPLAY2 , "Primary" is the primary monitor ; $Scale - [optional] True/False. If True the dimensions will be multiplied with the scale factor ; Return value...: None ; Author ........: ioa747 ; Notes .........: In $iX, $iY parameters can use string expression with the variable $DtW = current @DesktopWidth , $DtH = current @DesktopHeight ; ==================================================================================================================== Func _MM_MouseMoveOn($iX, $iY, $iSpeed = 10, $sDevice = "Primary", $Scale = False) Local Enum $hM, $RX, $RY, $RW, $RH, $Dv, $Pr, $WX, $WY, $WW, $WH, $Sc Local $Cur Local $aMon = _MM_GetMonitorsArray() If IsArray($aMon) Then For $i = 1 To $aMon[0][0] If $sDevice = "Primary" Then If $aMon[$i][$Pr] = 1 Then $Cur = $i Else If $aMon[$i][$Dv] = $sDevice Then $Cur = $i EndIf Next Else Return SetError(1, @extended, 0) EndIf If Not $Cur Then Return SetError(2, @extended, 0) EndIf Local $iScale, $iwX, $iwY, $amPos, $DtW, $DtH $DtW = $aMon[$Cur][$RW] $DtH = $aMon[$Cur][$RH] If $Scale = False Then $iScale = 1 Else $iScale = $aMon[$Cur][$Sc] EndIf $amPos = MouseGetPos() If VarGetType($iX) = "String" Then $iwX = $aMon[$Cur][$WX] + (Execute($iX) * $iScale) Else $iwX = $aMon[$Cur][$WX] + ($iX * $iScale) EndIf If VarGetType($iY) = "String" Then $iwY = $aMon[$Cur][$WY] + (Execute($iY) * $iScale) Else $iwY = $aMon[$Cur][$WY] + ($iY * $iScale) EndIf MouseMove($iwX, $iwY, $iSpeed) Sleep(200) $amPos = MouseGetPos() If $iwX <> $amPos[0] Then MouseMove($iwX, $iwY, $iSpeed) Sleep(200) $amPos = MouseGetPos() EndIf EndFunc ;==>_MM_MouseMoveOn ; #FUNCTION# ========================================================================================================= ; Name...........: _MM_ToolTipOn ; Description ...: Creates a tooltip anywhere on multi monitors ; Syntax.........: _MM_ToolTipOn($sText [, $iX = Default [, $iY = Default [, $sTitle = Default [, $iIcon = Default [, $iOptions = Default [, $sDevice = "Primary" [, $Scale = False]]]]]]]) ; Parameters ....: $sText The text of the tooltip. (An empty string clears a displaying tooltip) ; $iX - [optional] The x position of the tooltip. ; $iY - [optional] The y position of the tooltip. ; $sTitle - [optional] The title for the tooltip. ; $iIcon - [optional] Pre-defined icon to show next to the title: Requires a title. 0=NoIcon, 1=InfoIcon, 2=WarningIcon, 3=ErrorIcon ; $iOptions - [optional] Sets different options for how the tooltip will be displayed (Can be added together): ; 1=Display As BalloonTip 2= Center The Tip At The X,Y Coord 4=Force the tooltip to always be visible confining it to monitor borders if necessary. ; If multiple monitors are used, then the tooltip will "snap-to" the nearest monitor. ; $sDevice - [optional] The name of the device to move to, e.g. \\.\DISPLAY1 , \\.\DISPLAY2 , "Primary" is the primary monitor ; $Scale - [optional] True/False. If True the dimensions will be multiplied with the scale factor ; Return value...: None ; Author ........: ioa747 ; Notes .........: In $iX, $iY parameters can use string expression with the variable $DtW = current @DesktopWidth , $DtH = current @DesktopHeight ; ==================================================================================================================== Func _MM_ToolTipOn($sText, $iX = Default, $iY = Default, $sTitle = Default, $iIcon = Default, $iOptions = Default, $sDevice = "Primary", $Scale = False) ;~ ToolTip ( "text" [, x [, y [, "title" [, icon = 0 [, options]]]]] ) Local Enum $hM, $RX, $RY, $RW, $RH, $Dv, $Pr, $WX, $WY, $WW, $WH, $Sc Local $Cur Local $aMon = _MM_GetMonitorsArray() If IsArray($aMon) Then For $i = 1 To $aMon[0][0] If $sDevice = "Primary" Then If $aMon[$i][$Pr] = 1 Then $Cur = $i Else If $aMon[$i][$Dv] = $sDevice Then $Cur = $i EndIf Next Else Return SetError(1, @extended, 0) EndIf If Not $Cur Then Return SetError(2, @extended, 0) EndIf Local $iScale, $iwX, $iwY, $DtW, $DtH $DtW = $aMon[$Cur][$RW] $DtH = $aMon[$Cur][$RH] If $Scale = False Then $iScale = 1 Else $iScale = $aMon[$Cur][$Sc] EndIf If VarGetType($iX) = "String" Then $iwX = $aMon[$Cur][$WX] + (Execute($iX) * $iScale) Else $iwX = $aMon[$Cur][$WX] + ($iX * $iScale) EndIf If VarGetType($iY) = "String" Then $iwY = $aMon[$Cur][$WY] + (Execute($iY) * $iScale) Else $iwY = $aMon[$Cur][$WY] + ($iY * $iScale) EndIf ToolTip($sText, $iwX, $iwY, $sTitle, $iIcon, $iOptions) EndFunc ;==>_MM_ToolTipOn ; #FUNCTION# ========================================================================================================= ; Name...........: _MM_GetPointPos ; Description ...: Translate the X, Y point, to given monitor X, Y. ; Syntax.........: _MM_GetPointPos ( $iX, $iY [, $sDevice = "Primary" [, $Scale = False]] ) ; Parameters ....: $iX - X coordinate to Translate. ; $iY - Y coordinate to Translate. ; $sDevice - [optional] The name of the device to move to, e.g. \\.\DISPLAY1 , \\.\DISPLAY2 , "Primary" is the primary monitor ; $Scale - [optional] True/False. If True the dimensions will be multiplied with the scale factor ; Return value...: a two-element array containing the X, Y coordinates: $aArray[0] = X coord (horizontal), $aArray[1] = Y coord (vertical) ; Author ........: ioa747 ; Notes .........: In $iX, $iY parameters can use string expression with the variable $DtW = current @DesktopWidth , $DtH = current @DesktopHeight ; ==================================================================================================================== Func _MM_GetPointPos($iX, $iY, $sDevice = "Primary", $Scale = False) Local Enum $hM, $RX, $RY, $RW, $RH, $Dv, $Pr, $WX, $WY, $WW, $WH, $Sc Local $Cur Local $aMon = _MM_GetMonitorsArray() If IsArray($aMon) Then For $i = 1 To $aMon[0][0] If $sDevice = "Primary" Then If $aMon[$i][$Pr] = 1 Then $Cur = $i Else If $aMon[$i][$Dv] = $sDevice Then $Cur = $i EndIf Next Else Return SetError(1, @extended, 0) EndIf If Not $Cur Then Return SetError(2, @extended, 0) EndIf Local $iScale, $iwX, $iwY, $apPos[2], $DtW, $DtH $DtW = $aMon[$Cur][$RW] $DtH = $aMon[$Cur][$RH] If $Scale = False Then $iScale = 1 Else $iScale = $aMon[$Cur][$Sc] EndIf If VarGetType($iX) = "String" Then $iwX = $aMon[$Cur][$WX] + (Execute($iX) * $iScale) Else $iwX = $aMon[$Cur][$WX] + ($iX * $iScale) EndIf If VarGetType($iY) = "String" Then $iwY = $aMon[$Cur][$WY] + (Execute($iY) * $iScale) Else $iwY = $aMon[$Cur][$WY] + ($iY * $iScale) EndIf $apPos[0] = $iwX $apPos[1] = $iwY Return $apPos EndFunc ;==>_MM_GetPointPos ; #FUNCTION# ========================================================================================================= ; Name...........: _MM_GetMonitorsArray ; Description ...: Return a 2D array containing the monitors informations ; Syntax ........: _MM_GetMonitorsArray() ; Parameters ....: None ; Return values .: Return a 2D array containing the monitors informations ; Author ........: ioa747 ; Modified.......: ; Remarks .......: Help if use Local Enum $hM, $RX, $RY, $RW, $RH, $Dv, $Pr, $WX, $WY, $WW, $WH, $Sc ; 0=hM, 1=RX, 2=RY, 3=RW, 4=RH, 5=Dv, 6=Pr, 7=WX, 8=WY, 9=WW, 10=WH, 11=Sc ; ==================================================================================================================== Func _MM_GetMonitorsArray() ;0=hM, 1=RX, 2=RY, 3=RW, 4=RH, 5=Dv, 6=Pr, 7=WX, 8=WY, 9=WW, 10=WH, 11=Sc ;Local Enum $hM, $RX, $RY, $RW, $RH, $Dv, $Pr, $WX, $WY, $WW, $WH, $Sc Local $aPos, $aMonitorInfo, $aData = _WinAPI_EnumDisplayMonitors() If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][12] For $i = 1 To $aData[0][0] $aPos = _WinAPI_GetPosFromRect($aData[$i][1]) For $j = 0 To 3 $aData[$i][$j + 1] = $aPos[$j] Next $aMonitorInfo = _WinAPI_GetMonitorInfo($aData[$i][0]) $aData[$i][5] = $aMonitorInfo[3] ;Device name $aData[$i][6] = $aMonitorInfo[2] ;Primary $aData[$i][7] = DllStructGetData($aMonitorInfo[1], 1) ;wx $aData[$i][8] = DllStructGetData($aMonitorInfo[1], 2) ;wy $aData[$i][9] = DllStructGetData($aMonitorInfo[1], 3) ;ww $aData[$i][10] = DllStructGetData($aMonitorInfo[1], 4) ;wh $aData[$i][11] = _WinAPI_EnumDisplaySettings($aMonitorInfo[3], $ENUM_CURRENT_SETTINGS)[0] / @DesktopWidth Next EndIf ;_ArrayDisplay($aData, "", "", 0, Default, "0=hM|1=RX|2=RY|3=RW|4=RH|5=Dv|6=Pr|7=WX|8=WY|9=WW|10=WH|11=Sc") Return $aData EndFunc ;==>_MM_GetMonitorsArray Tested on Windows 10 Version 22H2 main setting Here I should emphasize, in my example I use \\.\DISPLAY1 as primary and \\.\DISPLAY2 as extended monitor on your system this may not work and need to be adjusted Example.au3 ; https://www.autoitscript.com/forum/topic/210826-moves-andor-resizes-and-arrange-windows-between-multi-monitors ;---------------------------------------------------------------------------------------- ; Title...........: Example.au3 ; Description.....: Example for UDF "MultiMonitors.au3" ; AutoIt Version..: 3.3.16.1 Author: ioa747 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 6 -w 7 #include "MultiMonitors.au3" #include <Misc.au3> Global $hDLL = DllOpen("user32.dll") ; for the _IsPressed ; first make 2 Test File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Global $sFile_1 = @ScriptDir & '\MoveOnMultiMonitors_Test_1.txt' Global $sFile_2 = @ScriptDir & '\MoveOnMultiMonitors_Test_2.txt' If Not FileExists($sFile_1) Then FileWriteLine($sFile_1, "Win_1") If Not FileExists($sFile_2) Then FileWriteLine($sFile_2, "Win_2") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _Example_WinBySide() ; _MM_WinBySide: Moves and/or resizes and arrange windows between multi monitors. _Example_WinMoveOn() ; _MM_WinMoveOn: Moves and/or resizes a window between multi monitors. _Example() ; _MM_GetPointPos & _MM_GetPointPos ; Delete the 2 Test File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If FileExists($sFile_1) Then FileDelete($sFile_1) If FileExists($sFile_2) Then FileDelete($sFile_2) DllClose($hDLL) Exit ;---------------------------------------------------------------------------------------- Func _Example_WinBySide() ; _MM_WinBySide: Moves and/or resizes and arrange windows between multi monitors. Local $Tip, $Title Local $Sign = @CRLF & @CRLF & "press {CTRL} to continue to the next - press {ESC} to Exit" $Tip = "Start " $Title = "Moves and/or resizes and arrange windows between multi monitors" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _Wait(2) Local $hWin_1 = WinWait("MoveOnMultiMonitors_Test_1.txt - Notepad", "", 1) If Not WinExists($hWin_1) Then ShellExecute("notepad.exe", $sFile_1) $hWin_1 = WinWait("MoveOnMultiMonitors_Test_1.txt - Notepad") ConsoleWrite("- $hWin_1=" & $hWin_1 & @CRLF) Local $hWin_2 = WinWait("MoveOnMultiMonitors_Test_2.txt - Notepad", "", 1) If Not WinExists($hWin_2) Then ShellExecute("notepad.exe", $sFile_2) $hWin_2 = WinWait("MoveOnMultiMonitors_Test_2.txt - Notepad") ConsoleWrite("- $hWin_2=" & $hWin_2 & @CRLF) ; 1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " Win_1 30% on the left side on Primary monitor" $Title = "1) _MM_WinBySide()" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _MM_WinBySide($hWin_1, $hWin_2, 30) _Wait() ; 2) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " Win_1 70% on the left side on DISPLAY2" $Title = "2) _MM_WinBySide()" & $Sign _MM_ToolTipOn($Title, "($DtW / 2)", "($DtH / 2)", $Tip, 1, Default, "\\.\DISPLAY2") _MM_WinBySide($hWin_1, $hWin_2, 70, "\\.\DISPLAY2") _Wait() ; 3) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " Win_1 70% on the right side on Primary monitor" $Title = "3) _MM_WinBySide()" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _MM_WinBySide($hWin_1, $hWin_2, -70) _Wait() WinClose($hWin_2) ; now we have 1 windows to handle $hWin_1 ~~~~~~~~~~ ; 4) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " Win_1 alone 70% on the left side on Primary monitor" $Title = "4) _MM_WinBySide() - Win_1 alone" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _MM_WinBySide($hWin_1, 0, 70) _Wait() ; 5) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " Win_1 alone 70% on the right side on Primary monitor" $Title = "5) _MM_WinBySide() - Win_1 alone" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _MM_WinBySide($hWin_1, 0, -70) _Wait() WinClose($hWin_1) EndFunc ;==>_Example_WinBySide ;---------------------------------------------------------------------------------------- Func _Example_WinMoveOn() ; _MM_WinMoveOn: Moves and/or resizes a window between multi monitors. Local $Tip, $Title Local $Sign = @CRLF & @CRLF & "press {CTRL} to continue to the next - press {ESC} to Exit" $Tip = "Start " $Title = "Moves and/or resizes a window between multi monitors." & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _Wait(2) Local $hWin_1 = WinWait("MoveOnMultiMonitors_Test_1.txt - Notepad", "", 1) If Not WinExists($hWin_1) Then ShellExecute("notepad.exe", $sFile_1) $hWin_1 = WinWait("MoveOnMultiMonitors_Test_1.txt - Notepad") ConsoleWrite("- $hWin_1=" & $hWin_1 & @CRLF) ; 1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " ($hWin_1, 0, 0, 600, 300, -1, '\\.\DISPLAY1')" $Title = "1) _MM_WinMoveOn" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _MM_WinMoveOn($hWin_1, 0, 0, 600, 300, -1, "\\.\DISPLAY1") _Wait() ; 2) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " ($hWin_1, 0, 300, Default, Default, -1, '\\.\DISPLAY1')" $Title = "2) _MM_WinMoveOn" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _MM_WinMoveOn($hWin_1, 0, 300, Default, Default, -1, "\\.\DISPLAY1") _Wait() ; 3) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " ($hWin_1, 0, 0, 600, 300, -1, '\\.\DISPLAY2', False)" $Title = "3) _MM_WinMoveOn" & $Sign _MM_ToolTipOn($Title, "($DtW / 2)", "($DtH / 2)", $Tip, 1, Default, "\\.\DISPLAY2") _MM_WinMoveOn($hWin_1, 0, 0, 600, 300, -1, "\\.\DISPLAY2", False) _Wait() ; 4) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = " ($hWin_1, 0, 0, 600, 300, -1, '\\.\DISPLAY2', True)" $Title = "4) _MM_WinMoveOn" & $Sign _MM_ToolTipOn($Title, "($DtW / 2)", "($DtH / 2)", $Tip, 1, Default, "\\.\DISPLAY2") _MM_WinMoveOn($hWin_1, 0, 0, 600, 300, -1, "\\.\DISPLAY2", True) _Wait() ; now we have 1 windows to handle with Special parameters ~~~~~~~~~~~ ; In $iX, $iY, $iWidth, $iHeigh parameters can use string expression with the variable $DtW = current @DesktopWidth , $DtH = current @DesktopHeight ; 5) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = '($hWin_1, "($DtW / 2) - 300", "($DtH / 2) - 150", 600, 300)' $Title = "5) _MM_WinMoveOn() - Special parameters" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _MM_WinMoveOn($hWin_1, "($DtW / 2) - 300", "($DtH / 2) - 150", 600, 300) _Wait() ; 6) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = '($hWin_1, "($DtW/2) - ($DtW/4)", "($DtH/2) - ($DtH/4)", "($DtW/2)", "($DtH/2)", -1, "\\.\DISPLAY2")' $Title = "6) _MM_WinMoveOn() - Special parameters" & $Sign _MM_ToolTipOn($Title, "($DtW / 2)", "($DtH / 2)", $Tip, 1, Default, "\\.\DISPLAY2") _MM_WinMoveOn($hWin_1, "($DtW / 2) - ($DtW / 4)", "($DtH / 2) - ($DtH / 4)", "($DtW / 2)", "($DtH / 2)", -1, "\\.\DISPLAY2") _Wait() ; 7) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = '($hWin_1, "$DtW / 3", "$DtH / 5", "$DtW / 2", "$DtH / 2")' $Title = "7) _MM_WinMoveOn() - Special parameters" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1) _MM_WinMoveOn($hWin_1, "$DtW / 3", "$DtH / 5", "$DtW / 2", "$DtH / 2") _Wait() ToolTip("") WinClose($hWin_1) EndFunc ;==>_Example_WinMoveOn ;---------------------------------------------------------------------------------------- Func _Example() ; _MM_GetPointPos & _MM_GetPointPos ; _MM_MouseMoveOn: Moves the mouse pointer between multi monitors. ; _MM_GetPointPos: Translate the X, Y point, to given monitor X, Y. Local $Tip, $Title Local $Sign = @CRLF & @CRLF & "press {CTRL} to continue to the next - press {ESC} to Exit" Local $iMidW = @DesktopWidth / 2, $iMidH = @DesktopHeight / 2 ; 1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; move the mouse ponter to Desktop center $Tip = "Mouse x, y:" & @CRLF & $iMidW & ", " & $iMidH $Title = "1) midle point:" & $Sign ToolTip($Title, $iMidW, $iMidH, $Tip, 1, 3) MouseMove($iMidW, $iMidH) _Wait(2) ; 2) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; move the mouse ponter to center of DISPLAY2 with _MM_GetPointPos ; _MM_GetPointPos ( $iX, $iY [, $sDevice = "Primary" [, $Scale = False]] ) Local $aPos = _MM_GetPointPos("($DtW / 2)", "($DtH / 2)", "\\.\DISPLAY2") $Tip = "Mouse x, y:" & @CRLF & $aPos[0] & ", " & $aPos[1] $Title = "2) midle point:" & $Sign ToolTip($Title, $aPos[0], $aPos[1], $Tip, 1, 3) MouseMove($aPos[0], $aPos[1], 30) ; move the mouse ponter to 100, @DesktopHeight / 2 of DISPLAY2 with _MM_MouseMoveOn ; _MM_MouseMoveOn ( $iX, $iY [, $iSpeed = 10 [, $sDevice = "Primary" [, $Scale = False]]] ) _MM_MouseMoveOn(100, "($DtH / 2)", 30, "\\.\DISPLAY2") ; move the mouse ponter to center of DISPLAY2 with _MM_MouseMoveOn _MM_MouseMoveOn("($DtW / 2)", "($DtH / 2)", 30, "\\.\DISPLAY2") _Wait(2) ; 3) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; now let's see the $Scale parameter ; $Scale - [optional] True/False. Default = False ; If True the dimensions will be multiplied with the scale factor of curent monitor $Tip = " move mouse point back" $Title = "3) now let's see the $Scale parameter" & $Sign ToolTip($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1, 3) MouseMove($iMidW, $iMidH) _Wait() ; 4) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; $Scale = False $Tip = ' (1000, 1000, Default, "\\.\DISPLAY2", False )' $Title = "4) _MM_MouseMoveOn() - $Scale = False" & $Sign ; ToolTip($Tip, 1000, 1000, "_MM_MouseMoveOn() - $Scale = False", 1, 3) ; ordinary ToolTip _MM_ToolTipOn($Title, 1000, 1000, $Tip, 1, 3, "\\.\DISPLAY2", False) _MM_MouseMoveOn(1000, 1000, 10, "\\.\DISPLAY2", False) _Wait() ; 5) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; $Scale = True $Tip = ' (1000, 1000, Default, "\\.\DISPLAY2", True)' $Title = "5) _MM_MouseMoveOn() - $Scale = True" & $Sign ; ToolTip($Tip, 1000, 1000, "_MM_MouseMoveOn() - $Scale = False", 1, 3) ; ordinary ToolTip _MM_ToolTipOn($Title, 1000, 1000, $Tip, 1, 3, "\\.\DISPLAY2", True) _MM_MouseMoveOn(1000, 1000, 10, "\\.\DISPLAY2", True) _Wait() ; 6) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; which means that with the scale factor, we can use proportional dimensions with respect to the primary display $Tip = ' _MM_MouseMoveOn() - $Scale = True' $Title = "6) which means that with the scale factor," & @CRLF $Title &= "we can use proportional dimensions with respect to the primary display" & $Sign _MM_ToolTipOn($Title, @DesktopWidth / 2, @DesktopHeight / 2, $Tip, 1, -1, "\\.\DISPLAY2", True) _MM_MouseMoveOn(10, 10, 10, "\\.\DISPLAY2", True) _MM_MouseMoveOn(@DesktopWidth - 10, 10, 10, "\\.\DISPLAY2", True) _MM_MouseMoveOn(@DesktopWidth - 10, 10, 10, "\\.\DISPLAY2", True) _MM_MouseMoveOn(@DesktopWidth - 10, @DesktopHeight - 10, 10, "\\.\DISPLAY2", True) _MM_MouseMoveOn(10, @DesktopHeight - 10, 10, "\\.\DISPLAY2", True) _MM_MouseMoveOn(10, 10, 30, "\\.\DISPLAY2", True) ; 7) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $Tip = '=== _MM_ToolTipOn with $Scale False ===' $Title = "5) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & $Sign _MM_ToolTipOn($Tip, "$DtW/2", "$DtH/2", "$Scale = False", 1, 3, "\\.\DISPLAY2", False) _Wait() $Tip = '=== _MM_ToolTipOn with $Scale True ===' $Title = "5) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & $Sign _MM_ToolTipOn($Tip, @DesktopWidth / 2, @DesktopHeight / 2, "$Scale = True", 1, 3, "\\.\DISPLAY2", True) _Wait() ; 8) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ConsoleWrite(@CRLF & "8) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" & @CRLF) ; _MM_GetPointPos ( $iX, $iY [, $sDevice = "Primary" [, $Scale = False]] ) $aPos = _MM_GetPointPos(@DesktopWidth, @DesktopHeight, "\\.\DISPLAY2", False) ConsoleWrite("DISPLAY2 with false:" & $aPos[0] & "," & $aPos[1] & @CRLF) $aPos = _MM_GetPointPos(@DesktopWidth, @DesktopHeight, "\\.\DISPLAY2", True) ConsoleWrite(" DISPLAY2 with True:" & $aPos[0] & "," & $aPos[1] & @CRLF) EndFunc ;==>_Example ;---------------------------------------------------------------------------------------- Func _Wait($iSec = 5) ; 5*1000 = 5000 Local $iTmp, $Max = ($iSec * 1000) / 50 While Sleep(50) Select Case _IsPressed("11", $hDLL) ;11 CTRL key Sleep(50) Return Case _IsPressed("1B", $hDLL) ;1B = ESC key Exit EndSelect $iTmp += 1 If $iTmp = $Max Then Return WEnd EndFunc ;==>_Wait ;---------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    1 point
  4. Maybe this ? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> ; ListBox OwnerDrawn Colors Global Const $tagDRAWITEMSTRUCT = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;hwnd hwndItem;handle hDC;dword rcItem[4];ptr itemData" Global Const $ODA_DRAWENTIRE = 1 Global Const $ROW_HEIGHT = 24, $MARGIN = 4 Example() Func Example() GUICreate("Ownerdrawn Listbox", 300, 300) Local $idListBox = GUICtrlCreateList("", 4, 4, 292, 292, $WS_VSCROLL + $LBS_OWNERDRAWFIXED) _GUICtrlListBox_SetItemHeight($idListBox, $ROW_HEIGHT) For $i = 0 To 19 _GUICtrlListBox_AddString($idListBox, "") Next GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example Func WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam) Local $tDRAWITEMSTRUCT = DllStructCreate($tagDRAWITEMSTRUCT, $lParam) Switch $tDRAWITEMSTRUCT.itemAction Case $ODA_DRAWENTIRE Local $tRECT = DllStructCreate($tagRECT, DllStructGetPtr($tDRAWITEMSTRUCT, "rcItem")) Local $hBrush = _WinAPI_CreateSolidBrush(Mod($tDRAWITEMSTRUCT.itemID, 2) ? 0xFFFFFF : 0xE0E0E0) _WinAPI_FillRect($tDRAWITEMSTRUCT.hDC, $tRECT, $hBrush) Local $sItemText = "Line " & $tDRAWITEMSTRUCT.itemID $tRECT.Left += $MARGIN $tRECT.Top += $MARGIN _WinAPI_DrawText($tDRAWITEMSTRUCT.hDC, $sItemText, $tRECT, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM
    1 point
  5. I've been working on graphics routines for my 360-degree Snake program, and I've been experimenting with bezier curves. It's kind of a pain to have to generate all those control points, so I wrote a routine to do it automatically. I thought someone else might like it, so I'll share it. This routine would be useful to anyone who is doing line-graphics and wants them smoother, or for example if you are drawing a graph and want it to look more round and not so sharp. The _PointDrawBezier() function is designed to draw open shapes, but with some modifications I can write another function better suited for closed shapes. Anyway, have a look. The example is really easy to understand - it will ask you for a curve strength (just take the default of 0.5 for now) and then click on the screen to set the points. Once you have at least 4 point (3 points set, the mouse counts as a 4th), it can calculate the curve. If you're curious to know where the control points are, then uncomment the 4 lines that have "$GUI_GR_DOT" in them. Enjoy! EDIT Added a new version that also does closed figures. Last version had 17 downloads. MWR_beziers_20060511.zip
    1 point
×
×
  • Create New...