Capture keyboard strokes

Started by garrmic1, August 26, 2014, 03:16:31 PM

Previous topic - Next topic

garrmic1

Hello,
  I am attempting to capture keyboard strokes on a Windows 7 machine.  I am currently using the command 'WaitForKeyEX' to watch for keys to be pressed.  I am unable to get this command to capture capital letters or anything requiring the use of the 'Shift' key.  Is there a way to capture this information with 'WaitForKeyEX' or some other command?  Here is my code (very similar to the Help file).

keycodes = "{BACKSPACE},{BS},{CLEAR},{DELETE},{DEL},{DOWN},{END},{ENTER}," ;8
;keycodes = StrCat(keycodes,"{ESC},{F1},{F2},{F3},{F4},{F5},{F6},") ;7
;keycodes = StrCat(keycodes,"{F7},{F8},{F9},{F10},{F11},{F12},{F13},{F14},") ;8
keycodes = StrCat(keycodes,"{F15},{F16},{HELP},{HOME},{INSERT},{INS},{LEFT},") ;7
keycodes = StrCat(keycodes,"{PGDN},{PGUP},{PRTSC},{RIGHT},{SPACE},{SP},{TAB},{UP},") ;8
keycodes = StrCat(keycodes,"0,1,2,3,4,5,6,7,8,9,`,-,=,[,],\,;,',.,/,");20
keycodes = StrCat(keycodes,"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,") ;26
keycodes = StrCat(keycodes,"A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z") ;26
keycodes = StrReplace(keycodes,",",@TAB)

BoxOpen("WaitForKeyEx","Press a key")
item = WaitForKeyEX(keycodes,-1)
Message (item,item)
key = ItemExtract(item,keycodes,@TAB)
BoxShut()
Message("WaitForKeyEx", StrCat("You pressed the '",key,"' key"))
Exit

Thanks
Mike.

....IFICantBYTE

Hi,
Put a plus + in front of any key you want to be detected shifted.
So, on your last key description line , make it something like:

keycodes = StrCat(keycodes,"+A,+B,+C,+D,+E,+F,+G,+H,+I,+J,+K,+L,+M,+N,+O,+P,+Q,+R,+S,+T,+U,+V,+W,+X,+Y,+Z") ;26

A plus means SHIFT ... it's all in the help file.
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)