PDA

Click to See Complete Forum and Search --> : sending command F5


Marcelo Velasquez
Apr 29th, 2000, 09:37 PM
As I do for through an application in VB, to change the attributes of a file for occult or system and to apply immediately for when the user opens the explorer he doesn't get to see, how to send of the command F5

Apr 30th, 2000, 03:43 AM
if i understand u right, to simulate the keystroke F5, I think one way to do this would be to use the keybd_event API.
The Virtual Key code to pass to this function for F5 is &H74.
I would probably make a constant like:

Private Const VK_F5 = &H74

I've got the declaration of the keybd_event in C++ and VB.
If you need the declaration, just lemme know which language.

CiD -=ii=-

Marcelo Velasquez
May 1st, 2000, 04:46 AM
You really understood!!!, As I make this, if you can send a piece of the code I thank

I am in advance grateful

May 1st, 2000, 05:59 AM
Sure, here it is in VB (cuz thats what i use):

Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)

'bvk - the virtual key code to be sent to the kb buffer
'bScan - hardware scan code.. just always set this to 0
'dwFlags - xtra info about the event
'dwExtraInfo - just set this to 0 too

'So, say u want to pass the F5 key, in a sub or function 'somewhere the code would be:

Private Const VK_F5 = &H74
Private Const KEYEVENTF_KEYUP = &H2

keybd_event VK_F5, 0, 0, 0
keybd_event VK_F5, 0, KEYEVENTF_KEYUP, 0

'U have to run the command twice like that cuz first time 'is pressing the key down and the second time is releasing 'it. Also sometimes when i pass keys i have to make the 'program sleep for a couple seconds to give the form a 'chance to come up.
'Hope this helps...
'
'CiD -=ii=-