ShortCut Key with Mac didn't work as it is?

My main machine which installed EggPlant is Mac OS X 10.7. My SUT is Mac OS X 10.7 Lion in a Virtual Machine with VMWare.

One of our application command -- shortcut key is Command and comma ","

If I manually test those two keys Command and ",", it will bring up correct dialog box, but if I wrote the script, it didn't work, following is my script:

*************************
Keydown CommandKey
Keydown CommaKey, return
KeyUp CommandKey
KeyUp CommaKey
**************************
Or

********************************
TypeText Commandkey & CommaKey
********************************

Or

********************************
TypeText CommandKey, ","
********************************

I have another shortcut Key: Command and R key, it works correctly when I use following scritp:
***********************
Keydown CommandKey
Keydown RKey, return
KeyUp CommandKey
KeyUp RKey
**********************

Thank you in advance

CEQA

Comments

  • CEQA,

    First of all, CommaKey is not a valid keyword in SenseTalk, so that would be why your first two scripts were not working. The keyword for a comma is just "comma" (which you would enter without the quotes). The third script (TypeText CommandKey, ",") however, should be functional. You should be able to verify that it is typing what you expect by looking at the output panel (in the Run window).
    Is it possible that you have a KeyDown earlier in your script that needs to be released (KeyUp)?
    Another thing you could try if it's still not working is to lengthen the amount of time that the key is pressed. You can do this by altering the KeyDownDelay and setting it to something like .1 (the default setting is likely .01 or .001). However, in order to restore it to its default after you no longer need it, I would recommend a script like this one:
    put the keydowndelay into KDD --stores the current keydowndelay setting
    set the keydowndelay to .1 --changes the value to slow the key press
    typetext commandKey, "," 
    set the keydowndelay to KDD -- restores the original delay value
    

    This way you know that it is set back to your default, whatever that happens to be.

    A couple of suggestions:
    Try using TypeText wherever possible instead of KeyDown and KeyUp; it is more direct and the modifier keys get released automatically. KeyDown and KeyUp can be useful if you need to do something else while a key is held down (such as a click).
    Also, remember that eggPlant only does whatever a user would do, and so if the user would not type something, then eggPlant should not have to type it either. I say this particularly in reference to your use of the Return key in your first and last scripts. This use of Return is not only unnecessary but is actually being modified by the CommandKey. It is in effect a CommandKey Return, not just a Return.
    It looks like you are also adding "Key" in places where it is not necessary (examples: "commaKey" and "RKey" should be "comma" and "R"). In the case of "commakey", it is causing the SUT to type "c,o,m,m,a,k,e,y" instead of hitting the comma key. This is good to keep in mind as it could cause complications.
    For instance, in a word document on my SUT when I run the command
    typeText commandKey, RKey
    

    the Edit menu is selected, because of the "e" in "Key", since in this case command R and command K do nothing.

    And so, you could also try using "comma", like this, since "comma" by itself is a valid keyword:
    typeText commandKey, comma
    

    If you're still having trouble, could you specify what context this command is in, that might give clues to why it may not be working?

    - Elizabeth
  • CEQACEQA Member
    Thank you very much.

    The following code works for me:
    ******************
    typeText commandKey, comma
    ******************

    By the way, I have the question regarding to "return" key

    Following code works for me:
    ***************
    typeText commandKey, R
    ****************

    If I use keydown and keyup, it will only highlight the command, it will not execute the command.

    *****************
    Keydown CommandKey
    Keydown R
    Keyup CommandKey
    Keyup R
    **********************

    If I add the return, it will execute the command. That's why I add the return on the end of script.
    *******************
    Keydown CommandKey
    Keydown R, return
    Keyup CommandKey
    Keyup R
    ********************

    Thanks.

    CEQA
  • CEQA,

    If you think about the way you would manually execute a Command R, you would push the Command key, then the R key, and then you would let the R key go before you let the Command key go. The way you have written the operation, the R key isn't let up until after the Command key, which is not the way it would normally be done, so it isn't working. The use of Return in this case is aborting the command KeyDown R before the Command key is let up, which is why it enables the operation's functionality.

    To reiterate, the best thing to do in this scenario is use the TypeText command instead of KeyDown and KeyUp. This is for a couple of different reasons; because it handles the press and release of the key for you, and also because it can be easily scripted as you are capturing images in the remote screen window.

    -Elizabeth
  • CEQACEQA Member
    Thanks for the good suggestion. I always try to find the best way to create my scripts.

    Thanks.

    CEQA
Sign In or Register to comment.