Click to See Complete Forum and Search --> : Simulate a key stroke
visual fzz
February 2nd, 2000, 03:15 AM
Hi everybody.
I want to simulate a key stroke on the keybord with code
Exemple: you display a message box with vbokonly and you generate with the code the hit of the space bar or the enter key in order to close this message box.
I want to do that with the window which format a 1.44Mo disk.
Is that possible???
Visual Fzz
Spectre
February 2nd, 2000, 08:49 AM
Don't use a messagebox (under the hood VB is using an API call to generate a standard windows messagebox) instead simply use a VB form (you can make it look just like the messagebox popup if you want) then you can put the code to do your format and then close the form when it is done. If you hid the form that you called from don't forget to show it again. By doing this you also gain the ability to use the animation control to put in the animation at the top like the standard windows format dialog - and to run a progress bar.
Dr. Inferno
February 2nd, 2000, 06:37 PM
the code to simulate a key stroke is:
SendKeys string[, wait]
wait is a boolean (true or false) which states this. If you enter TRUE, then the program you sent keystrokes to stays the active program until another one is sent. If you enter FALSE, immediately after that program gets the keystrokes your program becomes the active one open.
The keys to enter is the string. For example, say you wanted to enter the keystroke ALT + F4 (which closes the program), then you would do this:
sendkeys "%{F4}", true
This means you send the key ALT + F4 to whatever the active program is, and then you wait until another keystroke is passed until your program becomes active again. So, all you have to do is open the program which formats the A:\ disk and then send whatever key you need to...
TTN
February 2nd, 2000, 06:43 PM
Simply place this code where you want it to press enter:
SendKeys "~", True
It's fairly simple, the ~ stands for the return symbol, check out SendKeys in your help files to get the whole thing. If you want it to send letter just type the letters. EX:
SendKeys "h", True
will simulate the "h" key; etc...
ThomasTN visit: http://zap.to/ttnsoftware
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.