Jump to content

Recorder Mouse Location vs Control


 Share

Recommended Posts

Greetings,

I am testing out AutoIt and would like to 'duplicate' the following script using the a recorder.

; Script Start - Add your code below here
Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "Do you want to save")
ControlClick("Notepad", "Do you want to save", 6)
WinWaitActive("Save As", "")
ControlSetText("Save As", "", 1148, "test.txt")
ControlClick("Save As", "", "[TEXT:&Save]")

; WinWaitActive("Save As", "Do you want to replace")
If WinWaitActive("Save As", "Do you want to replace", 1) Then
    ControlClick("Save As", "Do you want to replace", "[TEXT:&Yes]")
EndIf

I've tried both the Au3Recorder and the MacroGenerator. The Au3Recorder works fine, but it uses x,y coordinates for mouse clicks and this will break down on other users computers or even if the Notepad window opens in a different location. I understand the MacroGenerator uses control names rather than x,y coordinates, but it seems to get confused by the Start | Run action.

Is there a configuration/option for the Au3Recorder to support control names?

As a newbie am I missing something with the MacroGenerator?

Thanks,

Matt

Link to comment
Share on other sites

What do you mean by confused?

As for the x and y thing you could always add WinGetPos() to the coordinates as a variable so that it clicks the right spot regardless of the windows position. Or you could add a WinMove() early in the script so that it's always in the right spot.

Example of the first thing:

$offset = WinGetPos("Untitled - Notepad")
MouseClick("left", 300 + $offset[0], 300 + $offset[1])
Link to comment
Share on other sites

When I use the MacroGenerator the result script stalls at the first step; when I record Start Menu <click> | Run <click>. It never clicks the 'Run' box. Same computer, same resolution, etc.

If I add a "WinMove" then how do I actually record the script? Make sure mouse is in the same location everytime I hit record?

With any coordinates, what happens when I run the script on a computer with different resolution?

It seems to me the Recorder should record Window title and ControlId or ControlClassNN, not x, y coordinates.

Thanks,

Matt

Link to comment
Share on other sites

  • 5 months later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...