|
-
Jun 23rd, 2000, 06:58 AM
#1
Thread Starter
Fanatic Member
Hello everyone. I know how to get the X and Y coordinates of a foreign application, but like to know if there is any faster and easier method. Currently, I am using GetWindowRect.
Thank You
Chemically Formulated As:
Dr. Nitro
-
Jun 23rd, 2000, 07:09 AM
#2
transcendental analytic
You can use ClienttoWindow API, but i'm not sure if it's faster in any way.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 23rd, 2000, 07:12 AM
#3
Thread Starter
Fanatic Member
Hello Kedaman!
Long time no talk to. Thank you for replying but there is no API call ClientToWindow. Do you mean ClientToScreen? I am going to play around with it now.
Chemically Formulated As:
Dr. Nitro
-
Jun 23rd, 2000, 07:35 AM
#4
Thread Starter
Fanatic Member
GetWindowRect or ClientToScreen
Kedaman! This is very interesting. Try this code by stepping through it with F8. Make sure you step through it with F8. I got two different results for the X and Y.
Drop it into a form that is not maximize during run time.
Code:
Option Explicit
Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As Rect) As Long
Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Form_Click()
Dim p_Positon As POINTAPI
Call ClientToScreen(Me.hwnd, p_Positon)
Dim r_Positon As Rect
Call GetWindowRect(Me.hwnd, r_Positon)
Call SetCursorPos(p_Positon.X, p_Positon.Y)
Call SetCursorPos(r_Positon.Left, r_Positon.Top)
End Sub
Thanks for introducing a new API to me, Kedaman.
Chemically Formulated As:
Dr. Nitro
-
Jun 23rd, 2000, 07:39 AM
#5
transcendental analytic
oh, i meant that
Well, you use a pointapi to retrive the position
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 23rd, 2000, 07:42 AM
#6
Thread Starter
Fanatic Member
I am not quite sure what you mean, but I used both API to see the difference. The ClientToScreen uses a PointAPI to get the position. The GetWindowRect uses Rect to get Left and Top.
Chemically Formulated As:
Dr. Nitro
-
Jun 23rd, 2000, 07:54 AM
#7
transcendental analytic
sorry, wrote that before you posted, such things happens to me all the time well, have fun with it
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 24th, 2000, 09:01 AM
#8
PowerPoster
GetCursorPos API
I think use the GetCursorPos API will do.
Code:
Option Explicit
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private pt As POINTAPI
Private Sub Command1_Click()
Dim dl As Long
Dim PosX As Long
Dim PosY As Long
dl = GetCursorPos(pt)
PopX = ScaleX(pt.x, vbPixels, vbTwips)
PopY = ScaleY(pt.y, vbPixels, vbTwips)
Msgbox "Current Mouse Position is " & PopX & ", " & PopY
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|