What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Virtual Key Code

Pages: (2): « First [ 1 ] 2 » Last »
Virtual Key Code
Author: Message:
Dan0208
Full Member
***

Avatar

Posts: 193
Reputation: 6
37 / Male / –
Joined: Dec 2003
O.P. Virtual Key Code
I am trying to write a simple script for salling clicker.
what I am trying to do is send a virtual keystroke of "fn + f4" which is a shortcut set by my laptop to change primary monitors.

I need to work out what the virtual key stroke codes for fn and f4 are.
this microsoft site is very helpful http://msdn.microsoft.com/library/default.asp?url...irtualKeyCodes.asp

as far as a know this 'fn' is not very common on keyboards and as such is a special key which is not documented on that site. so my question is does anyone know of what the keystroke resembling fn is or how I could go about finding it?

I have been googling and came up with FF but i have tried this line and its not working so maybe that key code was specific to the persons keyboard that posted it. by the way, as far as i can tell f4 is 73??

code:
SendVirtualKeystroke( 0xFF|0x73, true, false, false, false );


This post was edited on 09-24-2006 at 08:01 AM by Dan0208.
[Image: wetpix%20sig.png]
09-24-2006 08:01 AM
Profile E-Mail PM Web Find Quote Report
Mike
Elite Member
*****

Avatar
Meet the Spam Family!

Posts: 2795
Reputation: 48
32 / Male / Flag
Joined: Mar 2003
RE: Virtual Key Code
quote:
Originally posted by http://en.wikipedia.org/wiki/Fn_key
Unlike other modifier keys such as Shift or AltGr, the control processor inside the keyboard typically sends out a different keycode depending on whether the Fn key is depressed. This allows the keyboard to emulate a full sized keyboard and means that specialised keymaps do not need to be created; the operating system can use standard keymaps designed for a full sized keyboard.
That means that you will actually have to find which keystroke is sent when the Fn key is pushed... ;)
I have a laptop, so I might be able to help you...
I will research for it some more there, but right now I can't since the laptop is not here... :(

Also, check this for more information regarding the Fn key :)

This post was edited on 09-24-2006 at 08:33 AM by Mike.
YouTube closed-captions ripper (also allows you to download videos!)
09-24-2006 08:30 AM
Profile E-Mail PM Web Find Quote Report
Dan0208
Full Member
***

Avatar

Posts: 193
Reputation: 6
37 / Male / –
Joined: Dec 2003
O.P. RE: Virtual Key Code
Thanks for the reply,

yep I need to work out which keystroke is sent when its pushed but how do i do that? Is there an application that can do so?

haha funnily enough thats the site i have been reading and where i got the information about FF being the keystroke (though i cant seem to get it to work)

can anyone that knows Jscript actually confirm its the right code. i assume it is though cos it was taken from documentation from the salling clicker developer. im just not sure what all the true, falses are for...
[Image: wetpix%20sig.png]
09-24-2006 08:52 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Virtual Key Code
For extra background info, read this::
CookieRevised's reply to # key and = key

And:
http://msdn.microsoft.com/library/default.asp?url=/library/.../VirtualKeyCodes.asp
http://msdn.microsoft.com/library/default.asp?url=/library/.../wm_appcommand.asp
http://www.microsoft.com/mspress/books/sampchap/6232.asp#120
http://www.microsoft.com/whdc/device/input/w2kbd.mspx#EATAE


Finally, what you need depends on what your programming language returns or can detect, or what your destination app may detect. You have ascii codes, scan codes, key codes and virtual key codes.

This said, when you need to send something like that you do not send a keystroke (eg: <CTRL> <K>; thus 2 codes) but you send the code which makes up that keystroke (eg: <CTRL+K>; thus 1 code). The same goes for that Fn Key. You don't send the code for that, but you send the code of the F4 when Fn is pressed.

So sending 0xFF|0x73 doesn't make much sense (also '255 OR 115' will be 255 anyways). You need to send the keycode of the key F4 when the Fn key is on.

I attached a very crude virtual keycode scanner which I just slammed together. Launch it, toggle your Fn and press F4 and see what the keycode is (requires VB6 runtimes).

---------------

quote:
Originally posted by Dan0208
code:
SendVirtualKeystroke( 0xFF|0x73, true, false, false, false );
can anyone that knows Jscript actually confirm its the right code.
No, as that code is not part of JScript, but it is part of the scripting engine of salling clicker (just as the Interop stuff is part of Plus!'s addition to the JScript engine in Plus!Live).

quote:
Originally posted by Dan0208
....im just not sure what all the true, falses are for.
Isn't that also in the documentation?

Either way, there is the forum for that, search and you'll find (in fact their forum is full of threads with questions like yours) ;)

eg:
http://www.salling.com/forums/viewtopic.php?t=404...ndvirtualkeystroke
http://www.salling.com/forums/viewtopic.php?t=304...ndvirtualkeystroke

quote:
SendVirtualKeystroke(
        virtual keycode value,
        shiftState,
        ctrlState,
        altState,
        winState
);


PS: in the SVKS app the 'shift state' indicates the state of the shift keys. these are Shift, Ctrl and ALT. So don't confuse 'shift state' with the 'shiftState' of the SendVirtualKeystroke function where they actually mean the SHIFT button itself.

.zip File Attachment: SVKS.zip (3.42 KB)
This file has been downloaded 1010 time(s).

This post was edited on 09-24-2006 at 11:50 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-24-2006 10:26 AM
Profile PM Find Quote Report
Dan0208
Full Member
***

Avatar

Posts: 193
Reputation: 6
37 / Male / –
Joined: Dec 2003
O.P. RE: Virtual Key Code
Thanks cookie for your very detailed reply. I understand much more now.
I only have very basic knowledge of this but I thought i could at least try and modify another persons function for doing the alt+esc command to make mine do fn+f4.
how would i check the value of the virtual key code when those buttons are pressed at the same time? is it the information you provided in link 2? the appcommand?
if so how would i implement it? I only need to know once off what the code value is, its only a 5 line program lol.
Thanks
[Image: wetpix%20sig.png]
09-24-2006 11:44 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Virtual Key Code
reread my post, it's edited while you were posting ;)

And to add to it: Fn is not a shift state key like CTRL, ALT or SHIFT. Fn is a toggle key which maps other keycodes to the keys.

You first press Fn to toggle some keys on your keyboard (just like CAPS LOCK, or NUM LOCK does on a normal keyboard). In other words Fn is not part of the final keycode.

This post was edited on 09-24-2006 at 11:48 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-24-2006 11:45 AM
Profile PM Find Quote Report
Dan0208
Full Member
***

Avatar

Posts: 193
Reputation: 6
37 / Male / –
Joined: Dec 2003
O.P. RE: Virtual Key Code
that keycode scanner you provided works great. but one problem. It gives me info on every key i press on the keyboard EXCEPT when using the fn key in conjunction with its functions of f1 to delete key across the top.

i can get f4, or any letters etc but if i press fn by itself nothing happens. I know this is not what im meant to be getting but if i also press both at the same time to see what keycode is generated from this choice it changes my monitor to my tv like its sposed to but does not record anything on your keycode scanner :(
the same thing happens if i press fn + f7 (screen brightness down).

hmm when i first decided to do this i never though it would be such a hassle.
any other ideas?
thanks so much for all your help so far by the way

EDIT: added some more to my post to make it a bit more informative.
EDIT 2: we seem to have a habit of posting at the same time...

This post was edited on 09-24-2006 at 01:21 PM by Dan0208.
[Image: wetpix%20sig.png]
09-24-2006 01:17 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Virtual Key Code
If you don't get any virtual keycodes then there are no virtual keycodes and the chances are high the key combination is probably hard coded in the laptops hardware (and thus never send to the operating system at all).

You could try keyboard scan codes in that case, but it is not only hard to catch them, I highly doubt that scripting engine of that program can even simulate scan codes.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-24-2006 02:00 PM
Profile PM Find Quote Report
Dan0208
Full Member
***

Avatar

Posts: 193
Reputation: 6
37 / Male / –
Joined: Dec 2003
O.P. RE: Virtual Key Code
hmm ok, i think I just read that somewhere but wasnt sure what it meant or if it applied to my situation.

I think it has now gone beyond my ability. I thought it would be easier to mimmick the shortcut key to change my monitor to my tv then it seems to be. so I think I will have to leave it at that. unless there is any other methods? could I assign another shortcut that does the same thing yet doesnt use fn?

either way thanks cookie for all your help I really appreciate it.

This post was edited on 09-24-2006 at 02:20 PM by Dan0208.
[Image: wetpix%20sig.png]
09-24-2006 02:19 PM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Virtual Key Code
quote:
Originally posted by Dan0208
. unless there is any other methods? could I assign another shortcut that does the same thing yet doesnt use fn?
dunno. If it truely is a hardware combination (it's still not sure; it isn't because VB doesn't detect the virtual key, that you couldn't grab it somehow (eg: scan codes)), you have little chance in assigning another shortcut.

Unless, it can be set in the BIOS or something...
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-24-2006 09:40 PM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On