Jump to content

get Mouse Pos in Rect


Recommended Posts

Hi

I need to Begins get mouse Pos From inside the rectangle , i use GUIGetCursorInfo() .

Untitled.jpg.92c28decdf8428969551a04a623

Example :

#include <GDIplus.au3>
#include <GUIConstantsEx.au3>

AutoItSetOption("MouseCoordMode", 0)
AutoItSetOption("GUIOnEventMode", 1)

Global Const $iW = 400, $iH = 400, $iBgColor = 0xF0F0F0
Global Const $hGUI = GUICreate("", $iW, $iH)
GUISetBkColor($iBgColor, $hGUI)
GUISetState()

_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hPen = _GDIPlus_PenCreate()
$hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
$hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hCtxt, 4)
_GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, 4)

Global Const $iPosX = 50, $iPosY = 50, $iWidth = 300, $iHeight = 300
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

Do
    $hPos = GUIGetCursorInfo($hGUI)
    ToolTip($hPos[0] & " , " & $hPos[1])
    _GDIPlus_GraphicsClear($hCtxt, 0xFF000000 + $iBgColor)
    _GDIPlus_GraphicsDrawRect($hCtxt, $iPosX, $iPosY, $iWidth, $iHeight, $hPen)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH)
Until Not Sleep(10)

Func _Exit()
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hCtxt)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_Shutdown()
    GUIDelete()
    Exit
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...