getmo96 Posted December 30, 2008 Share Posted December 30, 2008 I have some code I used to close out projects in SAP. It is a simple loop and I have a issues with the SAP timing out. Then the script fails. I wan to add an if statement saying if system timesout then continue on the list in the normwl loop. Dim $ProjectNum Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) Opt("MouseCoordMode",0) WinWait("Project Builder: Project EUSMB.MOC.000036","") If Not WinActive("Project Builder: Project EUSMB.MOC.000036","") Then WinActivate("Project Builder: Project EUSMB.MOC.000036","") WinWaitActive("Project Builder: Project EUSMB.MOC.000036","") For $ProjectNum = 0000037 To 000574 Step 1 Send("{CTRLDOWN}{F2}{CTRLUP}") Sleep(2500) Send ("{ALT}!e") Sleep(2500) Send ("{DOWN}{DOWN}{DOWN}{RIGHT}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{RIGHT}{ENTER}") Sleep(2500) Send ("{ALT}!p") Sleep(3000) Send("{DOWN}{DOWN}{ENTER}") WinWait("Open Project","") If Not WinActive("Open Project","") Then WinActivate("Open Project","") WinWaitActive("Open Project","") Sleep(3000) Send("EUSMB.MOC.") Send($ProjectNum) Send("{ENTER}") WinWait("Close the project and open another","") If Not WinActive("Close the project and open another","") Then WinActivate("Close the project and open another","") WinWaitActive("Close the project and open another","") Send("{ENTER}") Sleep(30000) Next Link to comment Share on other sites More sharing options...
TurionAltec Posted December 30, 2008 Share Posted December 30, 2008 I am trying to automate a process with a SAP frontend daabase.... A lot of point and click, and there are just lists of projects I get from fellow peers at work. As you can see I am running the same porcess for everything in excel column. Anywayz I need am having trouble because the remote host where the app is running, has a heave traffic load which eats up processor time. I need to insert a if statment that identifies an error and the end user has to click a button to continue. I want the script to not stop and continue completeion of the list provided. Later I will get fance and add a logfile. I'll b workin it for now any advice will help. I am a Linux/Unix guy, but helping friends with a little VB. Hi getmo96, Please stop triple posting. It wastes people's time. The line If Not WinActive("Close the project and open another","") Then WinActivate("Close the project and open another","") can be replaced by simply WinActivate("Close the project and open another","") And the line For $ProjectNum = 0000037 To 000574 Step 1 Step 1 is assumed To address your main issue, are you trying to catch an error message that may appear at any time? You might try using an adlibenable that will periodically run and check for the existence of the window. If the error will only occur at a certain time in the process, what point is it? From the example in the help file: AdlibEnable("myadlib") ;... Exit Func myadlib() If WinActive("Error") Then ;... EndIf EndFunc Also if you're dealing with Excel, you might be interested in the Excel UDF http://www.autoitscript.com/forum/index.php?showtopic=34302 This lets you interface more directly with Excel Link to comment Share on other sites More sharing options...
Negative1 Posted March 5, 2009 Share Posted March 5, 2009 It is a simple loop and I have a issues with the SAP timing out. Then the script fails. SAP is timing out while processing something? if this is the case maybe you can use my wait system. This will cause the function to loop until sap is done processing. Anytime you press enter or change sub windows or process anything in sap the exstyle of the window changes during the processing. Func sapwait($title) $hWnd = WinGetHandle($title) $exstyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) while $exstyle = 256 $exstyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) sleep(50) WEnd EndFunc Hope this works for you... once i started using this function for my waits i had much more accurate sap scripts. Negative1 What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now