Reputation: 105
In my work I have access to a Windows 365 virtual machine where the company code runs 24/7. Sometimes there a SAP disconnection, Zscaler problem or other strange situation that is hard to keep track. I setup a python piece of code to perform a pyautogui.screenshot() so I can get a glimpse of maybe happen before the system move on. This work when I logged on the VM, but doesn't when not logged. I don't really understand the situation because the error message is not helping. "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 don't know if there a security measure from the VM configuration or something related of how VM works without logged accounts. The python code seen to run correctly for RPA.
The code:
def log(robot_name: str) -> None:
"""Take screenshot from current screen and from zscaler state, save in 2 places:
1 - place where Onedrive only access
2 - inside own machine HD where Onedrive do not share
:rtype: None"""
# screenshot
try:
Logger.log_i("Taking Screenshot")
screenshot = pyautogui.screenshot()
screenshot.save(f"{SS_DIR}\\{robot_name}_{TODAY}.png")
screenshot.save(f"{SS_SAFE_DIR}\\{robot_name}_{TODAY}.png")
Logger.log_i("Screenshot done")
except Exception as e:
Logger.log_e("Unable to Take Screenshot")
Logger.log_e(str(e))
try:
# Open ZScaler take screenshot and close it
Logger.log_i("Taking Zscaler Screenshot")
sleep(1)
pyautogui.press("win")
sleep(1)
pyautogui.typewrite('zscaler')
sleep(1)
pyautogui.press("enter")
sleep(4)
screenshot = pyautogui.screenshot()
screenshot.save(f"{SS_DIR}\\{robot_name}_{TODAY}_zscaler.png")
screenshot.save(f"{SS_SAFE_DIR}\\{robot_name}_{TODAY}_zscaler.png")
sleep(4)
pyautogui.hotkey('alt', 'f4')
Logger.log_i("Zscaler Screenshot done")
except Exception as e:
Logger.log_e("Unable to Take Screenshot")
Logger.log_e(str(e))```
Upvotes: 0
Views: 14