Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to determine the number of weeks at this moment? | Excel Discussion (Misc queries) | |||
Please take a moment to Read | New Users to Excel | |||
Blonde Moment? | Excel Discussion (Misc queries) | |||
A few questions if anyone has a moment? | Excel Worksheet Functions |