I am too lazy to always enter commands in cmd. I found that qtp can be used to open cmd. Well, I can be too lazy to enter commands in cmd.
Run qtp in eclipseCode:
Import win32com, win32com. Client
I = 1
while (I <3):
qtp = win32com. client. dispatch ("quicktest. application ")
# Starts up qtp
qtp. launch ()
# Make the qtp window visible
qtp. visible = true
# open a test, replace the path
qtp. open ('e: \ hpqtpworkspace \ opencmd % d' % (I)
# To open a qtp test in Quality Center
# qtp. open (R "[qualitycenter] Subject \ Foldername \ qtpscript")
# create a runresultsoptions object
qtresultsopt = win32com. client. dispatch ("quicktest. runresultsoptions ")
# Set the location to where the results will be save
qtresultsopt. resultslocation = "E: \ hpqtpworkspace \ opencmd % d \ RES1" % (I)
qtp. test. run (qtresultsopt)
Print "test has % s" % qtp. test. lastrunresults. status
# Close the test
qtp. test. close ()
# Quit qtp
qtp. quit ()
So that I can run two monkeyrunner scripts.
Opencmd1 code:
Systemutil. Run "cmd.exe", "", "C: \ WINDOWS \ System32", "open"
'Close the Input Method
Window ("Object Class: = lelewindowclass"). Type micshiftdwn
Window ("Object Class: = lelewindowclass"). Type micshiftup
'Switch to the monkeyrunner directory.
Window ("Object Class: = lelewindowclass"). Type "E :"
Window ("Object Class: = lelewindowclass"). Type micreturn
Window ("Object Class: = lelewindowclass"). Type "cd e: \ Android \ androidsdkwindows \ tools"
Window ("Object Class: = lelewindowclass"). Type micreturn
'Get picture
Window ("Object Class: = lelewindowclass"). Type "monkeyrunner test \ capturescreen. py"
Window ("Object Class: = lelewindowclass"). Type micreturn
Wait (60)
Window ("Object Class: = lelewindowclass"). Type "exit ;"
Window ("Object Class: = lelewindowclass"). Type micreturn
Opencmd2 code:
Systemutil. Run "cmd.exe", "", "C: \ WINDOWS \ System32", "open"
'Close the Input Method
Window ("Object Class: = lelewindowclass"). Type micshiftdwn
Window ("Object Class: = lelewindowclass"). Type micshiftup
'Switch to the monkeyrunner directory.
Window ("Object Class: = lelewindowclass"). Type "E :"
Window ("Object Class: = lelewindowclass"). Type micreturn
Window ("Object Class: = lelewindowclass"). Type "cd e: \ Android \ androidsdkwindows \ tools \ test"
Window ("Object Class: = lelewindowclass"). Type micreturn
'Get picture
Window ("Object Class: = lelewindowclass"). Type "Python compareimage. py"
Window ("Object Class: = lelewindowclass"). Type micreturn
Wait (5)
Window ("Object Class: = lelewindowclass"). Type "exit ;"
Window ("Object Class: = lelewindowclass"). Type micreturn
It was done, but the implementation was not very good and it had to be improved.