Sign in to follow this  
Followers 0
bob.frew

Mouse position in scrollable child GUI

8 posts in this topic

Hi people,
I hope you can help.


I have a GUI with a scrollable child GUI containing an image.
I am trying to get the x,y position of the mouse relative to the image.

I'm using
opt ('MouseCoordMode', 2)
MouseGetPos() and GUIGetCursorInfo($Child_GUI) both return the position of the mouse on the window.

So unless there is another command I have overlooked ??? !!
The alternate way is if I knew the current top and left of the image that is actually visible.
From this it would be simple to calculate the image (x,y) that the mouse is over.

I have used #include "GUIScrollbars_Ex.au3"  for the scrollbars.
Had hoped the values I need would be lurking in that code but if they are I can't see them.

I suspect I am missing the point somewhere (again)

All help greatly appreciated.
            Bob


AutoIt is great - leave me alone and I'll play for hours

Share this post


Link to post
Share on other sites



bob.frew,

Post the code you are using to create the GUI and child and I will take a look. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Opt ("ExpandEnvStrings", 0)
Opt ("ExpandVarStrings", 1)
Opt ("MustDeclareVars", 1)
opt ('MouseCoordMode', 2)        ; set relative coordinate system

;
#include <Array.au3>
#Include <File.au3>
#include <Date.au3>
#include <GDIPlus.au3>
#include <Misc.au3>

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include "GUIScrollbars_Ex.au3"
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
; ------------------------------------------------ version specifics
Dim $version = "V2.1"
Dim $version_date = "Nov 2013"
Dim $ico = @ScriptDir & "\_images\im.ico"
Dim $tname = "   ImgPart " & $version

; ------------------------------------------------ GUI variables
Dim $Cwindow,$Main_msg,$Child_GUI
Dim $c_cancel_button,$c_start_button

Dim $window_colour = 0x00005b ;     dark blue
Dim $f_colour_front = 0x000000 ;     white
Dim $f_colour_back = 0x007c7c ;     pale green

Dim $font = "Arial Narrow"
Dim $font2 = "Century Gothic"
; ------------------------------------------------
Dim $cancelled = 0;
; ------------------------------------------------ get image file
Dim $file_in = FileOpenDialog("ImgPart - Choose file", "", "img (*.*)", 1 + 2 ) ;  e.g. "F:\_Current\Lang\AutoIt\Mint\_data\pdf\Mint_2012_01.pdf"
If @error Then
   MsgBox(4096,"ImgPart","No File(s) chosen. Prog ends ")
    Exit
EndIf
; ------------------------------------------------ get info on image
_GDIPlus_Startup ()
Local $hImage = _GDIPlus_ImageLoadFromFile($file_in)
If @error Then
    MsgBox(16, "Error", "Does the file exist?")
    Exit 1
EndIf
Dim $W = _GDIPlus_ImageGetWidth($hImage)
Dim $H = _GDIPlus_ImageGetHeight($hImage)
_GDIPlus_ImageDispose ($hImage)
_GDIPlus_ShutDown ()
; ------------------------------------------------
;MsgBox(4096,"ImgPart","$W = " & $W & ", $H = " & $H)

; ######################################################################################

createGUI()
showGUI()

Exit
; ######################################################################################


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Func createGUI()
    Local $tbase  = 640;
; MsgBox(4096,"ImgPart","$W = " & $W & ", $H = " & $H & ", tbase = " & $tbase)


    Local $twidth = 140;
    Local $r = 190;
;    $Cwindow = GUICreate($tname, $W, $H+100, 10, 10, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_HSCROLL + $WS_VSCROLL)
    $Cwindow = GUICreate($tname, 600, 700, 10, 10, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

    GUISetIcon($ico)
    GUISetBkColor($window_colour)
     ; use width and height as per image


    $c_cancel_button = GUICtrlCreatePic("", 30, $tbase, 60, 20)       ;
    GUICtrlSetImage($c_cancel_button, @ScriptDir & "\_images\Stop_60.jpg")



    GUISetState(@SW_SHOW, $Cwindow)
    ; --------------------------------------------------------------------


    $Child_GUI = GUICreate("Child", 600, 600, 0, 0, $WS_CHILD, -1, $Cwindow)

    GUICtrlCreatePic($file_in, 0, 0, $W, $H)
    GUISetState(@SW_SHOW, $Child_GUI)

    _GUIScrollbars_Generate($Child_GUI, $W, $H)
    Return
EndFunc   ;==>createCatalogueGUI
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Func showGUI()
    Local $hDLL = DllOpen("user32.dll")
    While 1
        $Main_msg = GUIGetMsg()
        If $Main_msg = $GUI_EVENT_CLOSE Then
            $cancelled = 1;
            ExitLoop
        EndIf

        If $Main_msg = $c_cancel_button Then
            $cancelled = 1;
            ExitLoop
        EndIf
#cs
        If $Main_msg = $c_start_button Then
            validate()
            If $valid=1 Then
               ExitLoop
            EndIf
        EndIf
#ce
    If _IsPressed("20", $hDLL) Then
        ; ConsoleWrite("_IsPressed - Space Bar was pressed." & @CRLF)

        While _IsPressed("20", $hDLL)      ; Wait until key is released.
            Sleep(250)
        WEnd
        ; ConsoleWrite("_IsPressed - Space Bar was released." & @CRLF)
        addPoint()
    EndIf

    Wend
    Return
EndFunc
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Func addPoint()
    Local $mouse = MouseGetPos()
    MsgBox(0, "Mouse x,y:  ", $mouse[0] & "," & $mouse[1])

    Local $a = GUIGetCursorInfo($Child_GUI)
    MsgBox(0, "GUI get Mouse x,y:  ", $a[0] & ", " & $a[1] )
;    GUICtrlSetData($x, $a[0])
;    GUICtrlSetData($y, $a[1])
    Return
EndFunc
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 

// Am only at start of this idea

 

Bob

Edited by Melba23
Added tags

AutoIt is great - leave me alone and I'll play for hours

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

bob.frew,

Got it. When you post code in future please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. ;)

M23

Edit: I hate scrollbars! This is proving more difficult than I thought - I am getting very nearly the correct answer but there is something not quite right and I cannot find out where. :wacko:

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

bob.frew,

Ready for a quick tutorial on scrollbars? :D

Scrollbar movement is based on the dimensions of virtual lines and characters of the text that might be present in the GUI. As we are scrolling an image it is quite likely that this will not exactly be the correct number of pixels to match a round number of lines or characters and so there will be either a small margin around it (more likely in my experience) or it will be slightly cropped. Still hanging in there? ;)

The image I was using was slightly cropped - which is why I said I was getting coordinates that were slightly off. In fact the coordinates were correct but the image was not quite a large as I thought it should be. Once I realised that all became clear. I have cleaned up the script a bit to clarify what is going on - and used an Accelerator key to fire the coordinate calculation as it is much cleaner than using _IsPressed:

#include <GUIConstantsEx.au3>
#include "GUIScrollbars_Ex.au3"
#include <WindowsConstants.au3>
#include <GDIPlus.au3>

Global $Cwindow, $Main_msg, $Child_GUI
Global $c_cancel_button, $c_start_button, $cImage, $cDummy

Global $version = "V2.1"
Global $version_date = "Nov 2013"
Global $ico = @ScriptDir & "\_images\im.ico"
Global $tname = "   ImgPart " & $version

Global $window_colour = 0x00005b ;     dark blue
Global $f_colour_front = 0x000000 ;     white
Global $f_colour_back = 0x007c7c ;     pale green

Global $font = "Arial Narrow"
Global $font2 = "Century Gothic"
Global $cancelled = 0;

Global $file_in = FileOpenDialog("ImgPart - Choose file", "", "img (*.*)", 1 + 2) ;  e.g. "F:\_Current\Lang\AutoIt\Mint\_data\pdf\Mint_2012_01.pdf"
If @error Then
    MsgBox(4096, "ImgPart", "No File(s) chosen. Prog ends ")
    Exit
EndIf

_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile($file_in)
If @error Then
    MsgBox(16, "Error", "Does the file exist?")
    Exit 1
EndIf
Global $W = _GDIPlus_ImageGetWidth($hImage)
Global $H = _GDIPlus_ImageGetHeight($hImage)

ConsoleWrite("Image: " & $W & " - " & $H & @CRLF)

_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()

createGUI()

; Now we get the scrollbar factors to determine how each of them moves 
Global $aFactors = _Get_Factors()

While 1
    $Main_msg = GUIGetMsg()
    Switch $Main_msg
        Case $GUI_EVENT_CLOSE
            $cancelled = 1;
            ExitLoop

        Case $c_cancel_button
            $cancelled = 1;
            ExitLoop

    Case $cDummy
        addPoint()

    EndSwitch

WEnd

Exit


; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Func createGUI()
    Local $tbase = 640;
    Local $twidth = 140;
    Local $r = 190;
    $Cwindow = GUICreate($tname, 600, 700, 10, 10, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

    GUISetIcon($ico)
    GUISetBkColor($window_colour)

    $c_cancel_button = GUICtrlCreatePic("", 30, $tbase, 60, 20) ;
    $cImage = GUICtrlSetImage($c_cancel_button, "M:\Program\Au3 Scripts\Images\VistaX.jpg")

    $cDummy = GUICtrlCreateDummy()

    GUISetState(@SW_SHOW, $Cwindow)

    Local $aAccelKeys[1][2] = [["{SPACE}", $cDummy]]
    GUISetAccelerators($aAccelKeys)

    ; --------------------------------------------------------------------

    $Child_GUI = GUICreate("Child", 600, 600, 0, 0, $WS_CHILD, -1, $Cwindow)
    GUISetBkColor(0xFF0000)

    $cImage = GUICtrlCreatePic($file_in, 0, 0, $W, $H)
    GUISetState(@SW_SHOW, $Child_GUI)

    _GUIScrollbars_Generate($Child_GUI, $W, $H) ; Using the correct values cropped my image a bit.  I needed to add 25 to each

    Return

EndFunc   ;==>createGUI

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Func addPoint()

    ; Where is the cursor on the child?
    Local $a = GUIGetCursorInfo($Child_GUI)
    ; Add the amount the image has been scrolled (pixels = scroll units * relevant factor)
    $iX = $a[0] + _GUIScrollBars_GetScrollInfoPos($Child_GUI, $SB_HORZ) * $aFactors[0]
    $iY = $a[1] + _GUIScrollBars_GetScrollInfoPos($Child_GUI, $SB_VERT) * $aFactors[1]

    ConsoleWrite("Mouse: " & $iX & " - " & $iY & @CRLF)

    Return
    
EndFunc   ;==>addPoint
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Func _Get_Factors()

    Local $aFactors[2]
    Local $tTEXTMETRIC = DllStructCreate($tagTEXTMETRIC)
    ; Determine text size
    Local $hDC = DllCall("user32.dll", "handle", "GetDC", "hwnd", $Child_GUI)
    If Not @error Then
        $hDC = $hDC[0]
        DllCall("gdi32.dll", "bool", "GetTextMetricsW", "handle", $hDC, "ptr", DllStructGetPtr($tTEXTMETRIC))
        If @error Then
            $iError = @error
            $iExtended = @extended
            DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $Child_GUI, "handle", $hDC)
            Return SetError($iError, $iExtended, -2)
        EndIf
        DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $Child_GUI, "handle", $hDC)
    Else
        Return SetError(@error, @extended, -1)
    EndIf
    ; And store the factors
    $aFactors[0] = DllStructGetData($tTEXTMETRIC, "tmAveCharWidth") ; This is the average width of a character
    $aFactors[1] = DllStructGetData($tTEXTMETRIC, "tmHeight") + DllStructGetData($tTEXTMETRIC, "tmExternalLeading") ; This is the height of a line

    Return $aFactors

EndFunc
Please ask if you have any questions - scrollbars are really complex beasts and I still find them difficult to deal with even after all the experimentation I did to produce the UDF you are using to create them. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi M23,
many thanks for taking the time to look at my problem.
Very helpful indeed.

I had assumed (there's that word again) a couple of variables might have been lying about after the scroll bar had moved the display  so that I did not need to get involved with the scrollbars themselves.

Not being used to using DllCall the _Get_Factors() function phases me somewhat. I will have to come back to that later.
If all goes to plan I hope to be able to move the scrollbars to a given position once this first part is working ok. So will no doubt be doing some reading at that time.
For now you have got me moving forward again - 

Am sorry about posting the code outside a box. Have made a note to self for next time.
I like your use of Accelerator key. I had not come across those before.  

Thanks again

                       ... Bob 

 


AutoIt is great - leave me alone and I'll play for hours

Share this post


Link to post
Share on other sites

bob.frew,

 

using DllCall the _Get_Factors() function phases me somewhat

Not the easiest bit of code for a beginner that! :D

However, all it does is to ask Windows about the font that would be used in that GUI - as I explained, Windows uses the font average width and line height to determine how to move the scrollbars. "DC" is the "device context" of the GUI - essentially the description of how it will look - and we ask Windows for ithe GUI's "TextMetrics" data from which we extract the required dimensions. Does that help clear the mist at all? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Hi M23,

yes - should push me in the right direction

            cheers  Bob  :)


AutoIt is great - leave me alone and I'll play for hours

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

  • Similar Content

    • Tarakesh
      By Tarakesh
      I have a situation where the desktop is designed in java swings. The nodes JTree is not allowing me to do checkbox selection using "spacebar". I am able to navigate through the nodes using up, down arrow and a tab. When I reach to the desire node selection, mouse left click is not working due a flaw a JTree core. However since it is selected, if mouse cursor auto moved to the position of the selection and send a "click"  then it should be solved. Any ideas much appreciated. 
      the problem with having fixed coordinates are the main windows is divided to 2panels where right panel containing this JTree can be expanded or shrink-ed.

    • perlabsrat
      By perlabsrat
      Hello, I have a Logitech MX500 mouse, this has 7 buttons plus a wheel.
      I am trying to figure out how to detect clicks on three of the buttons on this mouse but have been unable to do so. I am not running any Logitech software just the standard Windows 7 driver. The buttons are all working fine but when I try to figure out which button was clicked unable to detect three of the buttons.

      Using this code snippet I am able to see all the button presses with the exception of these three marked by '?'.
      Is there some alternate method for detecting button clicks? I have been searching for example but have yet to find anything.
      Thanks...
       
      #include <Misc.au3> Dim $a While 1 For $a = 1 To 100 If _IsPressed($a) Then ConsoleWrite("you pressed " & $a & @CRLF) Next WEnd
    • Marcelos
      By Marcelos
      In my work place they blocked the application movemouse. so y decided to do one by myself , to cheat the system.
      I have used some peaces of code from another scripts I have, and also I have found in this forum
      Hope this helps
      $version="0.2" #include <Misc.au3> If _Singleton(@ScriptName, 1) = 0 Then ; allow only one instance MsgBox(0, "Warning", "An occurence of " & @ScriptName & " is already running") Exit EndIf #region tray icon #NoTrayIcon Opt("TrayIconHide", 0) Opt("TrayMenuMode", 1) TraySetToolTip("Ratoner "& $version) Local $exititem = TrayCreateItem("Exit") TraySetState(1) ; Show the tray menu. #endregion #region variables $BlockScreensaver=1 $flagMouse=1 $MouseNotMovedCounter=0 $posMouseMovedX=0 $posMouseMovedY=0 $Counter= 0 #endregion #region main Local $hTimer = TimerInit() while 1 $Counter=$Counter+1 if $Counter>1000 then CheckifMouseMove() if $MouseNotMovedCounter>2 then moveMouse() $Counter= 0 endif Switch TrayGetMsg() Case $exititem exit EndSwitch sleep(50) wend #endregion #region functions func CheckifMouseMove() ;~ ConsoleWrite("+CheckifMouseMove()" & @crlf) $posMouseMoved = MouseGetPos() if $posMouseMovedX<>$posMouseMoved[0]or $posMouseMovedY <> $posMouseMoved[1] then $posMouseMovedX=$posMouseMoved[0] $posMouseMovedY=$posMouseMoved[1] $MouseNotMovedCounter=0 ;~ ConsoleWrite('>$MouseNotMovedCounter = ' & $MouseNotMovedCounter & @crlf ) Else ;$MouseMoved=0 $MouseNotMovedCounter=$MouseNotMovedCounter+1 ;~ ConsoleWrite('--$MouseNotMovedCounter = ' & $MouseNotMovedCounter & @crlf ) endif EndFunc func moveMouse() ;~ ConsoleWrite("+moveMouse" & @crlf) Local $posMouse = MouseGetPos() $flagMouse=$flagMouse*-1 Local $new_y = $posMouse[1] + $flagMouse ; + (10*$flagMouse) MouseMove($posMouse[0],$new_y) $MouseNotMovedCounter=0 ;~ ConsoleWrite("+mouseMove $MouseNotMovedCounter" & $MouseNotMovedCounter & @crlf) endfunc #endregion  
    • Miliardsto
      By Miliardsto
      Hello . I implemented script like this
      But the vars $iX1 $iY1 are counting from the desktop start and I want it coords by window
      This not work with this script Opt("MouseCoordMode", 0)
      Func Mark_Rect() Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp Local $UserDLL = DllOpen("user32.dll") ; Create transparent GUI with Cross cursor $hCross_GUI = GUICreate("Test", @DesktopWidth, @DesktopHeight - 20, 0, 0, $WS_POPUP, $WS_EX_TOPMOST) WinSetTrans($hCross_GUI, "", 8) GUISetState(@SW_SHOW, $hCross_GUI) GUISetCursor(3, 1, $hCross_GUI) Global $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0x00FF00) ; Wait until mouse button pressed While Not _IsPressed("01", $UserDLL) Sleep(10) WEnd ; Get first mouse position $aMouse_Pos = MouseGetPos() global $iX1 = Round($aMouse_Pos[0], 2) global $iY1 = Round($aMouse_Pos[1], 2) ; Draw rectangle while mouse button pressed While _IsPressed("01", $UserDLL) $aMouse_Pos = MouseGetPos() $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0) $hMask = _WinAPI_CreateRectRgn($iX1, $aMouse_Pos[1], $aMouse_Pos[0], $aMouse_Pos[1] + 1) ; Bottom of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($iX1, $iY1, $iX1 + 1, $aMouse_Pos[1]) ; Left of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($iX1 + 1, $iY1 + 1, $aMouse_Pos[0], $iY1) ; Top of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) $hMask = _WinAPI_CreateRectRgn($aMouse_Pos[0], $iY1, $aMouse_Pos[0] + 1, $aMouse_Pos[1]) ; Right of rectangle _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2) _WinAPI_DeleteObject($hMask) ; Set overall region _WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask) If WinGetState($hRectangle_GUI) < 15 Then GUISetState() Sleep(10) ; Get second mouse position global $iX2 = Round($aMouse_Pos[0], 2) global $iY2 = Round($aMouse_Pos[1], 2) ; Set in correct order if required If $iX2 < $iX1 Then $iTemp = $iX1 $iX1 = $iX2 $iX2 = $iTemp EndIf If $iY2 < $iY1 Then $iTemp = $iY1 $iY1 = $iY2 $iY2 = $iTemp EndIf If _IsPressed("01", $UserDLL) = 0 Then _GDIPlus_Startup () $hDC = _WinAPI_GetWindowDC(0) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) ;Stworz pedzel i kolor, width ;$hPen = _GDIPlus_PenCreate(0x00FF00) ; Rysowanie linii ;_GDIPlus_GraphicsDrawLine($hGraphic,$iX1,$iY1,$iX2,$iY2,$hPen) ; middle of rectangle $xMiddle = ( $iX1 + $iX2 ) / 2 $yMiddle = ( $iY1 + $iY2 ) / 2 _GDIPlus_GraphicsDrawRect( $hGraphic, $xMiddle-20, $yMiddle-20, 40, 40) EndIf WEnd GUIDelete($hRectangle_GUI) GUIDelete($hCross_GUI) DllClose($UserDLL) EndFunc ;==>Mark_Rect