This project is read-only.

How to Press a list of function keys

Nov 14, 2010 at 2:18 AM

I need to press a list of function keys that were retrieved from the screen.  How do I loop through that list to press on each of the function key listed?   How would I assign one function key which is a string type to a Keyboard.SpecialKeys type in order to perform the press key?   I am having a difficult type accomplishing this task.   Any suggestions??  thanks in advance.
Here is a sample of code:

List<String> RetrievedKeys = GetAllFunctionKeys();   // Retrieving all Function keys listed on screen.
foreach (string Key in RetrievedKeys){
   AttachedKeyboard keyboard = screen.Keyboard;
   keyboard.PressSpecialKey(Key);}     //  however Key should be in form of Keyboard.SpecialKeys


Nov 15, 2010 at 5:12 AM

Hello, I researched how to cast strings to another type but was not successful.  I received "Invalid cast from 'System.string' to 'White.Core.windowsAPI.KeyboardInput.SpecialKeys'" error.  Any suggestions. Please see a test sample code of what I need to do.


string skey = "F6";      // only for testing.  Original test will retrieve the function key strings from the screen.
KeyboardInput.SpecialKeys special = (KeyboardInput.SpecialKeys)Convert.ChangeType(skey, typeof (KeyboardInput.SpecialKeys));

I would appreciate your help on this as I am really stuck.   Thanks.