DosTips.com

A Forum all about DOS Batch
It is currently 31 May 2016 13:55

All times are UTC-06:00




Post new topic  Reply to topic  [ 12 posts ] 
Author Message
PostPosted: 11 Apr 2012 06:41 
Offline

Joined: 31 Mar 2012 21:31
Posts: 160
I am trying to figure any way possible (simplest is best) to send the following key combination to a Window Explorer window.

<CTRL> + <NUM+>

So... the batch file would emulate someone holding down the Control key and pressing the Plus sign in the numeric keypad at the same time.

Im pretty sure there isn't a native dos command. I am hoping someone here would have the expertise to still help. I tried VB Script "sendkeys"; however, it doesnt seem to know the difference between the two PLUS characters on an extended keyboard. At least, I couldn't figure it out. I found a somewhat free "SendKeys.exe" utility on the Internet; however, it looks like it might have some complications with licensing. I need my solution to be 100% worry-free from licensing since whatever I use is not for personal use.

Ultimately, my goal is to send this key combination to a Windows Explorer window; which will enable auto-column width. Unfortunately, this is the only way to enable this feature from command line that I know of.

Thanks in advance,
MKANET


Top
   
PostPosted: 11 Apr 2012 06:49 
Offline

Joined: 23 Dec 2011 13:59
Posts: 3057
Sounds like a job for AutoHotKey
http://www.autohotkey.com/


Top
   
PostPosted: 11 Apr 2012 06:52 
Offline

Joined: 23 Dec 2011 13:59
Posts: 3057
But it does look like you can use the + sign with Sendkeys. Did you put it in Curly Braces.
http://ss64.com/vb/sendkeys.html


Top
   
PostPosted: 11 Apr 2012 06:53 
Offline

Joined: 31 Mar 2012 21:31
Posts: 160
Thanks. Ive tried that before (in reference to AutoHotKey). From what I remember, you actually have to have the application installed on whatever machine you need to run the compiled executable. At the most, I need very very tiny executable only. Not a full blown application that needs to be installed.

Also, VBscript CAN handle plus characters; however, I said, it can't tell the difference between either PLUS characters. There are two different ones on the keyboard. I specifically need the one on the numeric keypard.


Top
   
PostPosted: 11 Apr 2012 07:06 
Offline

Joined: 23 Dec 2011 13:59
Posts: 3057
MKANET wrote:
Thanks. Ive tried that before (in reference to AutoHotKey). From what I remember, you actually have to have the application installed on whatever machine you need to run the compiled executable. At the most, I need very very tiny executable only. Not a full blown application that needs to be installed.

Also, VBscript CAN handle plus characters; however, I said, it can't tell the difference between either PLUS characters. There are two different ones on the keyboard. I specifically need the one on the numeric keypard.


Not sure if this will work with VBscript or if it is just a .NET option.
{ADD}


Top
   
PostPosted: 11 Apr 2012 07:11 
Offline

Joined: 31 Mar 2012 21:31
Posts: 160
Im actually hoping for a working example. I have already spent significant time trying to get it to work in VBScript. I'm really not that strong in VBScript.


Top
   
PostPosted: 11 Apr 2012 09:05 
Offline

Joined: 31 Mar 2012 21:31
Posts: 160
For those that know VBScript, below is my code; which produces an "Invalid procedure call or argument Line4, Char1:

Code:
Dim WshellObj   
set WshShell = WScript.CreateObject("WScript.Shell")   
WshShell.AppActivate "Logs"   
WshShell.SendKeys "^{ADD}"


Top
   
PostPosted: 11 Apr 2012 12:54 
Offline

Joined: 10 Feb 2012 02:20
Posts: 5604
MKANET wrote:
I am trying to figure any way possible (simplest is best) to send the following key combination to a Window Explorer window.

<CTRL> + <NUM+>

Ultimately, my goal is to send this key combination to a Windows Explorer window; which will enable auto-column width. Unfortunately, this is the only way to enable this feature from command line that I know of.


Just a thought - I tried this in the GUI and it only works when a filename is in focus. If the directory tree was highlited it does nothing - is that going to be an issue?


Top
   
PostPosted: 11 Apr 2012 12:58 
Offline
Expert

Joined: 22 Jan 2010 18:01
Posts: 1988
Location: Germany
Sending key strokes is not possible using batch.
If you need to work with windows scripts you could use VBScript but this will not fully emulate the keyboard. Neither is each possible key implemented nor does it work for the common computer games (the game developers know such tricks). Also the SendKeys method does not distinguish between the letters block and the num block on your keyboard.
See
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

No warranty that you can apply that to your program.
*.vbs
Code:
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "Window title exactly as displayed on the task bar"
WScript.Sleep 500
WshShell.SendKeys "^{+}"
Set WshShell = Nothing

Regards
aGerman


Top
   
PostPosted: 11 Apr 2012 13:57 
Offline

Joined: 31 Mar 2012 21:31
Posts: 160
Hi aGerman, actually the VBscript I posted earlier is the correct script (since I'm interested in the {ADD} character, not the {+}. Unfortunately, there's a bug with VBscript sendkeys that cant handle this keycombination.

I actually had to use AutoIt; which has a much better send command.


Top
   
PostPosted: 11 Apr 2012 14:03 
Offline
Expert

Joined: 22 Jan 2010 18:01
Posts: 1988
Location: Germany
That's not a bug, it's simply not supported as I already told you and as you can read at the first link.

Regards
aGerman


Top
   
PostPosted: 11 Apr 2012 15:15 
Offline

Joined: 31 Mar 2012 21:31
Posts: 160
Sorry I didnt see that you already posted "SendKeys method does not distinguish between the letters block and the num block on your keyboard." I must have misread somewhere that {ADD} was for the numeric pad Plus; and, {+} is for standard.

Either way, the issue is moot since I already have a working solution using AutoIt. I appreciate the help though.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 12 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited