from django.shortcuts import render
from django.http import HttpResponse
from pywinauto.application import Application
from pywinauto.keyboard import send_keys
from pywinauto import mouse
def get_pid(name): # define function get process_pid
pids = psutil.process_iter()
for pid in pids:
if(pid.name() == name):
process=get_pid(“HsCMP.exe”) #it works
app = Application(backend=“uia”).connect(process=get_pid(“HsCMP.exe”)) # it no works why?
return HttpResponse(“Hello, world. You’re at the polls index.”+str(process))
HttpResponse Server Error (500)
I run the python script alone and it works, I only wrote one line of code"app = Application(backend=“uia”).connect(process=get_pid(“HsCMP.exe”))",and it no works why? Can somebody help me?
I don’t have an answer for you, but I do have a couple things that might help you diagnose the problem.
First, how are you running Django? Are you running this from the command line using runserver or runserver_plus? If so, check the console log where that’s running - that should have a more detailed error message.
You could also turn debug on in your settings to get a more detailed response - that may provide more information beyond just the 500.
Also, you could try running that from within the Django shell (or shell_plus) and see what error messages you may receive.
You might also want to check the Windows event log to see if something was logged in there.
I think you’re going to need to find more information about what’s actually happening before you can identify a solution.
Thank you very much !!!
According to your reminder, I found a solution.
Thank you very much indeed !!!