Sign in to follow this  
Followers 0
RGBreality

Having problem using the "Mousetrap" function

6 posts in this topic

Hey, folks!

I'm having a challenging time using the "Mousetrap" function. I keep getting a syntax error. I'm sure it's something silly I'm doing.

In this script, I have declared two variables which represent the X and Y coordinates I want the mouse to be trapped.

Dim $iLeft
Dim $iTop

Later in the script I try to use the Mousetrap function.

_MouseTrap([$iLeft = 280 [, $iTop = 34 ]])

But I receive syntax errors. What might I be doing wrong?

Here is the script in its entirety, if it should help.

Opt("WinWaitDelay",1)
Opt("WinTitleMatchMode",2)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
Dim $iLeft
Dim $iTop
WinWait("Supervisor - Ultimus Client","")
If Not WinActive("Supervisor - Ultimus Client","") Then WinActivate("Supervisor - Ultimus Client","")
WinWaitActive("Supervisor - Ultimus Client","")
MouseMove(27,19)
MouseDown("left")
MouseMove(27,20)
MouseUp("left")
MouseMove(280,34)
_MouseTrap([$iLeft = 280 [, $iTop = 34 ]])
Send("{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")
WinWait("Change Server","localhost")
If Not WinActive("Change Server","localhost") Then WinActivate("Change Server","localhost")
WinWaitActive("Change Server","localhost")
Send("{TAB}{TAB}{TAB}{ENTER}")
WinWaitActive("Ultimus Client","")
If Not WinActive("Ultimus Client","") Then WinWait("Ultimus Client","")
WinWaitActive("Ultimus Client","")
MouseDown("left")
MouseUp("left")
Send("{ALTDOWN}n{ALTUP}")
WinWaitActive("Ultimus Client - Login","| Version 8.2 |")
If Not WinActive("Ultimus Client - Login","| Version 8.2 |") Then WinActivate("Ultimus Client - Login","| Version 8.2 |")
WinWaitActive("Ultimus Client - Login","| Version 8.2 |")
Send("{DEL}")

Thank you very much for your assistance!

Most graciously,

RGBreality

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Remove the square brackets ([ ]) from the _MouseTrap parameters.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Hey, thanks for your reply!

I still seem to have a problem. I changed the Mousetrap function to read:

_MouseTrap($iLeft = 280, $iTop = 34)

But upon building the script, I receive this error:

ERROR: _MouseTrap(): undefined function.

_MouseTrap($iLeft = 280, $iTop = 34)

Did I follow your suggestion correctly?

Thank you again!

Most graciously...

RGBreality

Share this post


Link to post
Share on other sites

at the top of your file add

#Include <Misc.au3>

Share this post


Link to post
Share on other sites

Ah, thanks, Tomb! That did the trick!

So, what does the "#Include <Misc.au3>" function do? Does it include another script inside mine? Or does it merely reference the Misc.au3 script to learn what the Mousetrap function does?

Thank you again for your help!

Most graciously...

RGBreality

Share this post


Link to post
Share on other sites

 

Does it include another script inside mine?

Yes. The "light blue" functions (if you use Scite) with a prefixed underscore are not in "native" code. They are not executable by a standalone AutoIt.exe like the "dark blue" functions. These "light blue" functions are written in AutoIt-code. You can found many of them in the helpfile, after pressing F1 in Scite. :blink:  

If you want to use these functions in one of your scripts, you have to insert ("#include") them into your code. Many functions on a subject are grouped together in a so called UDF (UserDefinedFunction)-file. An UDF is a collection of functions. With one line of code "#include <collection.au3>" you have access to every function in this collection.  

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