Re: move mouse
- From: mr_unreliable <kindlyReplyToNewsgroup@xxxxxxxxxxx>
- Date: Tue, 22 Jul 2008 13:42:23 -0400
Mike Brearley wrote:
Is there a way in VBScript to move the mouse to a specific screen location and perform a mouse button action?hi Mike,
I see "krazymike" suggesting that you call the "SetCursorPos"
api to move the mouse. This is assuming that you can declare
and call api's from script -- and declaring-and-calling api's
from script is something that is _NOT_ built into the wsh/vbs
language (at least the wsh/vbs language that I'm familiar with).
You can call api's from script, but only if you are willing to
use a third-party object to do it. One such third-party object
is DynaWrap (see "boilerplate" below.
If you wish to do A LOT of calling api's, then I would suggest
that you use some other scripting language that allows for calling
api's directly. Here are a couple:
I used to also recommend autoit3, but since they dropped support
of win98 (my os of choice), I have stopped recommending them.
You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
--- <DynaWrap Boilerplate> ---
It is possible to declare-and-call an api from script,
but you must use a third-party control to do so,
or else write one yourself.
It has already been correctly pointed out that there
is no api-capability in "pure" script.
If you are willing to use a third-party control, then
one such control, called "DynaWrap", can be found on
Guenter Born's website (note: Guenter refers to it as
"DynaCall"). Here is the link to it:
- or -
On that page you will find a download for the control,
plus some code samples.
Note: you may find additional sample code by searching
the archives of the wsh and vbscript ng's.
Note also: DynaWrap does have its limitations. There are
certain things it can't do. For example, you can't call
api's "by ordinal". (I had previously asserted that you
can't use DynaWrap to call api's which take typedefs as
parameters, but I have been proven wrong on that --
although it took me about two weeks to figure out how it
was done). Regardless, Dynawrap will work for most of
"the usual suspects".
And finally, DynaWrap doesn't work entirely as advertised.
For example, it is supposed to allow for the declaration of
several api definitions in one instance of itself. I could
never get that to work (in win9x -- but others have shown
this to work as advertised under winNT). With win98, you
will need a new instance of DynaWrap for every api, or else
re-instantiate the object for every api. Someday I'm going
to learn enough c++ to fix that...
Another possibility (for calling api's from script is XNeat:
One other thing. While the above discussion is oriented to
calling the system api's, contained in the user32, kernel32,
gdi32 and other system dll's, you could use DynaWrap (and
other similiar utilities) to call the exported interfaces
to ANY dll.
--- </DynaWrap Boilerplate> ---
- move mouse
- From: Mike Brearley
- move mouse