Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to left click the mouse on the keyboard with vbscript sendkey. I've tried this code before:
 set shell = CreateObject ("Wscript.Shell")
shell.SendKeys "(numpad5)" but is not working
my left click button is numpad5. Could you help?

Edit: I want sendkey and notepad ++ with vbscript and when I press numpad5 mouse left click works 


What I have tried:

set shell = CreateObject ("Wscript.Shell")
shell.SendKeys "(numpad5)" but is not working
Posted
Updated 5-Oct-20 3:57am
Comments
Richard MacCutchan 5-Oct-20 7:30am    
What does "but is not working" mean? Please use the Improve question link above and add full details of what is happening.
Çağan Kahyaroğlu 5-Oct-20 14:06pm    
mouse erişimini açtım ve numpad5teki tuş mouse sol tık idi. sendkey ile de numpad5e komut göndermek istiyorum.dolaylı yoldan mouse sol tıkı oluyor.
Richard MacCutchan 5-Oct-20 14:37pm    
Ingilizce lutfen.
Çağan Kahyaroğlu 5-Oct-20 16:59pm    
I turned on mouse access and the button on numpad5 was mouse left click. I also want to send a numpad5 command with sendkey. The mouse is left clicked indirectly.
Dave Kreskowiak 5-Oct-20 12:40pm    
Well, that code isn't going to work at all. It seems you have some incorrect assumptions on what SendKeys does.

It does NOT assign a key to some other function. All it does is send keystrokes to whatever window has the focus. In your case, you sent the keys "( n u m p a d 5 )" to whatever window had the input focus. So the keys could have gone to a window you didn't intend, or even to nowhere!

Also, you have no way of telling the mouse to click on anything from VBScript.

1 solution

Quote:
Some special keys, such as the control keys, function keys etc are encoded in a string enclosed by {braces}

SendKeys - VBScript - SS64.com[^]
 
Share this answer
 
Comments
Çağan Kahyaroğlu 5-Oct-20 12:35pm    
all i want is a sample code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900