SRL Archive - General Botting Help

Need help with ascii char keypress


Suisyola

2015-01-05 21:54:00

Hi everyone. I'm using Simba to automate some tasks. I need to do a PressKey with print_screen modified by ctrl.

At first I thought doing the following would basically work
KeyDown((ascii dec.)ctrl)
PressKey((ascii dec.)Print_screen)
KeyUp((ascii dec)ctrl)

but there isn't an ascii code for ctrl since it is a modifier. I've tried looking up solutions in other languages but there really isn't much about throwing a modified keypress. Plenty on checking keyEvents thrown for a modifier though.

Does anyone have a solution? I really want to have Simba automate a Ctrl+Print_Screen key press.

Any help is greatly appreciated.

Frement

2015-01-05 21:58:48

vk_control	17
vk_printscreen 154

Taric

2015-01-05 22:38:08

Google searches are op :p,
If you need more than those two keys have this table:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx

i luffs yeww

2015-01-05 23:46:00

From: pizzapants
Google searches are op :p,
If you need more than those two keys have this table:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx


While Google is helpful, the link to the MSDN about virtual key codes isn't relevant to the question asked. Simba does not follow Microsoft's scheme for VK codes. You can't assume that either the name or hex representation is correct to use for Simba. You should use the VK_* variables for Simba.

Brandon

2015-01-06 02:46:36

From: i luffs yeww
While Google is helpful, the link to the MSDN about virtual key codes isn't relevant to the question asked. Simba does not follow Microsoft's scheme for VK codes. You can't assume that either the name or hex representation is correct to use for Simba. You should use the VK_* variables for Simba.



This is incorrect. Simba does follow the Virtual Key codes for all ASCII codes:


http://docs.villavu.com/simba/scriptref/mouseandkeyboard.html#keyboard-virtual-keys compared to: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx


Exact same. It is SMART that does not follow all the ASCII codes: https://github.com/BenLand100/SMART/issues/7

IIRC, it's only the enter key that is different: https://github.com/BenLand100/SMART/blob/master/src/EventNazi.java#L431


SRL takes care of it by using a compiler directive with key functions to determine which keys to use: https://github.com/SRL/SRL-6/blob/master/lib/core/text.simba#L221

So there's no confusion.

@Olly; I'm tagging you so you can fix it.. Whoever re-wrote SRL-6 messed up one function: https://github.com/SRL/SRL-6/blob/master/lib/core/text.simba#L251

which uses KeyDown explicitly.. It does not use the directive and so, it won't work for the Return-Key if using SMART.

Suisyola

2015-01-06 14:09:47

Thank you everyone. I've got it working now. Lots of awesome info!

i luffs yeww

2015-01-06 18:36:39

From: Brandon
This is incorrect. Simba does follow the Virtual Key codes for all ASCII codes:


http://docs.villavu.com/simba/scriptref/mouseandkeyboard.html#keyboard-virtual-keys compared to: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx


Exact same. It is SMART that does not follow all the ASCII codes: https://github.com/BenLand100/SMART/issues/7

IIRC, it's only the enter key that is different: https://github.com/BenLand100/SMART/blob/master/src/EventNazi.java#L431


SRL takes care of it by using a compiler directive with key functions to determine which keys to use: https://github.com/SRL/SRL-6/blob/master/lib/core/text.simba#L221

So there's no confusion.

@Olly; I'm tagging you so you can fix it.. Whoever re-wrote SRL-6 messed up one function: https://github.com/SRL/SRL-6/blob/master/lib/core/text.simba#L251

which uses KeyDown explicitly.. It does not use the directive and so, it won't work for the Return-Key if using SMART.


My mistake. I was going off of what Frement said was the code for print screen, but he must have had a typo. I assumed they were different because his "vk_printscreen: 154" information didn't match with what I thought it should've been. For one, there is nothing assigned to 0x9A, and there is no virtual key called "printscreen."

Sorry.

Brandon

2015-01-06 21:11:03

From: i luffs yeww
There is no virtual key called "printscreen." You should use the VK_* variables for Simba.



Ahh just a mistake. No harm done. However:

MSDN:
VK_SNAPSHOT: 0x2C -> 44

SIMBA:
SNAPSHOT: 44 -> 0x2C

You're right OP should use the VK keycodes instead of guessing the numbers.

i luffs yeww

2015-01-06 23:56:09

From: Brandon
Ahh just a mistake. No harm done. However:

MSDN:
VK_SNAPSHOT: 0x2C -> 44

SIMBA:
SNAPSHOT: 44 -> 0x2C

You're right OP should use the VK keycodes instead of guessing the numbers.


I know that it's called snapshot ;) I just meant there is literally no constant with the name "VK_PrintScreen" as suggested by Frement. I asked him about it and he told me that those are actually Java constants.

Dmox

2015-05-16 00:59:45

From: Brandon
This is incorrect. Simba does follow the Virtual Key codes for all ASCII codes:


http://docs.villavu.com/simba/scriptref/mouseandkeyboard.html#keyboard-virtual-keys compared to: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx


Exact same. It is SMART that does not follow all the ASCII codes: https://github.com/BenLand100/SMART/issues/7

IIRC, it's only the enter key that is different: https://github.com/BenLand100/SMART/blob/master/src/EventNazi.java#L431


SRL takes care of it by using a compiler directive with key functions to determine which keys to use: https://github.com/SRL/SRL-6/blob/master/lib/core/text.simba#L221

So there's no confusion.

@Olly; I'm tagging you so you can fix it.. Whoever re-wrote SRL-6 messed up one function: https://github.com/SRL/SRL-6/blob/master/lib/core/text.simba#L251

which uses KeyDown explicitly.. It does not use the directive and so, it won't work for the Return-Key if using SMART.



@Brandon Sorry for bumping this old thread but if I am doing this right, this still isn't fixed. I can't get my script to press down the enter key.. What number or word am I supposed to use in the KeyDown(); function?

I am able to use the arrow keys so I know it's not something on my end.

woo hoo

2015-05-16 01:09:31

From: Dmox
@Brandon Sorry for bumping this old thread but if I am doing this right, this still isn't fixed. I can't get my script to press down the enter key.. What number or word am I supposed to use in the KeyDown(); function?

I am able to use the arrow keys so I know it's not something on my end.


I tried "vk_return" and it worked on a notepad.

Dmox

2015-05-16 13:02:08

From: woo hoo
I tried "vk_return" and it worked on a notepad.


Yeah it is sending the key because I tested to see if it's sending the key by using "if isKeyDown(vk_return) then WriteLn('Enter is down')", but for some reason the SMART client won't receive the enter key. It will receive other keys but not the enter one..