I am trying to send a couple basic text commands to a flash program running in Firefox on Windows 7, but I am unable to get pywinauto working for me.
Right now, I have just been able to accomplish the very basic task of connecting to Firefox plugin-container by directing it to the path using the following code:
from pywinauto import application
app = application.Application()
app.connect_(path = r"c:\Program Files (x86)\Mozilla Firefox\plugin-container.exe")
The next step seems to be something to the effect of:
app.plugin-container.Edit.TypeKeys('Text')
However, I can't reference the plugin-container window using '.plugin-container', or any combination of those words. I have tried adding a title variable to the connect_() function and I have tried everything I can think of to find out how to type the command.
The example I am basing this off of is the notepad sample:
from pywinauto import application
app.start_(ur"notepad.exe")
app.Notepad.Edit.TypeKeys(u"{END}{ENTER}SendText d\xf6\xe9s "
u"s\xfcpp\xf4rt \xe0cce\xf1ted characters!!!", with_spaces = True)
It doesn't matter to me if I use pywinauto or Firefox. If it is any easier to do this using a different module or Internet Explorer, I'm on board for whatever accomplishes the task. I am using Python version 2.7.2 and would prefer it over any version changes.
Any help at all is appreciated. I am pretty lost in all this.
As the author of pywinauto - I think you are going to have a hard time. pywinauto only really helps with standard windows controls, and I don't think that flash controls are implemented as standard windows controls (Buttons, Edit boxes, etc).
OFf the top of my head - I would think Sikuli may be a better starting point (http://sikuli.org/).
Another option may be 'http://code.google.com/p/flash-selenium/' - I just googled for "automating flash input" - and it turned up in one of the first articles I clicked.
Thanks for trying pywinauto - I just don't think it is best suited for Flash automation.
Related
I am going to write simple "to do list" app in python. One of the features will be possibility to configure notifications/reminders for tasks. If user will be using GUI I am going to use some popup windows, but what if he runs the app in the terminal, without any GUI? What would be the best equivalent for that? Is there a possibility to somehow notify the user?
I will be thankful for any guidance or at least direction, I tried searching for all variants of "terminal/console/text" + "notifications/popups" but I did not find anything interesting...
I have a python GUI that opens a Chrome window using Seleium. Is there any way in the PyQT GUI to embed the Chrome browser's window so there are not 2 separate windows and its just the GUI? Guessing not possible but worth it to ask.
I have been looking to do exactly the same. I don't have a complete answer but hopefully some of what I found will be of use to others who are trying to do this as well.
It IS possible to embed the window of an outside application into a Python QT application. While I could quote various reference pages I have found that the following question gives most of the information and a good starting point to find more:
QT 5.5 embed external application into QWidget
Now, that requires knowing the Window ID but that isn't too hard to find. You can do that in Windows at least as described here:
http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-subprocess.html
As I said, this isn't a complete answer but should put anyone else following this trail several steps closer to the complete answer. Good luck everyone and if you find the complete answer please share it.
I have done a python webkit navigator, with GTK.
And, as I better know html/css for rendering than others ways, I have done a software using python, wekbit and GTK.
I got some questions. I have read documentation that I found, and did a lot of researchs on google and stackoverflow. I still got lot of questions.
First, in my app, I change the title of the window to communicate between javascript and python. I wish to do the same in my navigator, but I can not (I need title). Is their any others ways ?
I would love to bind javascript events listeners to python, without changing the title.
EDIT
I have found a solution. We can bind some events to python.
You can have more documentation about events in python :
import webkit
help(webkit.WebView)
I have tried with console-message. This events returns me 4 args : webview, webframe, int, msg. What is the int ? In most of messages it is valued to 13... If someone know what it means.
Second, my linux version of my navigator plays really well media element (audio, video...). I assume, it is because linux rulz and depedencies are pretty well installed on my computer.
But on windows it is another things ...
I have seen that I can build webkit for windows with these dependencies.
But I have found some javascript codecs for reading media elements (https://github.com/audiocogs). Should it be better than I inject this javascript, or compiling webkit in my own way ?
Third, can I handle cache settings ? I am pretty sure that now, there is no cache in my browser. (my code is really light now on).
Fourth, can I handle HTTP request ? (cookies, apache auth, ...)
Fifth, I use WebView.zoom_in(), and zoom_out functions. And definitively it has not the same behaviour than firefox or chrome when I zoom_in or zoom_out.
With firefox or chrome, it's like if zoom_out make you have more pixels than before. I mean if you zoom out on chrome, you can have different media queries than before.
With WebView zooms functions, it's like if there is only the font size who change.
How could I do zooms like firefox and chrome ?
Sixth, I could use gecko engine instead of webkit. But I do not know, how to choose between those twos.
It seems that webkit is nicely imported in python and gtk, and linux. But gecko probably too. How could I, in a cleverway, choose ?
Seventh, I got some streaming problems. For instance, if I want to hear some long music, or some videos, and pause them for some times, when I play back the media, my browser bug. There is no error in console, and the webkit.webview is all blank. I can reload, and it works again... How can I handle this error ?
Some relevant samples of my light code :
class nav:
def __init__(self):
self.browser = webkit.WebView()
self.browser.connect("create-web-view",self.set)
self.browser.set_full_content_zoom(True)
self.browser.get_settings().set_property("enable-webaudio",True)
self.browser.open(url)
def on_zoom_in(self, widget):
self.browser.zoom_in()
def on_zoom_out(self, widget):
self.browser.zoom_out()
def on_zoom_n(self, widget):
self.browser.set_zoom_level(1.0)
Thank you,
Not the answers for all the questions you have, but this will help.
There is no need to change the title for communicating between javascript and python. You can alert mechanism. Some examples can be found https://github.com/nhrdl/notesMD - the tool I wrote few days back. In simplest terms, your script uses alert function and python gets the callback. You can parse the text of alert message and decide on action.
Your code has nothing to do with webkit cache. Its function of what pages your application is visiting and what server prefers. Server can ask for some resources to be cached (e.g. images/javascript) and others not to be cached. I know webkit gtk 2 supports some more functions for caching, but don't recall much in Webkit gtk 1. I have seen it caching the files in your home directory though.
For cookies look at python webkit webview remember cookies?. Webkit also has various methods to get request and response and you can listen to various soup events for the things that interest you.
I have not read about python bindings for geco engine. That does not mean it does not exists, only I have not seen it.
I'm trying to write a program than will detect when my mouse pointer will change icon and automatically send out a mouse click. Is there a better way to do this than to take screenshots and parse the image for the mouse icon?
EDIT:
I'm running my program on windows 7.
I'm trying to learn some image processing and make a simple flash game i made automated.
Rules: when the curses changes shape, click to get a point.
Also what imaging modules for python will allow you to take a specific size screenshot not just the whole screen? This question has moved to a new thread: "Taking Screen shots of specific size"
The way to do this in Windows is to install either a global message hook with SetWindowsHookEx or SetWinEventHook. (Alternatively, you could build a DLL that embeds Python and hooks into the browser or its Flash wrapper app and do it less intrusively from within the app, but that's much more work.)
The message you want is WM_SETCURSOR. Note that this is the message sent by Windows to the app to ask whether it wants to change the cursor, not a message sent when the cursor changes. So, IIRC, you will want to put a WH_CALLWNDPROC and a WH_CALLWNDPROCRET and check GetCursorInfo before and after to see if the app has done so.
So, how do you do this from Python? Honestly, if you don't already know both win32api and friends from the pywin32 package, and how to write Windows message procs in some language, you probably don't want to. If you do want to, I'd start off with the (abandoned) pyHook project from UNC Assist. Even if you can't get it working, it's full of useful source code.
You should also search SO for [python] SetWinEventHook and [python] SetWindowsHookEx, and google around a bit; there are some examples out there (I even wrote one here somewhere…)
You can look at higher-level wrapper frameworks like pywinauto and winGuiAuto, but as far as I know, none of them has much help for capturing events.
I believe there are other tools, maybe AutoIt, that have all the functionality you need, but not in Python module. (AutoIt, for example, has its own VB-like scripting language instead.)
I saw here a solution, but i don't want wait until the key is pressed. I want to get the last key pressed.
The related question may help you, as #S.Lott mentioned: Detect in python which keys are pressed
I am writting in, though to give yu advice: don't worry about that.
What kind of program are you trying to produce?
Programas running on a terminal usually don't have an interface in which getting "live" keystrokes is interesting. Not nowadays. For programs running in the terminal, you should worry about a usefull command line User Interfase, using the optparse or other modules.
For interative programs, you should use a GUI library and create a decent UI for your users, instead of reinventing the wheel.Which wouldb eb etter for what you ar trying to do? Theuser click on an icon,a window opens on the screen, witha couple of buttons on it, and half a dozen or so menu options packed under a "File" menu as all the otehr windws on the screen - or - a black terminal opens up, with an 80's looking text interface with some blue-highlighted menu options and so on?. You can use Tkinter for simple windowed applications, as it comes pre-installed with Python + Windows, so that yoru users don't have to worry about installign aditional libraries.
Rephrasing it just to be clear: Any program that requires a user interface should either se a GUI library, or have a WEB interface. It is a waste of your time, and that of your users, to try and create a UI operating over the terminal - we are not in 1989 any more.
If you absolutely need a text interface, you should look at the ncurses library then. Better than trying to reinvent the wheel.
http://code.activestate.com/recipes/134892/
i think it's what you need
ps ooops, i didn't see it's the same solution you rejected...why, btw?
edit:
do you know:
from msvcrt import getch
it works only in windows, however...
(and it is generalised in the above link)
from here: http://www.daniweb.com/forums/thread115282.html