473,795 Members | 3,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mouse movements in form

15 New Member
Good morning folk,

a quick question to anyone who can help.

i am working on a program and i am using the below code to simulate mouse movement to certain
co-ords, but the thing is the co-ords 0 , 0 refer to the position at the very top left of the monitor.
what i want is for the co-ords 0 , 0 to refer to the top left in my form so the mouse clicks and
movements stay inside the form.






Here is the code:


Expand|Select|Wrap|Line Numbers
  1. Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
  2. Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
  3. Public Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
  4. Public Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
  5. Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
  6. Public Type PointAPI
  7.     x As Long
  8.     y As Long
  9. End Type
  10. Public Type RECT
  11.     Left As Long
  12.     Top As Long
  13.     Right As Long
  14.     Bottom As Long
  15. End Type
any help will be much appriciated

Thanks

Danausitn
Sep 18 '07 #1
2 1432
DanAusitn
15 New Member
do i have to set my active form as an object ? and then make the active selection my form or something ?
Sep 18 '07 #2
hariharanmca
1,977 Top Contributor
do i have to set my active form as an object ? and then make the active selection my form or something ?
i think you are looking for


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.  
  3. End Sub
In the above form mouse move event you can get form mouse X and Y position in X As Single, Y As Single parameters.
Sep 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3096
by: simo | last post by:
I'm looking to make an app to record my mouse movements and play them back. It will essentially be for unit testing websites, so I suppose it could be done using one of the wxPython MSIE ActiveX widgets, but I'd like it to work on other platforms and not just in web browsers. Anyone got any ideas for how this could be done? I guess if reading/writing mouse movements is difficult, I could limit
5
7101
by: Logan Mckinley | last post by:
I need to know where the cursor is (x,y) and when it moves even when it is not over my form. I know i can get the current location with: System.Windows.Forms.Cursor.Position.X System.Windows.Forms.Cursor.Position.X But that does not raise an event and using a timer would be to processor intensive. In MFC you would write a mousehook to solve this problem but when i run the C# MouseHook code for from MSDN...
1
1998
by: Jonny | last post by:
Hi all, Does anyone know how to capture the Windows Keys (I know that they are out of the ascii key range) and how to capture and record Mouse movements? Thanks, /Jonny
1
1687
by: John | last post by:
Hi all: I have an application that hides itself and displays an icon in the system tray. Is it possible for this application to detect keystrokes and/or mouse movements while hidden/minimized. So the application is not loaded and visible, so mouse movements on the form won't work, I need the program to be able to detect mouse movement on the system level. Thanks in advance.
1
19239
by: Benny Raymond | last post by:
In my attempt to make a macro recording program where i can then playback mouse movements i'm running into a big problem: I'm trying to simulate the movement of the mouse to a point on the screen. With my current code the mouse is only moving in the X direction and not in the Y direction (however my debug line is telling me that it's trying to move in the Y as well). I've read everything I could find online, tried some hacky ways of...
2
2351
by: Klaus Jensen | last post by:
Hi! I need an ASP.net control, which makes it possible for the user to define imagemaps. I show an image, the user can define areas (polygons would be nice, but just rectangles is ok), and I can access these areas, save them and use them to generate imagemaps. It is to be used with maps, where the client can add information to areas of
3
34831
by: madhuri.eerupula | last post by:
Hi. How to simulate(automatic) mouse movements and click operation using c#. Actually, i got pixels in the face (face tracking) right now and i need to move mouse(automatically, without using mouse manually) i.e., simulate mouse click operation using those pixels in c#. I think we can use robot() class in java , to achieve this, but how can we do this using c#. Hope you understand my problem and get bck to me asap. thanx bye
2
4787
by: bryan rasmussen | last post by:
Hi, I've been looking at autohotkey to do some different usability hacks for windows http://www.autohotkey.com/ one of the benefits of this language is it allows one to catch keyboard usage, joystick usage, and mouse usage inputs very easily at a global level or at application levels by watching applications for events within the applications. I was wondering if there were any python libraries that provided
6
3118
by: c.k. | last post by:
I was wondering if there was a way to give mouse movement on an empty form some lag/delay? For instance, user moves mouse, and the cursor is 20ms (possible adjustable from some option) behind the movement. So when user stops moving mouse, 20ms later the cursor itself stops moving... I tried using: Windows.Forms.Cursor.Current.Position = New System.Drawing.Point(x,y) and forms of sleep/timer events but cant seem to get it to work...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10437
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.