-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyautogui does not work as windows service #869
Comments
import os
import pyautogui
from flask import Flask, request, abort
app = Flask(__name__)
# Environment variable to control pyautogui actions
ENABLE_PYAUTOGUI = os.getenv("ENABLE_PYAUTOGUI", "False") == "True"
def check_authentication():
# Replace with your authentication logic
auth_token = request.headers.get("Authorization")
if auth_token != "your-secret-token":
abort(403)
@app.route("/")
def index():
check_authentication()
if ENABLE_PYAUTOGUI:
pyautogui.press("win")
return "Hello World"
if __name__ == '__main__':
app.run(debug=True, host="127.0.0.1", port=5000)
From: Humburto ***@***.***>
Sent: Friday, August 2, 2024 10:23 AM
To: asweigart/pyautogui ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [asweigart/pyautogui] pyautogui does not work as windows service (Issue #869)
[External Email]
I wrote a simple app with pyautogui and flask as follow. When I request http://{ip}/<http://%7bip%7d/>, the "windows" key should be pressed(so the windows start menu should appear).
import pyautogui
from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
pyautogui.press('win')
return "hello world"
if __name__ == '__main__':
app.run(host="0.0.0.0", port="80")
When I run this app in a terminal, it works as expected. However, when I warp it to a windows service with nssm(the non-sucking service manager), it does not work any more.
When I request the url, pyautogui raise some errors about failsafe:
[2024-08-02 22:05:12,577] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "D:\code\media-remote\.venv\Lib\site-packages\flask\app.py", line 1473, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\code\media-remote\.venv\Lib\site-packages\flask\app.py", line 882, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\code\media-remote\.venv\Lib\site-packages\flask\app.py", line 880, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\code\media-remote\.venv\Lib\site-packages\flask\app.py", line 865, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\code\media-remote\test.py", line 8, in index
pyautogui.press('win')
File "D:\code\media-remote\.venv\Lib\site-packages\pyautogui\__init__.py", line 593, in wrapper
failSafeCheck()
File "D:\code\media-remote\.venv\Lib\site-packages\pyautogui\__init__.py", line 1734, in failSafeCheck
raise FailSafeException(
pyautogui.FailSafeException: PyAutoGUI fail-safe triggered from mouse moving to a corner of the screen. To disable this fail-safe, set pyautogui.FAILSAFE to False. DISABLING FAIL-SAFE IS NOT RECOMMENDED.
I tried set pyautogui.FAILSAFE= False to disable failsafe then it did not raise above errors, but the windows start menu also did not appear( which means the windows key was not pressed).
Any help will be appreciated, thanks.
-
Reply to this email directly, view it on GitHub<#869>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AHELSLJ7FEDCIPHKU5GSLCTZPOI3VAVCNFSM6AAAAABL4UUM5SVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ2DKMBWHA2TQNA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***>>
This email contains links to content or websites. Always be cautious when opening external links or attachments.
Please visit https://carleton.ca/its/help-centre/report-phishing/ for information on reporting phishing messages.
When in doubt, the ITS Service Desk can provide assistance. https://carleton.ca/its/chat
-----End of Disclaimer-----
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wrote a simple app with pyautogui and flask as follow. When I request
http://{ip}/
, the "windows" key should be pressed(so the windows start menu should appear).When I run this app in a terminal, it works as expected. However, when I warp it to a windows service with nssm(the non-sucking service manager), it does not work any more.
When I request the url, pyautogui raise some errors about failsafe:
I tried set
pyautogui.FAILSAFE= False
to disable failsafe then it did not raise above errors, but the windows start menu also did not appear( which means the windows key was not pressed).Any help will be appreciated, thanks.
The text was updated successfully, but these errors were encountered: