In a post of november last year, I explained on how to automate a qlikview process with python using a class I’ve made for this purpose.
Now is time to see if we can play with some qliksense desktop automation. What i’m going to show is really basic: from python we will be able to start QlikSense and proceed with log in.
Before to begin, we need to have qliksense desktop already installed , defined username and password, log in at least one time having the remember password flag set.
We are going to use two main library, subprocess to start qliksense and pywinauto to automate the button to press for login.
Looking at the code, Subprocess.Popen start qliksense process and send info to standard output using a pipe. this because Qliksense when start, return a list of node process with PID number.
Next, we can see a while loop parsing lines returned by qliksense until it found the one representing the main process window.
So at the end the PID is defined, pywinautois connected trough the PID to the qliksense process to find the Qliksense desktop window, once found it, put the window on focus and after the dialog search for the LOG IN BUTTON, if found, will press on it. You may have to adjust the connection timeout increasing or decreasing the value according your installation. Also you may have to change the app_dialog["LOG IN"] according your locale language, for example Italians will put app_dialog["ACCEDI"]
A last note: the print(app_dialog.print_control_identifiers()) will show you all the controlrelated to the qsense window so it will be possible to enter username and password programmatically.
Here the source code used with python 3.7, pywinauto 0.6.8, QlikSense November 2019 :