1. 程式人生 > >SWT自動觸發滑鼠事件,模擬外掛

SWT自動觸發滑鼠事件,模擬外掛

Point point = shell.getLocation();

Event ev = new Event();              //建立事件

ev.type = SWT.MouseMove;             //滑鼠移動

ev.x = point.x + 130;

ev.y = point.y + 55;

shell.getDisplay().post(ev);

 

ev.type = SWT.MouseDown;

shell.getDisplay().post(ev);

 

text.setText("http://www.baidu.com");

 

        ev.type = SWT.MouseMove;

ev.x = point.x + 1150;

ev.y = point.y + 55;

shell.getDisplay().post(ev);

 

ev.type = SWT.MouseDown;

ev.button = 1;     

shell.getDisplay().post(ev);

ev.type = SWT.MouseUp;

shell.getDisplay().post(ev);