PDA

View Full Version : Can you send a spacebar key in vb.net?



Soredavide
02-26-2016, 01:24 PM
I am trying to send the spacebar key to a flash object, this was very easy in VB6. I have tried SendKeys.Send(Keys.Space), SendKeys.Send(" ") and SendKeys.Send("{SPACE}"). I am not sure why they are not working, does anybody know how to send the spacebar key in vb.net.

The code used in vb6 was SendScanKey VkKeyScan(Asc(" ")).

I am trying to get the next round to start automatically in typing terror.

[Only registered and activated users can see links]

j03
02-26-2016, 01:35 PM
We also tried Sendkeys.send(keys.space)
Zachafer


Sent from my iPhone using Tapatalk

---------- Post added at 01:35 PM ---------- Previous post was at 01:35 PM ----------

Keep in mind it is sending space but when trying to send to a flash object it is not being picked up.


Sent from my iPhone using Tapatalk

Atlas
02-27-2016, 04:38 PM
I also had this problem when I made a Faerie Caves II Bot with Python.
For me, I just solved it by clicking the screen (clicking works for typing terror too).

Zachafer
02-27-2016, 06:32 PM
I am trying to send the spacebar key to a flash object, this was very easy in VB6. I have tried SendKeys.Send(Keys.Space), SendKeys.Send(" ") and SendKeys.Send("{SPACE}"). I am not sure why they are not working, does anybody know how to send the spacebar key in vb.net.

The code used in vb6 was SendScanKey VkKeyScan(Asc(" ")).

I am trying to get the next round to start automatically in typing terror.



Hey Soredavide nice to see you!
The correct way to send a space with SendKeys is SendKeys(" ").
First, I would try setting the Form's KeyPrevew to True (is false by default).
Make sure you are calling Focus() on the flash object before sending keys.

I've never done it in .NET, but you can send VK_SPACE (short=32). See the answer here: [Only registered and activated users can see links]

If you can't get these to work, I can rewrite the SendScanKey for VBNet

Soredavide
02-28-2016, 12:29 PM
VK_SPACE does not seem to be allowed in flash


Private Declare Sub keybd_event Lib "User32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Const VK_SPACE = &H20

Me.KeyPreview = True
ShockwaveFlash1.Focus()
keybd_event(VK_SPACE, 0, 0, 0)

NVM; that worked, thanks.