KpyM Telnet/SSH Server - Forum
ALT key combo
Martin Kruse Jensen ALT key combo
 
Hi

I've purchased KpyM telnet/ssh server, and so far I'm very happy about it. My only problem is that in the one single application I need to run in a SSH terminal requires key combinations using the ALT key. Now, when i press CTRL+A i get a keystroke of the ALT key - that's neat, but what about when i need for example ALT+F9?

What do i need to do to emulate this?

Martin Kruse Jensen


Kroum Grigorov
 
Hi,

You can adjust key combinations in the ascii.ini file(I would advise you to make backup of the file before changing it).

I can suggest you 2 solutions for your problem:
1) you can predefine ctrl + l to alt_down and ctrl + t to alt_up
then for sending ALT+F9 you will need to press in your ssh client
ctrl + l ---> this will press alt key on the host
F9 ---> F9
ctrl + t ---> release alt key

you will need to change the following lines in ascii.ini file

from:
[b:d09905ce28]; ctrl + l
input11 = "0C"
key11 = "00000102 0000000C 001E0001"
[/b:d09905ce28]to:[b:d09905ce28]
; ctrl + l changed to alt_down
input11 = "0C"
key11 = "00000104 00000012 20380001"
[/b:d09905ce28]
and
from:
[b:d09905ce28]; ctrl + t
input19 = "14"
key19 = "00000102 00000014 001E0001"
[/b:d09905ce28]to:[b:d09905ce28]
; ctrl + t changed to alt_up
input19 = "14"
key19 = "00000105 00000012 c0380001"
[/b:d09905ce28]


2) if you need only few ALT + combos it would be more convinient to map ALT + combos directly to ctrl + keys.
What I mean is mapping directly ALT + F9 to ctrl + l. Thus pressing ctrl + l in your ssh client will generate ALT + F9 on the host.
You will need to change the lines in ascii.ini file
from:
[b:d09905ce28]; ctrl + l
input11 = "0C"
key11 = "00000102 0000000C 001E0001"
[/b:d09905ce28]to:[b:d09905ce28]
; ctrl + l changed to alt_down + F9 + alt_up
input11 = "0C"
key11 = "00000104 00000012 20380001 00000104 00000077 00420001 00000105 00000077 C0420001 00000105 00000012 c0380001"
[/b:d09905ce28]



You can find all F? key definitions in ascii.ini file.
Place 00000104 00000012 20380001 before the F? definition to generate alt_down and 00000105 00000012 c0380001 after to generate alt_up

Kroum


Martin Kruse Jensen ALT key combo
 
This is really making me wonder what's happening...

I've successfully mapped a key to do ALT down, F, ALT up in edit.com and that's just fine.

However, the application I need to control is Navision C5 and it just won't accept the hotkeys... Even with two mapped keys (ALT down [key] ALT up) it won't work. The application just acts as if the ALT key was not signaled at all.

I don't get it... Anyone who has an idea? Any help will be greatly appreciated!


Martin Kruse Jensen ALT key combo
 
What does those numbers mean anyway?


Kroum Grigorov
 
Hi,

Could you try to map ALT + F9 to this "numbers"
[b:bb0ed009f2]
; ctrl + l changed to alt_down + F9 + alt_up
input11 = "0C"
key11 = "00000104 00000012 60380001 00000104 00000078 20430001 00000105 00000078 e0430001 00000101 00000012 c0380001"
[/b:bb0ed009f2]

The "mystery" about the numbers is that they describe the windows messages that are sent to the program when you hit a key.

For example for alt + f9 you have.

[code:1:bb0ed009f2]
alt + f9
--------------
wm_syskeydown 00000104 00000012 60380001
wm_syskeydown 00000104 00000078 20430001
wm_syskeyup 00000105 00000078 e0430001
wm_keyup 00000101 00000012 c0380001
[/code:1:bb0ed009f2]

The catch here, is that some applications handle messages so weird, that you need to adapt the numbers for them, as is the case.

Tell me if this works for you, and all the combos you need and I will post back the changes in the config file.

Kroum


Martin Kruse Jensen
 
It didn't help either... However, I've written a Delphi program that can be used to script input (mouse, keyboard) simulation... And it works perfect with the ALT+F9 combination... Don't know if it's any use for you, but I've extracted the relevant code for sending ALT+F9... I'm using the sndkey32 library:

procedure SimulateKeyDown(MyKey: Cardinal);
var
MyInput: tagINPUT;
begin
MyInput.Itype := INPUT_KEYBOARD;
MyInput.ki.wVk := MyKey;
MyInput.ki.wScan := MapVirtualKey(MyKey, 0);
if (MyKey = VK_SHIFT) then
MyInput.ki.dwFlags := KEYEVENTF_EXTENDEDKEY
else
MyInput.ki.dwFlags := 0;
MyInput.ki.time := 0;
MyInput.ki.dwExtraInfo := 0;
SendInput(1, MyInput, SizeOf(MyInput));
end;

procedure SimulateKeyUp(MyKey: Cardinal);
var
MyInput: tagINPUT;
begin
MyInput.Itype := INPUT_KEYBOARD;
MyInput.ki.wVk := MyKey;
MyInput.ki.wScan := MapVirtualKey(MyKey, 0);
MyInput.ki.dwFlags := KEYEVENTF_KEYUP;
MyInput.ki.time := 0;
MyInput.ki.dwExtraInfo := 0;
SendInput(1, MyInput, SizeOf(MyInput));

if (MyKey = VK_SHIFT) then
begin
MyInput.ki.dwFlags := KEYEVENTF_KEYUP or KEYEVENTF_EXTENDEDKEY;
SendInput(1, MyInput, SizeOf(MyInput));
end;
end;

procedure TMainForm.parseKey(param: TStrArray; paramcnt: integer);
begin
SimulateKeyDown(VK_MENU); //Press ALT key

SimulateKeyDown(120); //Press F9 key
SimulateKeyUp(120); //Depress F9 key

SimulateKeyUp(VK_MENU); //Depress ALT key
end;

The entire source can be downloaded at l0c41://scripter.iktp.dk

Hope it helps!
Martin


Martin Kruse Jensen
 
Somewhat more readable code extract: l0c41://nomorepasting.com/paste.php?pasteID=69538


Martin Kruse Jensen
 
This wouldn't have anything to do with the service rights would it? It's running as Administrator on a Windows 2000 Server machine...


Kroum Grigorov
 
I looked at the delphi code but it is of no use.
It uses the SendInput function, which generates key strokes but doesn't target them to specific application. In that case the generated key strokes are handled by the application that holds the input focus. KTS runs as "background" service and it will definitely not have the input focus, the generated keys by the delphi code would never reach to KTS terminals.

For generating key strokes KTS uses the SendMessage function.Yesterday I spent several hours trying different combinations of messages to generate alt + f9 but with no success.

I suppose that (some) apps handle ALT+F? keys differently than normal key messages. ALT+F? messages are either translated to commands before being processed by the target window, or the apps are scaning directly the key states(for alt pressed, probably), I suppose that's why KTS messages are not processed "correctly".

I will try few more times, but I'm a bit sceptic about the results.
The more I dig on this issue, the more I feel that it is hardly likely that KTS would support ALT+F? keys.


Martin Kruse Jensen
 
Hmm, the problem seems to be that no applications at all get the WM_KEYDOWN with VK_MENU right... Wonder why...

I'm googling all over to see if I can find any solution to the problem...


Kroum Grigorov
 
Yep, the problem is that combining WM_KEYDOWN with VK_MENU doesn't work for some reason. And I can't figure out why.

I've been trying all combinations of [url=l0c41://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputmessages/wm_syskeydown.asp]WM_KEYDOWN[/url] and [url=l0c41://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputmessages/wm_syskeydown.asp]WM_SYSKEYDOWN[/url] but in vain.
I'm using [url=l0c41://www.windows-spy.com/]winspector[/url] to monitor the messages send when you press keys, and tried exactly the same message combo in KTS but no succeess either.


Martin Kruse Jensen
 
I've finally found a workarround. Not programatically unfortunately, but the application I use has a feature where you can press F1 to get a list (which is browsable by the arrow keys) of keys currently available.

Sorry I could not help solving the problem in the server software.

Martin Kruse Jensen


Kroum Grigorov
 
I'm glad to learn you solved your issue.

Kroum


Gopi
 
Handle Alt + F4 key press
in delphi


 

© 2007 - 2008 Kroum Grigorov
Powered by phpBB © 2001, 2005 phpBB Group