Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default capturing mouse positions at any moment

Hi,

I need to find out the position of a mouse at any given moment , i.e
without any event happening, is this possible. If yes ,how can i do
that. Please help me on this.
Thanks in advance.

Regards
Shrinu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default capturing mouse positions at any moment

Hi
AFAIK not possible on a worksheet within Excel / VBA

--
Regards
Frank Kabel
Frankfurt, Germany


Shrinu wrote:
Hi,

I need to find out the position of a mouse at any given moment , i.e
without any event happening, is this possible. If yes ,how can i do
that. Please help me on this.
Thanks in advance.

Regards
Shrinu


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default capturing mouse positions at any moment

Hi Shrinu,

Here is some code to return the mouse position as a simple function .

Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Sub test()
Dim pPosition As POINTAPI
Dim lReturn As Long

lReturn = GetCursorPos(pPosition)
MsgBox "Cursor position is:" & vbCrLf & _
"x co-ordinate: " & pPosition.x & vbCrLf & _
"y co-ordinate: " & pPosition.y

End Sub

I also have some code that dynamically returns the mouse position into the
status bar. Post back if that would be useful.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Shrinu" wrote in message
m...
Hi,

I need to find out the position of a mouse at any given moment , i.e
without any event happening, is this possible. If yes ,how can i do
that. Please help me on this.
Thanks in advance.

Regards
Shrinu



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default capturing mouse positions at any moment

Hi Bob
I should have thought that you'll provide some API calls :-)
What kind of event are you using to update the satus bar? OnTime
method?

--
Regards
Frank Kabel
Frankfurt, Germany


Bob Phillips wrote:
Hi Shrinu,

Here is some code to return the mouse position as a simple function .

Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Sub test()
Dim pPosition As POINTAPI
Dim lReturn As Long

lReturn = GetCursorPos(pPosition)
MsgBox "Cursor position is:" & vbCrLf & _
"x co-ordinate: " & pPosition.x & vbCrLf & _
"y co-ordinate: " & pPosition.y

End Sub

I also have some code that dynamically returns the mouse position
into the status bar. Post back if that would be useful.


"Shrinu" wrote in message
m...
Hi,

I need to find out the position of a mouse at any given moment ,

i.e
without any event happening, is this possible. If yes ,how can i do
that. Please help me on this.
Thanks in advance.

Regards
Shrinu


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default capturing mouse positions at any moment

Hi Frank,

No I tend to eschew OnTime, and use Windows Timer and callbacks to write to
the status bar.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Frank Kabel" wrote in message
...
Hi Bob
I should have thought that you'll provide some API calls :-)
What kind of event are you using to update the satus bar? OnTime
method?

--
Regards
Frank Kabel
Frankfurt, Germany


Bob Phillips wrote:
Hi Shrinu,

Here is some code to return the mouse position as a simple function .

Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Sub test()
Dim pPosition As POINTAPI
Dim lReturn As Long

lReturn = GetCursorPos(pPosition)
MsgBox "Cursor position is:" & vbCrLf & _
"x co-ordinate: " & pPosition.x & vbCrLf & _
"y co-ordinate: " & pPosition.y

End Sub

I also have some code that dynamically returns the mouse position
into the status bar. Post back if that would be useful.


"Shrinu" wrote in message
m...
Hi,

I need to find out the position of a mouse at any given moment ,

i.e
without any event happening, is this possible. If yes ,how can i do
that. Please help me on this.
Thanks in advance.

Regards
Shrinu






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default capturing mouse positions at any moment

Be aware of 1 thing though:

When you use the coords from this api (or an office.commandbar) these
will be given with a actual screenres of 96ppi.

Excel's coordinates from say .cells(3).Left will be given with a default
of 72ppi ... more like pixels :(

this means that any coords you use to get or set directly from excel in
'POINTS' need to be multiplied by 96/72

Also Excel's coord (0.0) from say a worksheet start in the usable area
(depending on whether toolbars are docked etc)

'Get the starting point of the xlDesktop (Usable Area)
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As
Long, lpPoint As POINTAPI) As Long

dim p as pointapi
dim lhnd as long
dim lret as long
lhnd = application.hWnd 'This works for xlXP and newer
lRet = ClientToScreen(lHnd, p) 'This fills p


hth...



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Bob Phillips" wrote:

Hi Shrinu,

Here is some code to return the mouse position as a simple function .

Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Sub test()
Dim pPosition As POINTAPI
Dim lReturn As Long

lReturn = GetCursorPos(pPosition)
MsgBox "Cursor position is:" & vbCrLf & _
"x co-ordinate: " & pPosition.x & vbCrLf & _
"y co-ordinate: " & pPosition.y

End Sub

I also have some code that dynamically returns the mouse position into
the status bar. Post back if that would be useful.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine the number of weeks at this moment? Eric Excel Discussion (Misc queries) 2 September 15th 08 09:33 PM
Please take a moment to Read Totti New Users to Excel 1 December 31st 07 03:47 PM
Blonde Moment? AKJL Excel Discussion (Misc queries) 0 February 9th 07 03:28 PM
A few questions if anyone has a moment? Wally Excel Worksheet Functions 0 June 26th 05 01:57 PM


All times are GMT +1. The time now is 09:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"