How to get the right click context menu in a Windows application using Python, do not set the position of the cursor and when not focus that Windows application.
Context menu is not the Explorer context menu, it is the Windows application right click context menu.
Here is an example for Notepad:
app.UntitledNotepad.Edit.Click(button='right') # works
app.PopupMenu.MenuSelect('Paste') # seems not working when Notepad is not in focus
# though it works when app.UntitledNotepad.SetFocus() is called before
app.PopupMenu.MenuSelect('Paste') may not work in such a case because probably WM_COMMAND can be sent to a focused window only. To get it to work use app.PopupMenu.MenuItem('Paste').ClickInput() though your app window will get to focus any way.
So finally there are 2 working examples. The first is:
app.UntitledNotepad.SetFocus()
app.UntitledNotepad.Edit.Click(button='right')
app.PopupMenu.MenuSelect('Paste')
The second is:
app.UntitledNotepad.Edit.Click(button='right')
app.PopupMenu.MenuItem('Paste').ClickInput()
Related
How can I can a function and create a function for the icon context menu? I want to make the iconic Open New Window function pop-up when you right click on the icon menu in the taskbar/dock. See this question for more info on this kind of question.
Places I have looked but found nothing:
https://www.tcl.tk/man/tcl8.5/TkCmd/tk_mac.html#M15
https://pyinstaller.org/en/stable/feature-notes.html#open-event-handling-in-a-tkinter-based-gui-application
While there are a tiny subset of apple events that you can benefit from the DockMenu is not accessible directly via tkinter. Turns out mac is not really open for modifications and even smaller tasks can be hard. You could consider to use a system tray icon instead.
I am working with Pywinauto to automate a Desktop Application.
At one point there could be a popup window. With findbestmatch I want to check if the popup is available. The name of the popup window is the same as of the normal window.
Is there an alternative for findbestmatch or is it the best option?
There is a pywinauto function called popup_window() which could be a good starting point for you. See link
Its listed under pywinauto.controls.hwndwrapper, which provides basic wrapping of windows controls. It will return the handle/id of any open popups or a reference to self if no popups exist.
I want to make a click through window. A window which I click but the click pass to the window below it.
I've found this two solutions for windows:
How to make click-through windows PyQt
I have a form that can "click through", i.e. direct clicks to the window below. How can I undo my changes after the event?
But I want it to work in linux. I study the xlib mechanisms but cannot understand how the window stack works. Actually I can get all the windows with XQueryTree() and found the ones under my window. But I don't know witch one are above.
The goal is to have an application that runs on top of all other applications and windows in the desktop, and display a clickable control (say, an image button) that moves around the screen.
The application must run as a service in the background and show thebutton (let's say) each hour, once clicked it disappears until the next hour.
This application has to be written in Python.
It looks like PyQt is one of the better options, but I'm not sure if it does support this sort of functionality and if it is a good alternative for modern Windows applications.
What packages or frameworks are appropriate for this scenario? I have seen Pygl and PyGame but they seem to be limited to a window, is this correct?
You actually don't need to create the program as a service. You can just start the application and not show the window immediately. You can use PyQt or wxPython. I'm more familiar with wxPython, so if you went that route, you could use a wx.Frame style flag such as wx.STAY_ON_TOP to get the functionality you want.
I have created applications that load up in the system tray with just an icon. When you click the icon, it shows the frame. The rest of the time, the frame is hidden. I would try that route before looking at doing a service.
im having some problems to send to the front a GTK window.
I have a main window (window_root) with a button that launches another window (window_programs).
with this commands:
window_root.hide()
window_programs.show()
then, in window_programs, i have a button that displays another window (window_list) with the command:
window_list.show()
window_list is modal.
The problem was that window_list appeared at the back of window_programs.
so i did some research and i found window_list.show().
The problems is that window_list appears at the front, but when i click it window_programs comes to the front!
it makes some time that i'm looking for the solution, any help will be appreciated!
You are looking for the transient-for property of the modal window (which should be available in Glade). If the modal window needs to be transient to either of the two other windows, then you need to use gtk_window_set_transient_for() as needed since the modal can only be transient for one window at a time.