sendKeys -function (for CS2 and CS5)

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

autiokari

sendKeys -function (for CS2 and CS5)

Post by autiokari »

This is a Javascript sendkeys -function, works at least with CS2 and CS5:

Code: Select allsendKeys=function(KeysToSend){
//special characters must be escaped by "\", 
var sendKeysFile=new File(parentFolder + "/temp-" + pcID +".vbs" );
   var s="DIM objApp\n"
   s=s+"SET objApp = CreateObject(\"Photoshop.Application\")  \n";
   s=s+"Set WshShell = WScript.CreateObject(\"WScript.Shell\") \n";
   s=s+"WshShell.SendKeys \"" + KeysToSend + "\"\n";
   s=s+"WScript.Quit()\n";

   sendKeysFile.open("w:");
   sendKeysFile.write(s);
   sendKeysFile.close();

sendKeysFile.execute();
}//sendkeys


It works by first creating a vbs (WshShell) file and then executing that. I save the tempvbs file into the folder one upwards from the folder where the main script resides, the variable parentFolder is defined elsewhere and holds that path (as string). The variable pcID is also declared elsewhere and contain the ID of the computer (can be removed if not needed).

The function is used like:
Code: Select allsendKeys("\%(ia{RIGHT}w)");


the above reliably opens the Shadows-Highlight dialog of CS5 with the Most Recently Used Settings.

The format of the sendkeys -string is the same as in Visual Basic for Application (of MS Excel) detailed instructions can be found from the help there.

BR,
Timo