Sign in to follow this  
Followers 0
herbgoat

Mouse Input question

8 posts in this topic

I'm new and would appreciate any help for what should be a simple question. I need my script to record the cursor position on a mouse click.

I have found the command "MouseGetPos" but I need something to go with it to tell the script to MouseGetPos when the left button is pressed.

Example...

$cursorpos = OnMouseClick MouseGetPos()

Except there seems to be no command "OnMouseClick"

Any help?

Share this post


Link to post
Share on other sites



Are you attempting to write a GUI?

if so:

#include <GuiConstants.au3>

$main = GUICreate("MyGUI", 392, 322)

$Button_1 = GUICtrlCreateButton("Button", 140, 190, 70, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_EVENT_PRIMARYDOWN
            $cursorpos = MouseGetPos()
            MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])
        case    $msg = $Button_1
            Exit
    EndSelect
WEnd
Exit

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Gary, I think he is trying to get the script to "know" whenever the user is clicking

the left mouse-button. I`m unable to help him at the moment, so couldn`t you

show him some code that uses the _IsPressed() func... ?

Edit : Of course I meant non-GUI. If I understand herbgoat correctly that is..

Edited by Helge

Share this post


Link to post
Share on other sites

I don't want to create a button. I'm writing a script that will click on a certain button on the screen (in Internet Explorer).

I have 2 problems.

1. The button will not be the same place each time depending on each individual computer due to screen size and resolution. I want to make this compatible with other people's computers.

2. The button is a graphic that changes names each time it is pressed so I can't just go off the name of the link.

I just had a thought that I can go off the name of the graphic... "next.gif"

I'll give that a shot. Thanks.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I don't want to create a button. I'm writing a script that will click on a certain button on the screen (in Internet Explorer). 

I have 2 problems.

1. The button will not be the same place each time depending on each individual computer due to screen size and resolution. I want to make this compatible with other people's computers.

2. The button is a graphic that changes names each time it is pressed so I can't just go off the name of the link.

I just had a thought that I can go off the name of the graphic... "next.gif"

I'll give that a shot. Thanks.

<{POST_SNAPBACK}>

You'll probably want to look into:

ControlGetPos ( "title", "text", controlID )

MouseClick ( "button" [, x, y [, clicks [, speed ]]] )

Not sure if that's what your looking for.

Have to go mow the lawn.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Part of the problem is that the MouseClick command makes the mouse click on the specified coordinates not wait for the user to click the mouse. I've already used MouseClick in my script for another task. The problem is I need to manually edit the program for each person's computer to define where that button is located. I would like the program to find out for itself by saying, "click on the next button now." Then you click and it remembers where that was. Then later in the program I can use MouseClick to go click that "next" button on the webpage again.

Share this post


Link to post
Share on other sites

Did you get it to work off of "next.gif"?

If not you might need to look into PixelSearch and then MouseClick from coords from that.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

I would like the program to find out for itself by saying, "click on the next button now." Then you click and it remembers where that was. Then later in the program I can use MouseClick to go click that "next" button on the webpage again.

This solution isn't ideally cosmetic but in your script you could fire up a MsgBox() that asks the user to place their mouse cursor over the button and press Enter. After the message box dismisses you could grab the mouse coordinates using MouseGetPos().

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0