How to simulate a key-press in ExtendScript?

笑着哭i 提交于 2020-05-13 14:45:06

问题


currently I want to write a script for AE, which relieves me of some keyboard inputs. Once the script is running, I want to click with the mouse, and then some key-inputs for example X Y and Z should be simulated. The little GUI and the eventhandler are no problems, but the simulation of key pressing. Please help.

var win = new Window ("dialog", "Dummy");
win.aButton = win.add ("button", undefined, "Start");
win.bButton = win.add ("button", undefined, "Stop");

//Start
win.aButton.onClick = function (event){
var activeViewer = app.activeViewer;
    if activeViewer.type == ViewerType.VIEWER_COMPOSITION){

     HERE SHOULD THE KEYS x, y AND z PRESSED VIA THE SCRIPT 

    }else return;
}
//Stop
win.bButton.onClick = function (event){
    win.close();
    return;
}
win.show();

回答1:


There is something in Extendscript that looks like it can execute KeyboardEvents

Javascript Tools Guide Look at page 152

initKeyboardEvent() eventObj.initKeyboardEvent (eventName, bubble, isCancelable, view, keyID, keyLocation, modifiersList)  


来源:https://stackoverflow.com/questions/26850666/how-to-simulate-a-key-press-in-extendscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!