4

I am trying to use pywinauto to automate TomCat to start and stop every time I update the class files. However, when I try and run it it gives me the following warning:

UserWarning: 32-bit application should be automated using 32-bit Python (you use 64-bit Python)

I am pretty sure I have the 64-bit version of my desired program (Even reinstalled to make sure). Is there any way to skip this warning so the program can execute? Or is this not possible? (Tomcat is even installed in program files instead of program files(x86).) If the case is that I have to use the 32-bit version of python to do this, how can I install pywinauto for both the 32-bit and 64-bit version of python? I tried running it with 32-bit version of python but it says the "pywinauto" module is not recognized, even though I ran pip install pywinauto.

EDIT: The program "worked" despite the warning message. It just informed me that I should use 32-bit python. Even though the code for tomcat did not work( I have no idea why, even used SWAPY to make sure code is correct, but it would still not work). Here is some code that did not execute as expected (i.e nothing happened)

def tomCatAuto():
    app = Application().Connect(title=u'Apache Tomcat 8.0 Tomcat8 Properties', class_name='#32770')
    window = app.Dialog
    button = window.OK
    button.Click()
DanZoe
  • 111
  • 1
  • 3
  • 15
  • Does 32-bit Python usage help with installed pywinauto? If still no, please provide some code to reproduce the issue and a download link for Tomcat software if it's free available. – Vasily Ryabov Dec 06 '15 at 15:35
  • Hi, @VasilyRyabov Here is the download link: http://apache.uib.no/tomcat/tomcat-7/v7.0.65/bin/apache-tomcat-7.0.65.exe Also added some code in the original post. The issue was not compatibility-related(i think). I tried it on another program and it worked even though I got the same warning message. Pywinauto just seems to behave strangely when trying to automate TomCat. Want to give it a try? – DanZoe Dec 07 '15 at 20:45
  • Yep, I see `Tomcat7w.exe` process is really 32-bit. So you need to run 32-bit Python to automate it. Also make sure Python+pywinauto is running as Administrator. – Vasily Ryabov Dec 08 '15 at 10:09
  • 1
    For me it even works with 64-bit Python (running as Administrator). – Vasily Ryabov Dec 08 '15 at 10:17
  • Hi, @VasilyRyabov I tried running as administrator. Did not get any error messages, but when I run the code I posted TomCat suddenly crashes (common daemon service not responding). Did you try out my exact code? – DanZoe Dec 08 '15 at 20:10
  • I tried it, but v7.0 daemon seems not crashed for me. – Vasily Ryabov Dec 08 '15 at 20:39
  • Very weird. I got tomcat 8.0. This is a program that should be automated because every time you make a change to a servlet you need to turn it on and off. I will try the 7.0 version but doubt it will make a difference. – DanZoe Dec 08 '15 at 23:18
  • You can try `ClickInput` method that behaves like a real user. Maybe the app handles it in a different way. – Vasily Ryabov Dec 14 '15 at 07:57
  • @VasilyRyabov Still does not work. Surrouned the method call with a try-except and it excepted. Whenever I run the above code with ClickInput daemon crashes, Can you try the code I have written? – DanZoe Dec 14 '15 at 17:41
  • Is the daemon crashed when doing the job manually? If no, which parameters are set in the daemon? – Vasily Ryabov Dec 14 '15 at 18:58

1 Answers1

6

To make sure the program is really 64-bit you may open the Task Manager and take a look at "*32" suffix presence in the process name. If it's shown, the process is really 32-bit (probably it's a bug in TomCat installer?).

To install pywinauto for non-default Python on your system you need to specify full path to the pip.exe like so:

C:\Python27_32\scripts\pip.exe install pywinauto

EDIT: I see Tomcat7w.exe process is really 32-bit. So you need to run 32-bit Python to automate it. Also make sure Python+pywinauto is running as Administrator.

P.S. 64-bit Python+pywinauto may work for 32-bit process (that's why there is a warning only, not error). Sometimes users have problems with a TreeView control when the process is of incorrect bitness.

Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78