Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse Training

Status
Not open for further replies.

spelltwister

Programmer
May 12, 2005
36
US
Hello, I have been trying for quite a while, without any leads as to how to train the mouse. By this, I mean I want the computer to prompt the user to click on a part of the screen. It will then grab the mouse coordinates and store them somewhere for later use. Then it will prompt them for another click, and store that mouse click for later. After seven clicks, I have macro code finished, but there are clicks on element trees and such that do no have a way to be directly referenced. That's what the user will be clicking on. They will select where each part is that is needed, the macro will turn on and off the different elements of the tree and run tests with the different elements on and off. Any help appreciated!
 
System.Windows.Forms.Cursor.Current.Position

to replicate the users movements with the mouse you may want to consider catching the mouse position every 1/10th of a second or so.

with this method, when you play back the recorded "script" of user behaviour you won't get things jumping about all over the place with no indication as to what may be clicked on next
 
Hi, Thanks for your reply, but that's not quite what I want. I know how to find the mouse position, but what I'm looking for is a script that will wait for the user to click on seven parts of the screen, and store just those places for use. Then, after the user clicks, I have a script that will do the rest without them needing to be there, so it doesn't matter what the screen does. Thanks again, and I hope I've cleared up the confusion. :-D
 
In other words you only want to store the clicked location? Get the mouse position from inside the Mouse.Down event.
 
The type of thing your after is what user interface testing software does (such as Vermont HighTest which isn't in the league of the expensive ones but does the job very well).

If you're simply getting seven clicks then going on to something else then you'll probably be better off creating the application yourself.

 
Code:
Imports System.Windows.Forms
    
    [COLOR=green]'Your variables[/color]
    Dim myIndex = 0
    Dim myXArray()
    Dim myYArray()

    [COLOR=green]'Catch the cursor position as the useer clicks the screen[/color]
    Private Sub Form1_[b]MouseDown[/b](ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        ReDim myXArray(myIndex)
        myXArray(myIndex) = Cursor.Position.X()
        ReDim myYArray(myIndex)
        myYArray(myIndex) = Cursor.Position.Y()
        myIndex = myIndex + 1
    End Sub
 
thanks much for the help. I think I need to explain my situation a little better. I am using a program called TestComplete to create macros for the company I work for. I am not using a form (otherwise this would be really easy), instead, the macro opens up the software I am testing and manipulates it. The problem is that there is no way to reference where the element tree is unless the user first selects the seven elements that are to be toggled during the running of the application. I do not know if there is a command similar to "on" like in FLASH or JavaScript, where I'd say "on Sys.MouseDown(1,"*","*")" and how to actually make those astericks work as a wild card. The syntax for this command is Sys.MouseDown(which click, x pos, y pos). Since I do not know where the mouse is, I would like it to work for all positions and store it. I hope there is someway of actually getting this to work and I really appreicate all the help. Thanks.
 
Now I am very puzzled....can you try and explain what this has to do with VB.Net?

When I first saw the subject about Mouse Training, I was so tempted to suggest a little metal cage, and an excercise wheel, but thats just my childish side coming out again, and anyway I wasnt sure exactly which event the mouse would be training for.


Sweep
...if it works dont mess with it
 
I think I understand what he wants, but I'm not sure I know how to do it.

Basicly, he wants his .Net app to sit in the background and record mouse movements and clicks. Most specificly, the mouse position when it is clicked.

I'm assuming that later he will want to "replay" the recorded macro and send mouse clicks at the recorded locations.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Do you think he wants to record mouse "droppings" from an application other than the one the user is exercizing the mouse on?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top