herbgoat Posted July 9, 2005 Share Posted July 9, 2005 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? Link to comment Share on other sites More sharing options...
GaryFrost Posted July 9, 2005 Share Posted July 9, 2005 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. Link to comment Share on other sites More sharing options...
Helge Posted July 9, 2005 Share Posted July 9, 2005 (edited) Gary, I think he is trying to get the script to "know" whenever the user is clickingthe left mouse-button. I`m unable to help him at the moment, so couldn`t youshow him some code that uses the _IsPressed() func... ?Edit : Of course I meant non-GUI. If I understand herbgoat correctly that is.. Edited July 9, 2005 by Helge Link to comment Share on other sites More sharing options...
herbgoat Posted July 9, 2005 Author Share Posted July 9, 2005 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. Link to comment Share on other sites More sharing options...
GaryFrost Posted July 9, 2005 Share Posted July 9, 2005 (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 July 9, 2005 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. Link to comment Share on other sites More sharing options...
herbgoat Posted July 9, 2005 Author Share Posted July 9, 2005 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. Link to comment Share on other sites More sharing options...
GaryFrost Posted July 9, 2005 Share Posted July 9, 2005 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. Link to comment Share on other sites More sharing options...
LxP Posted July 10, 2005 Share Posted July 10, 2005 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(). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now