How to Move the mouse using VBScript - vbscript

I am trying to move the mouse using VBScript. I tried to use Sendkeys "{CLICK LEFT , x , y}" and Sendkeys "{MOVETO, 10 , 20}" but it isn't working i also tried to use MouseKeys, so i could move it with the keyboard and therefore use Sendkeys to activate it but it also did not work (the mousekeys numpad is not moving the mouse). I've tried everything I know and what i could research elsewhere, so now I hope one of you can answer this for me. thxs

One possible way to move the mouse is:
Dim Excel: Set Excel = WScript.CreateObject("Excel.Application")
Excel.ExecuteExcel4Macro "CALL(""user32"",""SetCursorPos"",""JJJ"",""xxx"",""yyy"")"
-->xxx = X Position
| yyy = y Position
The only disadvantage is that you need Microsoft Excel to run this script...
Hope I could help you

VBScript can't do this natively. You'd have to do some calls to the Windows API or some other library that can do this for you.
As an alternative, you may want to consider a different scripting language, like AutoHotKey which can do this in one simple line of code for you.

Related

There is another way do Copy and Paste in VBS or BAT?

I was trying to automatize some repeated fill forms that I do in my job. I automate a lot of in VBA Excel, and I wanted to do with VBS too, but the company's computer doesn't work "^{C}", eather "%{TAB}".
In resume, ALT + or CTRL+ doesn't has the common response and a lot of functions are blocked...
There is another way to Change Window and Copy/Paste?
I found the problem:
.vbs has a lot of bugs in the blocked computer.
Ctrl + C or V works better as lower case: "^{c}" & "^{v}"
And the % + something doesn't work in any way.
So worked like this way for me:
Dim WS
set WS = CreateObject("WScript.Shell")
WS.AppActivate "Protocolos - Internet Explorer" ' name of the sheet
CScript.Sleep 100
WS.SendKeys "^{c}"
CScript.Quit

How to show hexdecimal view of integers in Clion and PyCharm?

I found this help https://www.jetbrains.com/help/clion/using-hexadecimal-view.html
but it relies on long keystroke to call maintenance popup, which is probably not working on my machine (a lot of keystrokes not working).
Is it possible to call this setting w/o keystroke?
I'm using the following trick. In the Variables view add ".hex()" for bytearray
You can call Help | Find Action (or press double Shift) and search for 'Maintenance'.

SEND clip as keystrokes

I am just wondering if there is any way in manner of PSH or VBS to paste/SEND the text from clipboard as separate keystrokes rather then string????
It is VERY important, since I have to do some automatic search in web UI drop down lists and passing text by CTRL+V simply does not work. So I need to send each letter as unique keystrokes.
Tried to find some way and searched over the Internet but no luck.
Thank you in advance
There are a few ways to interact with the clipboard in VBScript. Here's one way to read clipboard text:
strText = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")
Once you have the text, you could simply send each letter in sequence:
For i = 1 To Len(strText)
SendKeys Mid(strText, i, 1)
Next

Send windows key in vbs?

I've looked everywhere for this, is it actually possible to do? If you press WIN + LEFT ARROW it will mount your selected window to the left of your screen, and that's exactly what I'm trying to do.
I have tried things like:
shl.sendkeys "#{LEFT}"
Because I found out that # could be for WIN just like + is for Shift and % is for Alt.
This may be a stupid question but it would help me out so much. Thank you for you time
Set Keys = CreateObject("WScript.Shell")
Keys.SendKeys("^{Esc}")
This should work, it Simulates the push of the Windows key by pushing the CTRL ^ and the ESC {Esc}keys, i don't know how to make the window mount to the left of the screen
VBScript's SendKeys doesn't support the Windows key.
You can use AutoIt instead:
Send("{#Left}")
Oh, so you want to mount the window to the left, I currently don't think there's a way to do that, but there's another shortcut for start menu, as well as windows key, it's Ctrl+Esc, ^{ESC}, you could possibly run the onscreen keyboard, then somehow tab over to the key, but it would be hard, also how about trying Alt+Space, %{SPACE}, to click the window icon then, M for move, then set the cursors position to the left of the screen, somehow? I don't currently need help moving the cursor in V.B.S., but you could Google it. Hash symbol is actually typing the symbol #, hash, tested with this. I also got help on the send-keys function, here. I have way to much researching, but I still can't find a answer. Some-one also said using "Auto hotkey", a third party program, but I don't really trust programs that can take control over your whole PC.
So I guess your options are:
Alt+Space to click window icon, then M for move, then move cursor to left side of the screen
Auto HotKey, although I don't recommend it.
Other commands, but SendKeys, in VBS,
Running a file, built in a different language to do so.
Or well, waiting-for / asking Microsoft to add it in, in the next version of Windows?!
a very late response, but here is my working effort
Dim shellObject : Set shellObject = CreateObject("WScript.Shell")
Extern.Declare micVoid, "keybd_event", "user32.dll", "keybd_event", micByte, micByte, micLong, micLong
Const KEYEVENTF_KEYUP = &H2
Const VK_LWIN = &H5B
Wait 5
Call Extern.keybd_event(VK_LWIN,0,0,0) 'press win key
Wait 5
shellObject.SendKeys "({UP})" 'right aline the window. TODO Error handlng
Wait 5
Call Extern.keybd_event(VK_LWIN,0,KEYEVENTF_KEYUP,0) 'up win key
Set shellObject = Nothing
try this
wshshell.sendkeys "{lwin}"

Batch file to set the position of the curser on windows 7 OS. How?

is it possible to make a batch file that sets the position of the mouse/curser to an (x,y) coordinate on the screen? and if so, then is it possible to click on something that is in that position? Any ideas would be helpful! Thanks!
No. You would have to have a seperate executable to do this for you.
It may be possible in VBScript.
P.S. If you're interesting in automating tasks I'd download something like a mouse recorder for something simple like that. If you're automating more complicated tasks, give a shot at Autoit.
No and Yes.
You can't place the cursor at Position X,Y with pure batch, but you can replace the cursor to the home position in one line, and then you can rewrite the content.
For detecting mouse clicks with batch you need an external tool.
Try a look at Lingubender Tan's Batch tools
EDIT: You can place the cursor with pure batch to the home postion, but I need the help of the user, till now.

Resources