View unanswered posts | View active topics It is currently 24 Apr 2014 18:08



Post new topic Reply to topic  [ 12 posts ] 
Send key combination to a window title 
Author Message

Joined: 31 Mar 2012 21:31
Posts: 160
Post Send key combination to a window title
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


11 Apr 2012 06:41
Profile

Joined: 23 Dec 2011 13:59
Posts: 1557
Post Re: Send key combination to a window title
Sounds like a job for AutoHotKey
http://www.autohotkey.com/


11 Apr 2012 06:49
Profile

Joined: 23 Dec 2011 13:59
Posts: 1557
Post Re: Send key combination to a window title
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


11 Apr 2012 06:52
Profile

Joined: 31 Mar 2012 21:31
Posts: 160
Post Re: Send key combination to a window title
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.


11 Apr 2012 06:53
Profile

Joined: 23 Dec 2011 13:59
Posts: 1557
Post Re: Send key combination to a window title
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}


11 Apr 2012 07:06
Profile

Joined: 31 Mar 2012 21:31
Posts: 160
Post Re: Send key combination to a window title
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.


11 Apr 2012 07:11
Profile

Joined: 31 Mar 2012 21:31
Posts: 160
Post Re: Send key combination to a window title
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}"


11 Apr 2012 09:05
Profile

Joined: 10 Feb 2012 02:20
Posts: 3675
Post Re: Send key combination to a window title
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?


11 Apr 2012 12:54
Profile
Expert

Joined: 22 Jan 2010 18:01
Posts: 1700
Location: Germany
Post Re: Send key combination to a window title
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


11 Apr 2012 12:58
Profile

Joined: 31 Mar 2012 21:31
Posts: 160
Post Re: Send key combination to a window title
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.


11 Apr 2012 13:57
Profile
Expert

Joined: 22 Jan 2010 18:01
Posts: 1700
Location: Germany
Post Re: Send key combination to a window title
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


11 Apr 2012 14:03
Profile

Joined: 31 Mar 2012 21:31
Posts: 160
Post Re: Send key combination to a window title
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.


11 Apr 2012 15:15
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 


Who is online

Users browsing this forum: Bing [Bot], garysegal, Google [Bot] and 7 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 © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.