Why does a right click sent from pywinauto not change the state of the grayed out connect button in informatica, but a real mouse button click does? - ui-automation

I am trying to write a script using pywinauto to open a repository in Informatica powercenter workflow manager (v9.6.1)
After the below lines are executed, I get the context menu with the connect option as in the screenshot. Also notice the 'connect' button on the toolbar stays grayed out. If I use the actual mouse and click on the treeview item for the repository I want to connect to, the connect button turns green and enabled. But not when pywinauto sends the right click.
from pywinauto.application import Application
from pywinauto.keyboard import SendKeys
import time
app = Application().Start(cmd_line=r'C:\PowerCenterClient\client\bin\pmwflmgr.exe')
informaticaworkflowmanager = app[u'Informatica::WorkflowManager']
informaticaworkflowmanager.Wait('ready')
time.sleep(2)
systreeview = informaticaworkflowmanager[u'TreeView']
tree_item = systreeview.GetItem([u'Repositories', u'REP'])
tree_item.Select()
tree_item.Click(button='right',double=True,where='icon')
I tried using SendKeys to send 'c' followed by {ENTER} and it just returns without doing anything. Also if I use the actual keyboard on the right click context menu generated after the above pywinauto steps run- it selects the connect menu when i press c , but it just doesn't do anything when I press Enter. I think somehow the connect function is not enabled.
I am clueless if any other input is required by the application to enable it. I also tried using the informaticaworkflowmanager.MenuItem(u'&Repository->&Connect...') option but to no avail- it says it is disabled.
Any pointers to help get pywinauto to open a repository are welcome!

Just summarizing the comments...
First try running the script as Administrator. If it doesn't help, use method click_input(). It runs real click like a user does. Method click() sends WM_CLICK or BM_CLICK which is probably not handled by the app in grayed button state.
If you run the script as Administrator, it should inherit privileges for child process by default. There is no special flag in method start() because some functions may not work if target app process has higher privileges. Anyway elevation usually requires confirmation from user and this Security Confirmation dialog can't be automated by OS design (even click_input() with hard coded coordinates won't work while this dialog was shown, I checked it a while ago).

Related

Selenium IDE - Click on close button in iframe obviously works but raises exception : frame no longer exists

In my scenario, I click on a button on a website which opens a popin.
In that popin, i click some buttons (all is working fine) until I need to confirm by clicking another button.
Problem comes here. When I look at the execution, Selenium IDE obviously finds the button and click it because I can see the popin close and the result of the actions done in the popin on the website.
But the test fails on this button click with reason : frame no longer exists
Any idea ?
They is a try/catch mechnism under development which could be used to mitigate this. In the meantime I exported my tests to run in webdriver and this issue no longer manifests itself.

Tcl/Tk grab a window globally

My Tk application has a main window, when executing, new window arises to show the running progress. I want all the events (mouse, keyboard, etc) are directed to the progress window, so when program is runned, user cannot interact with the main window, and must wait until execution is done and progress window destroyed.
I tried using grab to handle this.
grab set .progress_window
But it doesn't work. The progress window still disappears when mouse clicked somewhere outside it.
grab set -global .progress_window seems work but it block all the other windows running on my computer.
How to solve this problem?
Thank you so much.
You might need this too to keep it on top:
wm transient .progress_window .
Also, see how Tk itself creates modal dialogs.
There are some hoops to go through to get it fully right, e.g.:
https://github.com/tcltk/tk/blob/master/library/dialog.tcl

How do I automate mouse clicks on a Windows system tray icon using Perl?

I am writing some automation scripts using Perl for testing a custom Windows application. The only way to exit the application is to automate a right click on a system tray icon (which the application creates) and clicking on exit on the menu that it shows. Is it possible to automate such clicks using Perl? I checked the Win32::GuiTest module but could not find much stuff on automating mouse clicks on system tray icons.
I don't know of a robust way to do what you are asking.
But it looks like you can make it work by first calling MouseMoveAbsPix to move to the right location, then SendMouse a RightClick. If you know the exact machine that you will be using, and know where the tray should be, you can click on the tray icon.
But be aware that this will be very, very dependent on what exactly is on the window. And this logic won't work at all if the screen is an any way different than you expect. (For instance there is an unexpected popup.)
Incidentally you might try seeing whether sending the application the key combination ALT+F4 will exit the application. There is a chance that this will work, and it should be much more reliable.
That distribution comes with examples. You first want to play around with spy.pl in order to find out the window name of the appropriate tray icon. Then in your real program you use that name to immediately address the icon, this is position independent.

Restarting an app in Eclipse

Is there any way to restart a program in Eclipse? (preferably 1-click)
I really wish the console view had something like a restart button that would kill the app and restart it with the latest changes.
This always takes me at least three clicks. I click the down arrow next to the green circle with white triangle (play button) to open the dropdown menu, then I click to choose the Java main that I want to run, and then to stop I click the red square terminate button in the console view. Is there any easier way to do this that requires fewer clicks?
In Eclipse 4.1
open:
windows->Preferences->keys
in the filter text type: terminate and relaunch
In the binding add your binding (i use shift-F5)
For "when" select "In Windows"
This will do it in single shorcut for you.
Or install relaunch plugin:
https://bitbucket.org/mantis78/relaunch-plugin/wiki/Home
which will enable you to restart anywhere
If you use "build automatically", there is a good chance that your changes are applied on the running program, on the fly. As such, most changes will be effective directly without a need to restart.
If there is a structural difference and Eclipse can't inject the new code (for example if you change anonymous classes, or inheritance patterns), then you will be prompted with a dialog inviting you to restart the application in one click:
Exceptions are when you change the value of a static variable (or of the initialization of a class that won't be executed again until you restart the application). In this case indeed, you will need to restart explicitly with another method.
the console view has a terminate button (a red square) which stops the execution. then another click on the Run button (the green circle with triangle) begins execution again.
thats what i do - 2 clicks :)
If you're using Eclipse with Spring you could download the "Spring Tools X" plugin.
This will automatically add a start and relaunch button to the top bar menu.
It should be available on any perspective.
I haven't found an elegant solution for this problem, but if your program is short running and you can live with a few instances here and there, you can just use the run command. Its default shortcut is Ctrl+F11. Every time you press this, your application will restart. BUT! If you press this while your application is still running, another instance will be run because the "old" instance won't be automatically terminated.
There are ways to really terminate your application using shortcut keys, but that requires setting breakpoints and then using the "terminate" command, and that isn't very elegant.
When developing my own network application, I have added a code to check if the older instance is running, and if so, then send an agreed command over network socket for graceful shutdown. While this approach may not be the best as universal solution, it allows clean shutdown of the previous instance, rather than just killing it.
Easy way without plugin, every Eclipse !
Click the project from of this icon at this time hold the shift Button, Project will restart (Terminate and relaunch) with server port also.

Using FileChooserButton in GTK+

I'm trying hard to find out how to use the file chooser button properly. Reading the reference manual on GtkFileChooserButton, GtkFileChooserDialog and GtkFileChooser didn't help so far. I've tried connecting to the undocumented signal file-set of GtkFileChooserButton and calling get\_filename() from here, but it seems to behave quite unreliably. When the user clicks the button and selects a file, it works fine so far.
But, if after clicking on the same button (which already has a filename set), the user changes his mind and closes the "open file" dialog, get\_filename() returns None (a Python type, i write it using pygtk) while the file remains set. Even more weird, if i call get_filename() on that button later from within another signal handler, the filename returns to what it previously had been set by the user. By the way, only closing the dialog box seems to cause the problem, pressing "cancel" works just fine.
Unclear question:
if you mean how to distinct between a valid chosen file:
if you call Run you will get a reponse:
Gtk::RESPONSE_ACCEPT if the user selected a file and accepted this file (clicked ok)
So only get the filename when the file is accepted.
if you mean how to reset filepath:
see gtk FileChooser -> set_ current_folder(filename) (without the space)