Unable to Access Currently running Background process "Credential Manager UI Host" for VPN connection app.
See original GitHub issueExpected Behavior
Need to Switch to Back-ground app and click on “Allow”.
Actual Behavior
My Script is able to trigger VPN app and pass credentials then connect to VPN. But New Security key POP-UP started coming, and I am not unable to switch to that pop up to select Allow Button. Please help me if it can be possible with Pywinauto or I need to use any other library in python.
Steps to Reproduce the Problem
- Below
Short Example of Code to Demonstrate the Problem
Below is my Script.
from pywinauto.application import Application
from subprocess import Popen,PIPE
from tkinter import ttk
import time
import tkinter as tk
def VPNConnect():
app = Application().start(r'C:\windows\system32\rasphone.exe -d "<VPN_app>"')
time.sleep(2)
app.VPN_app1.Connect.click()
dlg = app.top_window()
print(dlg)
dlg.Button.Allow.click()
time.sleep(5)
app.Warning.OK.click()
time.sleep(10)
app.VPN_app1.type_keys('user_id')
app.VPN_app1.type_keys("{TAB}")
app.VPN_app1.type_keys("{TAB}")
app.VPN_app1.type_keys("{TAB}")
app.VPN_app1.type_keys("{TAB}")
app.VPN_app1.type_keys("password")
time.sleep(2)
app.VPN_app1.type_keys("{ENTER}")
def VPNcheck():
cmd = ['%comspec% /c route print 10.10.10.0'] #Command for getting VPN connection status
result = subprocess.Popen('%comspec% /c route print 10.10.10.0', stdout=subprocess.PIPE, shell =True)
for line in result.stdout.readlines():
if b'<VPN_app1>' in line or b'<VPN_app2>' in line:
return True
return VPNcheck
def popupmsg(msg):
popup = tk.Tk()
popup.wm_title("!")
label = ttk.Label(popup, text=msg)
label.pack(side="top", fill="x", pady=20)
B1 = ttk.Button(popup, text="Okay", command = popup.destroy)
B1.pack()
popup.mainloop()
VPNcheck()
#Condition to check if the VPN is already connected and then call VPNConnect().
if VPNcheck() == True:
popupmsg('VPN is already connected')
else:
VPNConnect()
Below Is the error.
ElementNotFoundError Traceback (most recent call last)
<ipython-input-14-3dc39ad4f5a7> in <module>
53 popupmsg('VPN is already connected')
54 else:
---> 55 VPNConnect()
<ipython-input-14-3dc39ad4f5a7> in VPNConnect()
17 dlg = app.top_window()
18 print(dlg)
---> 19 dlg.Button.Allow.click()
20 time.sleep(5)
21 app.Warning.OK.click()
~\AppData\Roaming\Python\Python37\site-packages\pywinauto\findwindows.py in find_element(**kwargs)
85
86 if not elements:
---> 87 raise ElementNotFoundError(kwargs)
88
89 if len(elements) > 1:
ElementNotFoundError: {'best_match': 'Allow', 'top_level_only': False, 'parent': win32_element_info.HwndElementInfo - '&Cancel', Button, 1706668>, 'backend': 'win32'}
Specifications
- Pywinauto version: NA
- Python version and bitness: Version 3.7.4
- Platform and OS: Windows 10
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Troubleshoot Azure point-to-site connection problems
Go to C:\Users<UserName>\AppData\Roaming\Microsoft\Network\Connections\Cm<GUID>, manually install the certificate (*.cer file) on the user ...
Read more >The VPN seems connected but I can't connect to my server or ...
There are a number of possible causes for such a behavior. This FAQ will help you to find out what is causing the...
Read more >Known Issues - Ivanti
Symptom: Failure message displays when VPN connection is established with HC remediation. Condition: Connect to VPN with HC remediation. Workaround: With ...
Read more >How to fix 8 common remote desktop connection problems
2. Firewall problems · Open the Control Panel by entering Control at the Windows Run prompt · Click System and Security · Click...
Read more >Addressed Issues in GlobalProtect App 5.2 - Palo Alto Networks
Fixed an issue where the GlobalProtect app could not connect to the Prisma ... using a Two-Factor Authentication (2FA) authentication method as expected....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You have to inspect which attributes the control actually exposes. Use the
print_control_identifiers()method of pywinauto. And/or for more inspection use inspect.exe or the new MS accessibility insight tool.Did you verify procesd id of your pop up? You can do it with Inspect.exe utility, as suggested by @michel117 . As a debug step, you could hard code the pid and try to connect to it. Also, did you try to run your script as admin, to eliminate permissions problems?