Sign in to follow this  
Followers 0

cursor position !

10 posts in this topic

#1 ·  Posted (edited)

Gets the mouse cursor position relative to CONTROL ? 

 
Edited by Mrbenkali

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi,

Yes you can, think a little.


OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

Updated 07 November, 2013 - If you find dead links please send me a PM, do not post in the topics !

Share this post


Link to post
Share on other sites

#3 ·  Posted

you can do it in my example !

Share this post


Link to post
Share on other sites

#4 ·  Posted

you can do it in my example !

:blink:


OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

Updated 07 November, 2013 - If you find dead links please send me a PM, do not post in the topics !

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hints: Ctrl coords, Mouse coords; Difference.

Edited by FireFox

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

Updated 07 November, 2013 - If you find dead links please send me a PM, do not post in the topics !

Share this post


Link to post
Share on other sites

#6 ·  Posted

How to do in this example 

#include <GUIConstantsEx.au3>

Global $x, $y

Example()

Func Example()
    Local $msg

    HotKeySet("{Esc}", "GetPos")

    GUICreate("Press Esc to Get Pos", 400, 400)
    $x = GUICtrlCreateLabel("0", 10, 10, 50)
    $y = GUICtrlCreateLabel("0", 10, 30, 50)
    $Pic1 = GUICtrlCreatePic("", 10, 40, 250, 250)
    GUISetState()

    ; Run the GUI until the dialog is closed
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func GetPos()
    Local $a

    $a = GUIGetCursorInfo($Pic1)
    GUICtrlSetData($x, $a[0])
    GUICtrlSetData($y, $a[1])
EndFunc   ;==>GetPos

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You're losing more time to post than to find how to do it knowing that I almost did it for you (without code).

Edited by FireFox

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

Updated 07 November, 2013 - If you find dead links please send me a PM, do not post in the topics !

Share this post


Link to post
Share on other sites

#8 ·  Posted

FireFox already told you.

You already know the coordinates of the control.  You know how to get the coordinates of the mouse.  The rest is arithmetic.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Result: You don't even need to get the cursor coords (with the MouseGetPos function).

That was quite hard.

#include <GUIConstantsEx.au3>
 
Local $hGUI = 0, $iLabel1 = 0, $aCi = 0, $aCtrlPos = 0
 
$hGUI = GUICreate("MyGUI")
 
$iLabel1 = GUICtrlCreateLabel("", 10, 10, 100, 13)
 
GUISetState(@SW_SHOW, $hGUI)
 
$aCtrlPos = ControlGetPos($hGUI, "", $iLabel1) ;in case you don't know the control coords
 
While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(10)
 
    $aCi = GUIGetCursorInfo($hGUI)
    If IsArray($aCi) = 0 Then ContinueLoop
 
    GUICtrlSetData($iLabel1, "X: " & $aCi[0] - $aCtrlPos[0] & ", Y: " & $aCi[1] - $aCtrlPos[1])
WEnd
 
GUIDelete($hGUI)
Edited by FireFox

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

Updated 07 November, 2013 - If you find dead links please send me a PM, do not post in the topics !

Share this post


Link to post
Share on other sites

#10 ·  Posted

AH OK THANK YOU 

FireFox   :thumbsup: 

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