0

I have presentations in Google Docs, and I'm to figure out how to trigger the next slide via JavaScript. I'm playing around with writing a little web server that runs on my local network that I can use to access via my phone, which would trigger key events in the presentation, serving as a hack for a presenter remote. I'm sure there are other ways to accomplish the same thing, but I'm trying to get this one to work.

I've tried triggering a click event at various places on the page, but I haven't been able to get the presentations to respond. I've tried it on the window object, document object, and any other hooks I could try. i.e.

$('.punch-viewer-right').click(); // The div with the button to advance slides

I also tried this code to get it to change via keystroke:

var e = jQuery.Event("keydown");
e.which = 37; // the left arrow
$("body").trigger(e); // I tried as many elements as I could grab

But nothing seemed to register. I pulled in jQuery, so it was available, but I can't get this one to work.

Any ideas on how I get this to change slides via JavaScript?

Community
  • 1
  • 1
EmptyArsenal
  • 7,314
  • 4
  • 33
  • 56

1 Answers1

0

You can simulate a keydown event for the spacebar (in the developer console):

document.dispatchEvent(
    new KeyboardEvent('keydown',{ keyCode:32, which: 32 })
)
machineghost
  • 33,529
  • 30
  • 159
  • 234