Link to home
Start Free TrialLog in
Avatar of vbark
vbark

asked on

SetCursorPosition using VBScript dll compile

Hello

What I want to do is set the cursor position using VBScript, I understand the way to do tis is by creating a dll then calling then accessing the DLL.

I don't have a VB or DLL Compiler, ideally if someone could show me what to put in the dll and reccomnd a decent free compiler or send me the compliled dll with the vbs calls.

Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long

Many Thanks
deangrahamnz@yahoo.co.uk
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Hello vbark,

you could download the dll from
source: http://www.traktiq.net/ee_temp/CURSOR.dll

the instruction how to use it can be found in
https://www.experts-exchange.com/questions/21120178/How-to-get-the-x-and-y-coordinates-of-the-cursor.html

--------------
Dim POS
Set POS = Wscript.CreateObject("CURSOR.POSITION")
Wscript.echo "Position of X =" & POS.X
Wscript.echo "Position of Y =" & POS.Y
Set POS = Nothing
--------------

unfortunately don't know of a free compiler for activex dlls, microsoft used to make one available but that is years ago

hope this helps a bit
bruintje
Avatar of vbark
vbark

ASKER

Hi there,

What that appears to do is get the cursor position, what I want to do is set it, so make the cursor move to a point on the screen defined by me.

but otherwise that is exaclty what I am after.
ok misread that you can download a new version from the ur above

also made the code available in a zip
http://www.traktiq.net/ee_temp/cursor.zip

used the source here for the setposition class in the same dll
http://www.vbaccelerator.com/home/VB/Tips/Moving_and_Tracking_the_MousePointer_in_Code/article.asp

all the class code for the setposition is coming from that snippet

the vbs code to set the position is
-----------
Dim POS
Set POS = Wscript.CreateObject("CURSOR.SetPosition")
POS.MoveTo 640, 480
POS.MoveTo 200, 480
-----------

think you even have a bonus by being able to click with the mouse but have not tested that
Avatar of vbark

ASKER

Thanks bruintje,

Any chance of getting that as a dll, I don't have VB on this machine.

Avatar of vbark

ASKER

Sorry this time it was me who mis-read.

I put that cursor in system32 folder and tried the vbs script but got the error

Error:      Could not locate automation class named "CURSOR.SetPosition".

Any Ideas

ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vbark

ASKER

That's what I hadn't done, many thanks for your help.

glad it works now

thanks for the grade, makes me wizard in VB :)