Jump to content

Recommended Posts

Posted

I'm trying to convert mouse position into MS Publisher's Document coordinates

but my mouse is like 50 to 100 points off from the place it should be

What I'm doing wrong? Maybe I need some conversion? Like PointsToPixels?

$pos=MouseGetPos();

Local $tpoint = DllStructCreate("int X;int Y")

DllStructSetData($tpoint, "X", $pos[0])

DllStructSetData($tpoint, "Y", $pos[1])

_WinAPI_ScreenToClient($oPublisherObj.Activewindow.hwnd, $tPoint)

$X1Pos=DllStructGetData($tpoint, "X");

$Y1Pos=DllStructGetData($tpoint, "Y");

thanks

  • Moderators
Posted

tobject,

Your code looks correct. This is something I wrote to answer another question some time ago which uses the same function (you need AutoIt Help open so you can click in it):

#include <Misc.au3>
#include <WinAPI.au3>

_Convert_Coordinates()

Func _Convert_Coordinates()

    Local $tPoint = DllStructCreate("int X;int Y")
    Local $aCoords

    Local $dll = DllOpen("user32.dll")

    While 1

        If _Ispressed("01", $dll) = 1 Then
            $aCoords = MouseGetPos()
            ConsoleWrite("Screen coords: " & $aCoords[0] & " - " & $aCoords[1] & @CRLF)
            ExitLoop
        EndIf

    WEnd

    DllClose($dll)

    WinActivate("AutoIt Help")
    WinWaitActive("AutoIt Help")
    Local $hWnd = WinGetHandle("AutoIt Help")

    DllStructSetData($tPoint, "X", $aCoords[0])
    DllStructSetData($tPoint, "Y", $aCoords[1])

    _WinAPI_ScreenToClient($hWnd, $tPoint)

    $aCoords[0] = DllStructGetData($tPoint, "X")
    $aCoords[1] = DllStructGetData($tPoint, "Y")

    ConsoleWrite("Client coords: " & $aCoords[0] & " - " & $aCoords[1] & @CRLF)

EndFunc

Two things spring to mind (bear in mind I am not at all familiar with the app you are using! :huggles: ):

1. Does the active window of MS Publisher which you are using have coordinates which start 0,0 in the top left corner?

2. Is $oPublisherObj.Activewindow.hwnd actually giving you the handle of the window you want? (You can check this with the Au3 Window Info Tool)

Sorry I cannot be of more help - I hope one of these suggestions does the trick. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

I'm doing custom resizing

on Alt+1 it grabs left top corner of my object and should drag it with mouse cursor til I click Alt+1 again

I guess I'm missing conversion from Client mouse position into Document points/objects position

http://msdn.microsoft.com/en-us/library/aa211711(office.11).aspx

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
  • Recently Browsing   0 members

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