How to get info box text with Python - python

Im sorry if this question sounds a bit vague, but I dont know the term for what I am looking for.
If you place your mouse cursor over an item in Windows and leave it there for a second, a box pops up with some text. For example, if you have your cursor on the 'e' icon, a box will show up with the text "Microsoft Edge".
Is there a method, using Python, to read what that text is? So for the example given, I would like to write or call a function that returns a string containing "Microsoft Edge".
Thank you for any help you can offer.

You are referring to tooltips. It's possible to use python with BeautifulSoup to scrape these off the web.

I am looking to get tooltip text from an icon displaying in the system tray. There are functions in class pywinauto.controls.common_controls.ToolTipsWrapper(hwnd) in pywinauto module of python. For example GetTipText(tip_index)Return the text of the tooltip. You can try if these functions provide any help to you. But I was getting error like 'no windows found' when using control of the icon by classname as window handle. For e.g
app = Application(backend="uia").connect(path="explorer")
sys_tray = app.window(class_name="Shell_TrayWnd")
hnd = sys_tray.childWindow(class_name= "ToolbarWindow32")``
texts= pywinauto.controls.common_controls.ToolTipsWrapper(hnd).texts()
print(texts)
Documentation of pywinauto: https://media.readthedocs.org/pdf/pywinauto-docs/docs-rework/pywinauto-docs.pdf

Related

How to create s custom window in Python to display an iframe?

For displaying video player I would like to create a custom window that shows the output of the iframe html code I give.How do I create it ? I use Python idle and Windows
Please give more details. What are you using to parse html code?
what are you using for an ui?
If you are really new... try some googles :)
Pywebview
This might help. But for referent please try and google before asking.

pywinauto print control identifiers does not show required controll buttons

I'm trying to automate installation (install anyware type) using pywinauto.
When I use function to dispaly controlls "print control identifiers()", I see only buttons like "minimize", "close" , "maximize" and window name. There is no "next button" and other required buttons, that I need for automating this installation.
this is how it looks after using this function:
enter image description here
this is how installer window looks :
enter image description here
code sample:
w_handle2 = pywinauto.findwindows.find_windows(title=u'PTC Solution Installer', class_name='SunAwtFrame')[0]
window2 = app.window(handle=w_handle2)
window2.print_control_identifiers()
Could you pleas help me, with my issue? Is ther any other way to check the controlls? I was also trying to use other software like inspector.exe, it tells me the windows name , but nothing about controlls.
If there is no other way, then maybe there is possibility to use function for clinking mouse, with some additional precision. For example finding specific string on installer window and clicking on it, or getting button string location and passing it, to mouse click coordinates.
Topic Update image with
inspect tool screenshot:
screenshot with inspect tool
winspy screenshots:
winspy screenshot1
winspy screenshot2
winspy screenshot3

Python. How to print text to console as hyperlink?

I'm working on a console application. My application uses urwid lib. In some cases, I need to show very long hyperlinks as short text inside table columns. I want to open links in the browser when I click on the text inside the column.
So, my question is:
It is possible to print text as a hyperlink to the console?
Can you provide a small example of how to print text as a hyperlink using python?
A bit late, but there totally is a way to do that now, without curses or anything, just pure text and collaboration from your terminal emulator.
def link(uri, label=None):
if label is None:
label = uri
parameters = ''
# OSC 8 ; params ; URI ST <name> OSC 8 ;; ST
escape_mask = '\033]8;{};{}\033\\{}\033]8;;\033\\'
return escape_mask.format(parameters, uri, label)
Call that function with link('https://example.com/') to get a simple, clickable link, or link('https://example.com/', 'example') for a custom label.
Note that links are faintly underlined in your terminal, and not all of them support the feature.
Yes, using some tools, like gNewt or Curses, you could create a button and 'on click' do an action (like open a browser to a given url).
gNewt : http://gnewt.sourceforge.net/
nCurses : https://docs.python.org/3.7/library/curses.html
Otherwise, it's the terminal application that will manage the text you give it, and if it doesn't implement uri's recognition your program won't work as you'd like.
No, some consoles do recognize urls and convert them to a clickable hyperlink. All you can do is make it easy to recognize for console applications by putting a http:// in your url.
Also see
How does bash recognize a link?

Search text and scroll down with qwebview

I'm using Qwebview with Pyside/Qt to view an HTML page on a GUI I'm working on.
I need the possibility to add a search text function, otherwise it is useless for the purpose the GUI is made.
I've searched but I didn't find anything useful for build a code that search the text and scrolls down the page as it is made in the common browsers.
The only function I found is findText but it returns a boolean and I cannot see how it can be useful.
Do somebody have an hint / advice / guide or code for this request?
Thank you.
Okay, so it turns out that i had an example of this using a QTextBrowser, which has a lot of this built into utility functions.
You can still do it with a QWebBrowser though.
Bind ctrl-f to open a search panel, and then make it so that the search box sends out two signals;
(presuming it's a QLineEdit), returnPressed, and textChanged.
Each of them then calls findText on the QWebPage object.
The important part is setting the correct flag in the findText call (which you'll want to set with checkboxes in your search functionality, i'd say).
You set the flags so that HighlightAllOccurrences is not set.
I cannot see any way to get details on a selection. Are you sure that when you do not set the HighlightAllOccurences flag it does not scroll to the next selection automatically?

How to make an editor using markdowns with Qt4 and Python?

I'd like to make a small desktop editor to take notes, that uses markdowns to format text quickly. The application should transcribe markdowns instantaneously or after clicking on a button.
For this I'd like to use Qt4 and Python.
What, in your opinion, is the most efficient way to proceed?
In the case the rich text is rendered after pressing a button, I suppose I could use QTextEdit widget for the edit-mode, but what to use to display the rich text? I want this to look good. Should I render the text in HTML? Or something else?
Please advise.
You can look at how ReText has done it. Maybe even ReText is the app you want to code :-)
I came here because I'm looking for a solution for the same task.
Here is what I would (or hopefully will) try:
Subclass QTextEdit, which can display both plain and rich text.
supply two string properties, one containing Markdown source, the other generated HTML.
For entering "edit mode" (however your UI will handle this)
self.setText(self.markdown)
self.setReadOnly(False)
For leaving "edit mode":
self.markdown = self.toPlainText()
self.toHtml() # convert self.markdown to self.html
# don't know yet how to achieve that
self.setHtml(self.html)
self.setReadOnly(True)
For displaying the HTML one can use a CSS stylesheet.
As UI interface I could imagine: clicking on the readonly display mode switches to edit mode, [Ctrl]-[Enter] triggers HTML generation.

Categories

Resources