Skip to content

Instantly share code, notes, and snippets.

@kjelly
Created March 16, 2014 13:02
Show Gist options
  • Save kjelly/9582874 to your computer and use it in GitHub Desktop.
Save kjelly/9582874 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtWebKit import *
import random
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("http://www.csie.ntu.edu.tw/~b01902112/9007199254740992/"))
web.show()
def action():
keys = [Qt.Key_Right, Qt.Key_Left, Qt.Key_Down, Qt.Key_Up]
key = random.choice(keys)
event = QKeyEvent (QEvent.KeyPress, key, Qt.NoModifier)
QCoreApplication.postEvent (web, event)
timer = QTimer()
timer.timeout.connect(action)
timer.start(1)
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment