pywinauto not seeing elements visible via inspect.exe - python

I am automating a third party application with pywinauto. I am able to see some specific elements and their texts when using e.g. inpect.exe, but when looking at pywinauto's print_control_identifiers these elements are not included at all (marked with red in the image between the two green ones).
print_control_identifiers VS Inspect.exe (red ones are missing)
Is it somehow possible to see these elements with pywinauto?
In this particular case I need to check for example if an element containing the text "Varoitus!" exists, but for some reason pywinauto can't see it at all.

Related

Qt Creator - How to get rid of "line too long" warning in python scripts

As the title suggests I wonder if it is possible to set the length of a line in python scripts when someone uses Qt Creator as an IDE, in order to get rid of this annoying warning:
I found at least how to hide these annotations (for Mac Os users): First method is to go with the mouse on the top-left corner of the screen and to sequentially click Qt Creator->Preferences. Immediately the Preferences Dialog Window will appear inside the Qt Creator working window. There, have to go to Text Editor in the left panel and in the right panel associated with Text Editor, in the horizontal tabs have to click on Display tab. Scroll down and uncheck Line annotations. The second and the third methods imply to place the mouse over one particular annotation (second method) or over one of the small yellow triangles which are shown in the left column of the "lines numbers column" (third method) and in both cases after one or two seconds will appear a floater and inside that floater with blue letters will be the "Annotation settings" message. Clicking on that message will open the same Preferences Window like in first case. And there will be repeated the procedure described in the first case.

Python - how to remove border around selected ListBox item?

This is a minor issue but I've been struggling with it most of the afternoon and getting nowhere, so here goes. I'm about to write a Python script that will require the use of the ScrolledListBox(). Never having used it before, I started with an experimental script where I could play with it and get familiar with it. I now have the script to where I can double click on an item and, in the handler, correctly print the selected item to stdout. However, I notice that when the item is selected, either with a single or double click, a rectangular border appears around the item in the list and remains there until another item is selected. I've been trying to see if there's a way to get rid of this border but so far have been unable to do so. Here's what I've tried:
1) Thanks to another post in this forum I found that the keys() method would give me a list of the available options for the widget. So, given a ScrolledListBox named slb1 I could do something like print(slb1.keys()) and I got the full list of everything I could configure on the widget. One of them was 'selectborderwidth' so I did: slb1.configure(selectborderwidth=0) thinking that this would remove the border. It didn't.
2) Next I dug through my copy of "Python and Tkinter" and discovered the selection_clear(first, last=None) method. The description states, "If any of the elements between first and last (inclusive) are selected, they are deselected." So I tried: slb1.selection_clear(0, None) in the handler but once again the rectangular border around the item remained.
I'm just getting started in Python and Tkinter so hopefully I'm missing something somebody with more experience knows about. Any ideas on how to get rid of the border?
Thanks,
Dave
The documentation by New Mexico Tech, which can be a good reference when working with Tkinter, lists the attributes for the Listbox widget, among which activestyle. This parameter refers to the box around the currently active (not necessarily selected) item, and can take the values underline, dotbox, and none.
If you set activestyle to none, the dotted border will go away.

spyder IDE sidebar, rename, find all occurances?

I have some questions about spyder 3.2.4 ide for python:
The "sidebar" (to the right of the main code-window) which marks all lines with warnings, all lines with todo etc with a small colored marker. Can I set these colors? Can I disable which ones to show?
Can I "smart rename" a variable like in other IDEs? I mean not just text replace, but actually make sure i just rename the selected variable (all occurances and nothing but it) and not just text matching a string i type in like i would in "word".
Can I list all occurances of a variable like in other IDEs? Lets say I have a list called "combinedAreas" and want to list all the uses of that variable, preferably also being ablo to click a line and jump to that line.
Thanks!
(Spyder maintainer here) About your questions:
Can I set these colors?
No
Can I disable which ones to show?
Yes, you can do that by going to
Preferences > Editor > Code Introspection/Analysis > Analysis
Can I "smart rename" a variable like in other IDEs?
Not right now, but we're trying to implement this feature for Spyder 4 (our next major release).
Can I list all occurances of a variable like in other IDEs?
No, but it's also planned for Spyder 4.

Change desktop wallpaper on certain monitor? [duplicate]

I'm using:
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER,
0, "picturefile", 0)
To change the wallpaper.
But I'm wondering if there's any simple way to put different wallpapers on each screen.
This feature isn't standard in windows though, but there are external applications like ultramon that do this. Anyone know how that works?
The way I thought it might work if I join the two images together into one and then make that the wallpaper, but then I still need a way to span one image accross both screens.
Also, how could I grab some info about the monitor setup, the resolution of each screen and their placement? Like what you see in the gui display settings in windows, but in numbers.
After joining the images together into a big image, you have to set the wallpaper mode to tiled to make it so the image spans the desktop (otherwise it will restart on each monitor).
Couple of ways to do this:
a) Using IActiveDesktop (which does not require Active Desktop to be used, don't worry). This is nicest as on Win7 the new wallpaper will fade in.
You create an IActiveDesktop / CLSID_ActiveDesktop COM object and then call SetWallpaper, SetWallpaperOptions and finally ApplyChanges. (As I'm not a Python dev, I'm not sure exactly how you access the COM object, sorry.)
OR:
b) Via the registry. This isn't as nice, but works well enough.
Under HKEY_CURRENT_USER\Control Panel\Desktop set:
TileWallpaper to (REG_SZ) 1 (i.e. the string "1" not the number 1)
WallpaperStyle to (REG_SZ) 0 (i.e. the string "0" not the number 0)
Then call SystemParameterInfo(SPI_SETDESKTOPWALLPAPER...) as you do already.
.
By the way, the code I'm looking at, which uses IActiveDesktop and falls back on the registry if that fails, passes SPIF_UPDATEINIFILE | SPIF_SENDCHANGE as the last argument to SystemParameterInfo; you're currently passing 0 which could be wrong.
EnumDisplayMonitors is the Win32 API for getting details on the monitors, including their screen sizes and positions relative to each other.
That API returns its results via a callback function that you have to provide. (It calls it once for each monitor.) I am not a Python developer so I'm not sure how you can call such a function from Python.
A quick Google for "Python EnumWindows" (EnumWindows being a commonly-used API which returns results in the same way) finds people talking about that, and using a Lambda function for the callback, so it looks like it's possible but I'll leave it to someone who knows more about Python.
Note: Remember to cope with monitors that aren't right next to each other or aren't aligned with each other. Your compiled image may need to have blank areas to make things line up right on all the monitors. If you move one of the monitors around and do a PrtScn screenshot of the whole desktop you'll see what I mean in the result.

Classify different versions of the same webpage

There is a webpage which when loaded uses a random placement of forms / controls / google ads. However, the set is closed--from my tests there are at least three possible variations, with two very common and the third very rare.
I would like to be able to classify this webpage according to each variation. I tried analyzing the html source of each variation, but the html of all the variations is exactly the same, according to both Python string equals and the Python difflib. There doesn't seem to be any information specifying where to put the google ads or the controls.
For an example, consider a picture with two boxes, a red one (call it box A) and a blue one (call it box B). The boxes themselves never change position, but what takes their position does.
Now consider two possible variations, one of which is chosen everytime the webpage is loaded / opened.
Variation 1: Suppose 50% of the time, the google ad is positioned at box A (the red one) and the website control is thus placed at box B (the blue one).
Variation 2: Suppose also 50% of the time, the google ad is positioned at box B (the blue one) and the website control is thus placed at box A (the red one).
So if I load the webpage, how can I classify it based on its variation?
If the HTML is definitely the same every time, the variations are probably being done on the client side using javascript.
The answer depends on what you mean by "classify." If you just want to know, on any given load of the page, where the widgets are, you will probably have to use something like Selenium that actually opens the page in a browser and runs javascript, rather than just fetching the HTML source. Then you will need to use Selenium to eval some javascript that detects the widget locations. There is a selenium module for python that is fairly straightforward to use. Consider hooking it up to PhantomJS so you don't have to have a browser window up.

Categories