Simple code for mouse positionning.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rachadleb
Posts: 2
Joined: 31 Oct 2012 05:24

Simple code for mouse positionning.

#1 Post by rachadleb » 31 Oct 2012 05:42

Hello everyone, I'm new here and I'm looking for a little help.

I need a simple bat code that will automatically change the position of the mouse to any corner of the screen (or extremity) every time the user logs in.

The idea is that users (on my network) are not allowed to use the mouse. And its positioning in the middle of the screen makes the reading of certain information sometimes hard (mouse gets in the way).

So that's it, a simple bat code to automatically reposition the mouse after logging.

Much appreciated and thank you for your time and help.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Simple code for mouse positionning.

#2 Post by foxidrive » 31 Oct 2012 05:59

Can you use third party programs on the servers?

You might have to use one to reposition the mouse, or maybe a VBS script can do it - if you have Windows Scripting Host enabled on the server.

Plain vanilla batch can't do it, but may be able to help with a tool.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Simple code for mouse positionning.

#3 Post by abc0502 » 31 Oct 2012 06:00

a vbscript here can do this.
it will need a small adjustment to make it move to the corner and require Excel

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Simple code for mouse positionning.

#4 Post by abc0502 » 31 Oct 2012 06:03

I modified it it will move the mouse to the left top corner

Code Editied
Option Explicit
Dim Excel, GetMessagePos, x, y, Count, Position

Set Excel = Wscript.CreateObject("Excel.Application")
GetMessagePos = excel.ExecuteExcel4Macro("CALL(""user32"",""GetMessagePos"",""J"")")

x = CLng("&H" & Right(Hex(GetMessagePos), 4))
y = CLng("&H" & Left(Hex(GetMessagePos), (Len(Hex(GetMessagePos)) - 4)))
Position = "- 600"
Excel.ExecuteExcel4Macro("CALL(""user32"",""SetCursorPos"",""JJJ""," & x & " " & Position & "," & y & " " & Position & ")")


foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Simple code for mouse positionning.

#5 Post by foxidrive » 31 Oct 2012 06:10

http://www.nirsoft.net/utils/nircmd2.html

Setcursor at that page is a free tool your sysadmin can use to set the cursor position.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Simple code for mouse positionning.

#6 Post by Ed Dyreen » 31 Oct 2012 06:16

rachadleb wrote:I need a simple bat code that will automatically change the position of the mouse to any corner of the screen (or extremity) every time the user logs in.

Code: Select all

@rundll32.exe user32.dll,SetCursorPos
http://www.dostips.com/forum/viewtopic.php?p=13236#p13236

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Simple code for mouse positionning.

#7 Post by foxidrive » 31 Oct 2012 06:33

Ed Dyreen wrote:

Code: Select all

@rundll32.exe user32.dll,SetCursorPos


Good one Ed. It works in Win 7 too.

rachadleb
Posts: 2
Joined: 31 Oct 2012 05:24

Re: Simple code for mouse positionning.

#8 Post by rachadleb » 31 Oct 2012 07:20

I'm sorry I wasn't available, i was working on site.
Many thanks to everyone that answered this post and especially for Ed that gave the most simple and efficient solution.
I will implement it shortly.
It's good to see that forums still can handle requests one can't find on Google!

Again, to all that took the time to respond, my sincere gratitude.

Post Reply