I would like to do a testing on the mouse cursor, I had been told that I should turn off the “Rich Cursors” feature under VNC in Eggplant Preferences. I would like to know whether the “Rich Cursors” option can be toggle on and off in a script?
UPDATE 6/2/10: While the tip below will work to set a dwrite, you can’t rely on eggPlant picking up the change to the setting during the script run. There are threading and notification issues that may prevent the change being detected by the application for some time after it has been made. Also, the -array-add flag is not supported on Windows or Linux.
There’s no EggPlant command to do this and there’s no global variable that you can access directly within a script. However, you can do it by using the shell() function to issue a dwrite:
put shell("defaults write com.redstonesoftware.Eggplant DisabledEncodings -array-add Cursor")
Note that this will mean that the rich cursors are disabled until you re-enable them, either by checking the box in the Preferences or by deleting the dwrite. There doesn’t appear to be the granularity available to remove a single element from the dwrite array, so you can only remove the entire array via the command line. To do it from within your script, you would again use the shell function:
put shell("defaults delete com.redstonesoftware.Eggplant DisabledEncodings")
Please be aware that the dwrites are case-sensitive, so you need to be sure to enter them exactly as they appear above.
I had tried the shell() function but it seem like the function do not work everytime. Sometimes, it failed to turn off the Rich Cursor. I would like to know is there any way to make sure that the shell() function above will work properly?
I don’t believe it’s really possible for the shell function to fail to set dwrite. You might need to disconnect and reconnect (which is scriptable) to see the change, although in my tests it took affect immediately without needing to do so.
You could run another shell function and check the output to see if the dwrite is set:
if shell("defaults read com.redstonesoftware.Eggplant DisabledEncodings") does not contain "Cursor" then logerror "Rich cursors not disabled"
If the dwrite is set, then the rich cursors are disabled, but that doesn’t necessarily mean that EggPlant is going to immediately read the dwrite, although again, it worked in my tests.