Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stuffing the keyboard buffer
Message
De
03/06/1999 15:26:50
 
 
À
03/06/1999 15:02:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00225979
Message ID:
00226159
Vues:
21
>>>>>Does anybody know the correct syntax in VFP to declare and call
>>>>>the "keybd_event" API function?
>>>>>
>>>>>I'm running an external application which when it runs presents the user with a Yes and No button, with the Yes button set as the default. I am trying to automate the execution of this external function as much as possible and want to programmatically press the Enter key to trigger the Yes button and conclude the process.
>>>>
>>>>Hi Mark,
>>>>
>>>>Are you using the MESSAGEBOX() function, or a dialog of your own design? I really don't think that you can automate this from within VFP if you're using MESSAGEBOX() since the dialog is modal to the application. However, if you're not using MESSAGEBOX(), all you have to do is use the KEYBOARD command, to make it look as if the default command button was pressed.
>>>
>>>
>>>Hi George.
>>>I'm running an external application, via CreateProcess(). Unfortunately the scope of the KEYBOARD command is limited to within the VFP application.
>>>
>>>What I'm doing is merging a .REG file by calling REGEDIT.EXE and passing it the name of the reg file. It works fine under Win'95 but under '98 the user is presented with a YES/NO prompt to merge the reg file. I want to keyboard an ENTER to automate clicking the YES button. ( the default button)
>>>
>>>If you know of any API functions for merging a REG file as an alternative to running REGEDIT that would even be better. If it were only a few registry settings I'd write to the registry manually but there are too many to do that way.
>>
>>Hi Mark,
>>
>>Sorry if I didn't understand your question correctly. I wasn't exactly sure what was generating the dialog.
>>
>>I think my friend Ed has you on the right track. In fact, I was about to respond to your last message to him about the error you were getting and the 0xOD and 0x0D business, but he beat me to it.
>>
>>AFAIK, there is no way via an API function to do what you're trying to accomplish. I'm wondering, however, if there isn't a command line switch (such as /s) that will do this in silent mode, similar to REGSVR32. I know that there's are several command line switches.
>
>
>Thanks guys.
>The keybd_event tip works great. In order to get it to work right though I had to replace the 0x0D with 13 ( it didn't like 0x0D either). I also tried the /s switch which someone suggested on deja.com and that allows me to avoid having to answer the prompts at all. Better yet though, it just occured to me that rather than merge the reg file via regedit ( which I admit is a kluge) I could right a little function that you pass a reg filename to and it does a low level file read and merges the registry entries one line at a time using standard registry functions. I was just looking for a way to avoid hard coding a bunch of registry entries. Thanks again.

Mark, you're asking for trouble here unfortunately, especially with Win9x. There's a maximum size to the registry, and a number of things can pop error dialogs for REGSVR32; without some error checking, you've left yourself open to undtected errors and hangs that your application won't be able to handle directly.

Since this is a VFP app, why not create a database of registry values to maintain? While this isn't as ubiuquitous as the .REG file format, it's easy to process in your application, and you can construct things in your database of registry entries that couldn't be dome with a .REG file - for example, a .REG file can't delete a registry value or registry key.

I think you're probably on the right track trying to do things programatically; this is an approach that I use as a part of the distributed app maintenance core I've developed for handling network environments.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform