Sign in to follow this  
Followers 0
MITH

AU3_DLL - WinGetPos Functions

10 posts in this topic

Hi,

I am not able to get the four WinGetPos functions to work in VBA using the Autoit DLL.

I get error stating "Cant find DLL Entry Point AU3_WinGetPosX in AutoitX3.dll"

Here's my Code:

Private Declare Function AU3_WinGetPosX Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As LongPtr, ByVal szText As LongPtr) As Long
Private Declare Function AU3_WinGetPosY Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As LongPtr, ByVal szText As LongPtr) As Long
Private Declare Function AU3_WinGetPosHeight Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As LongPtr, ByVal szText As LongPtr) As Long
Private Declare Function AU3_WinGetPosWidth Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As LongPtr, ByVal szText As LongPtr) As Long

Public Function WinGetPosX(szTitle As String, Optional szText As String = "") As Long
WinGetPosX = AU3_WinGetPosX(StrPtr(szTitle), StrPtr(szText))
End Function

Sub Test()
msgbox WinGetPosX ("Untitled - Notepad")
End Sub

Requesting to help me please...

Share this post


Link to post
Share on other sites



John,

I am able to use most of the AutoIt DLL Functions except that return screen coordinates like the below ones:

AU3_WinGetPosX

AU3_WinGetPosY

AU3_WinGetPosHeight

AU3_WinGetPosWidth
AU3_MouseGetPosX
AU3_MouseGetPosY

AU3_ControlGetPosX

AU3_ControlGetPosY

AU3_ControlGetPosHeight

AU3_ControlGetPosWidth

I am not sure what is causing this problem.

Share this post


Link to post
Share on other sites

This works for me:

Private Declare Function AU3_WinGetPosX Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As Long, ByVal szText As Long) As Long
Private Declare Function AU3_WinGetPosY Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As Long, ByVal szText As Long) As Long
Private Declare Function AU3_WinGetPosHeight Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As Long, ByVal szText As Long) As Long
Private Declare Function AU3_WinGetPosWidth Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" (ByVal szTitle As Long, ByVal szText As Long) As Long

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi Funkey, I tried the method you suggested, but still not working, same error again.  :(  Seems to be bug in the AutoItx3.dll which I am using or may be because I am using 32bit MS Office on 64bit Windows 7 - Not sure. Could you please tell me which version of AutoItx3.dll you are using. I will try with that version. My version is 3.3.12.0

Thanks.

Edited by MITH

Share this post


Link to post
Share on other sites

Hello,

I tried with AutoIt 3.3.8.1 on Win7 x64 with Office 2003. For me everything worked as expected.

Maybe I have soon time to test with v3.3.12.0.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

Hi

I tried the code with AutoItX3.dll version 3.3.8.1 - works perfectly. I also tested the same code with version 3.3.10.2 but it does not work. Seems the bug started from versions later than 3.3.8.1. Hope this is fixed in next version.

Thanks Funkey :thumbsup:

Share this post


Link to post
Share on other sites

Hi

I again need your help.

It was not the bug. :mad2:

In AutoIt DLL Version 3.3.12.0. I find that the AU3_WinGetPosX, AU3_WinGetPosY, AU3_WinGetPosHeight and AU3_WinGetPosWidth functions are removed and a singe function AU3_WinGetPos has been added. But in new function there is third LPRect Argument which is now giving wrong coordinates. :doh:

Below is my code using new function. The coordinates returned are 0. Please help me on this.

Public Declare  Function AU3_WinGetPos Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" _
(szTitle As LongPtr, szText As LongPtr, LPRect As LPRect) As Integer

Type LPRect
X As Integer
Y As Integer
Width As Integer
Height As Integer

End Type


Sub Test()

Dim LRect As LPRect, r As Integer, sT As String, sTx As String
sT = "AutoItX Help"
sTx = ""

r = AU3_WinGetPos(StrPtr(sT), StrPtr(sTx), LRect)

MsgBox LRect.X & "  " & LRect.Y & "  " & LRect.Width & "  " & LRect.Height
End Sub

Share this post


Link to post
Share on other sites

 

Hi

I again need your help.

It was not the bug. :mad2:

In AutoIt DLL Version 3.3.12.0. I find that the AU3_WinGetPosX, AU3_WinGetPosY, AU3_WinGetPosHeight and AU3_WinGetPosWidth functions are removed and a singe function AU3_WinGetPos has been added. But in new function there is third LPRect Argument which is now giving wrong coordinates. :doh:

Below is my code using new function. The coordinates returned are 0. Please help me on this.

Public Declare  Function AU3_WinGetPos Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" _
(szTitle As LongPtr, szText As LongPtr, LPRect As LPRect) As Integer

Type LPRect
X As Integer
Y As Integer
Width As Integer
Height As Integer

End Type


Sub Test()

Dim LRect As LPRect, r As Integer, sT As String, sTx As String
sT = "AutoItX Help"
sTx = ""

r = AU3_WinGetPos(StrPtr(sT), StrPtr(sTx), LRect)

MsgBox LRect.X & "  " & LRect.Y & "  " & LRect.Width & "  " & LRect.Height
End Sub

 

There is no problem with AU3_WinGetPos function. I'm using java, see https://code.google.com/p/jautoitx

Share this post


Link to post
Share on other sites

Solved: It was just the DLL calling convention that I should have followed.

:guitar:

Public Declare  Function AU3_WinGetPos Lib "C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" _
(ByVal szTitle As LongPtr, ByVal szText As LongPtr, ByRef LPRect As LPRect) As Integer

Type LPRect
X As Integer
Y As Integer
Width As Integer
Height As Integer

End Type


Sub Test()

Dim LRect As LPRect, r As Integer, sT As String, sTx As String
sT = "AutoItX Help"
sTx = ""

r = AU3_WinGetPos(StrPtr(sT), StrPtr(sTx), LRect)

MsgBox LRect.X & "  " & LRect.Y & "  " & LRect.Width & "  " & LRect.Height
End Sub

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