Skip to content
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

pywintypes.error : (0, 'SetCursorPos', 'No error message is available') on using Regex #396

Closed
jagadeesh1983 opened this issue Aug 1, 2017 · 8 comments
Labels

Comments

@jagadeesh1983
Copy link

jagadeesh1983 commented Aug 1, 2017

Hi,

I am using Python 2.7 (64 bit) with pyWinAuto 0.6.3 (64 bit) on Windows 2012 R2 (64 bit) to automate 64-bit application.
I am getting following error when we use regex for title_re.

<class 'pywintypes.error'>: (0, 'SetCursorPos', 'No error message is available')

Here is my Code snippet:

app = application.Application().connect(title_re='.*Application Designer.*')
app.window_(title_re = 'Application Designer.*').MenuSelect('File->Delete')

However, when we connect to our application by giving complete name of window through title then we are not facing above mentioned issue.

Below code works fine:

app = application.Application().connect(title='Application Designer - Untitled')
app.window_(title_re = 'Application Designer.*').MenuSelect('File->Delete')

Please let me know how to fix this issue if I need to use regex in my pywinauto code.

Thanks,
Jagadeesh

@vasily-v-ryabov
Copy link
Contributor

Hi @jagadeesh1983 do you run the script as Administrator? It looks like insuffient privileges issue so far.

@jagadeesh1983
Copy link
Author

Hi Vasily,

Yes, I have logged in to the Windows 2012 R2 machine as administrator and ran the script.

Thanks,
Jagadeesh

@vasily-v-ryabov
Copy link
Contributor

It might be insufficient to login as administrator (if UAC is enabled, default runtime mode could be non-privileged). Try popup menu "Run as Adminiostrator" for the script or your IDE.

@vasily-v-ryabov
Copy link
Contributor

Hi @jagadeesh1983 is the issue still relevant?

@bugmeout
Copy link

same problem on win7 server2012 R2. it's not stable, sometimes goes wrong.

traceback like that:

Traceback (most recent call last):
  File ".\haha.py", line 165, in <module>
    print getHRloginstatus(hr_watcher)
  File ".\haha.py", line 114, in getHRloginstatus
    user_ctrl.type_keys(getrandom_str())
  File "C:\Python27\lib\site-packages\pywinauto\base_wrapper.py", line 852, in type_keys
    self.set_focus()
  File "C:\Python27\lib\site-packages\pywinauto\controls\hwndwrapper.py", line 1285, in set_focus
    mouse.move(coords=(-10000, 500))  # move the mouse out of screen to the left
  File "C:\Python27\lib\site-packages\pywinauto\mouse.py", line 232, in move
    _perform_click_input(button='move',coords=coords,button_down=False,button_up=False)
  File "C:\Python27\lib\site-packages\pywinauto\mouse.py", line 125, in _perform_click_input
    win32api.SetCursorPos((coords[0], coords[1]))
pywintypes.error: (0, 'SetCursorPos', 'No error message is available')

@jagadeesh1983
Copy link
Author

Hi Vasily,

I am not working on pyWinAuto project now. So that issue is not relevant for me.
You can close this ticket if you want.

Thanks,
Jagadeesh

@lippinj
Copy link

lippinj commented Feb 7, 2018

I'm running into the same error when attempting to run a script on a Windows VM as part of a robotframework test, but only when running it without a Remote Desktop connection. If I'm connected to the machine when the script runs, everything works fine and I can observe the effects on the application that's being automated.

The error occurs in the function:

def gui_click_save(self):
  """Clicks File->Save in the menu."""
  m = self.main_form.Menu()
  m_file = m.GetMenuPath('File')[0].SubMenu()
  m_file_save = m_file.GetMenuPath('Save')[0]
  m_file_save.click()

Edit: in my case, enclosing self.ctrl.set_focus() at menuwrapper.py:323 in a try..catch block seems to allow the script to run as intended. Apparently, at least SetCursorPos and SetForegroundWindow fail in the case of the VM without an active Remote Desktop session.

@vasily-v-ryabov
Copy link
Contributor

Hi @lippinj this problem is not pywinauto related (though error message might be more meaningful), because RDP window provides GUI context for an automation. See issue #401 with more details on how to resolve it different ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants