tobject Posted February 5, 2010 Share Posted February 5, 2010 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 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 5, 2010 Moderators Share Posted February 5, 2010 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):expandcollapse popup#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) EndFuncTwo things spring to mind (bear in mind I am not at all familiar with the app you are using! ):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. M23 deleteme_yes 1 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: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tobject Posted February 6, 2010 Author Share Posted February 6, 2010 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now