Skip to main content
Known Participant
January 20, 2013
Question

Why this one does not work? Simulate a mouse event

  • January 20, 2013
  • 1 reply
  • 925 views

Hi I m trying to simulate a mouse event but is seems to not work. here is the code thata Iam using for testing

Everithing goes fine until it reraches  line number 5. in the console says dispatchEvent is  undefined

var win = new Window("dialog","testerWindow",[200,200,400,400]);

win.onClick=  function(){alert("Hello World")}

var event = ScriptUI.events.createEvent("MouseEvent");

var init = event.initMouseEvent("click",true,true,1,win,0,0,0,0,0,1);

win.dispatchEvent(init);

win.show()

it should show an alert Message as soon as the window shows up right?

This topic has been closed for replies.

1 reply

Legend
January 21, 2013

Something tells me that maybe it's not showing due to the fact that the click event happens before the window is actively showing. Try calling it afterwards and see if it works.

Known Participant
January 26, 2013

hey David thanks for taking the time to answear but it seems to not work

Please any more ideas why this would be happening.