Sign in to follow this  
Followers 0
Alex1986

get Mouse Pos in Rect

2 posts in this topic

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

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0