DerKiLLa Posted October 25, 2018 Share Posted October 25, 2018 Hello, i'm new to AutoIT I have a problem with my script ... the script starts SAP Business One, then log in, then runs a app within SAP and closes SAP. It does run without problems, when i am logged in. But it has to run as a scheduled task at night and when i'm not connected, it stays in the lockscreen. And then the script does not run. It starts SAP, but can't find the window to control the application. So i only get the "SAP not found" message. Local $iPID = Run("C:\Program Files (x86)\SAP\SAP Business One\SAP Business One.exe", "", @SW_SHOWMAXIMIZED) WinActivate("SAP Business One 9.2") $hwnd = WinWaitActive("SAP Business One 9.2", "", 10) If $hwnd = 0 then msgbox(0,"Not found", "SAP not found") Else Sleep(5000) Send("!r") ... ProcessClose($iPID) EndIf Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted October 25, 2018 Moderators Share Posted October 25, 2018 @DerKiLLa welcome to the forum. You are learning first hand how unreliable scripts with Send, MouseClick, etc. are, especially when trying to run as a scheduled task. Take a look at the Control* commands in the help file, such as ControlSend and ControlClick. It has been a long time since I administered SAP applications; you will need to use the AutoIt Window Info Tool (in the same directory where you installed AutoIt) to determine if you can capture and manipulate the various controls on the window. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
DerKiLLa Posted October 25, 2018 Author Share Posted October 25, 2018 I tried ControlSend, but you cant use it with SAP Business One ... u dont have controls for Buttons. I use ControlClick in the Script, but i can't use ControlSend. Because Buttons like "OK" oder "Firma wechseln" dont have their own control. Link to comment Share on other sites More sharing options...
BigDaddyO Posted October 25, 2018 Share Posted October 25, 2018 Not sure if Locked is the same as disconnected, but it's possible there is no desktop to interact with. if that's the case you can't activate a window and there will never be an active window. Try switching to WinExists to see if it can even see the window. If it's there, you may need to switch over to IUI automation which is much more complicated but it should work for you. Link to comment Share on other sites More sharing options...
Juvigy Posted October 29, 2018 Share Posted October 29, 2018 Easiest is to try with mouse clicks via coordinates. Keep in mind that if there is no user logged in it will never work as when no one is logged in - you dont have any 'windows' that you can interact with. Link to comment Share on other sites More sharing options...
jdelaney Posted October 29, 2018 Share Posted October 29, 2018 (edited) @juvigy, that is not correct at all. You can interact with windows on session 0, but the windows will never become active, and no variation of send will work because of that. instead use winexist and controlsettext and controlclick. Edited October 29, 2018 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Juvigy Posted October 30, 2018 Share Posted October 30, 2018 I know, but as the user stated above - ControlSend cant be used in his case. This is why i wrote what i did in the context of this special case. Link to comment Share on other sites More sharing options...
jdelaney Posted October 30, 2018 Share Posted October 30, 2018 Just be careful not to mislead people. You WILL have windows even when running outside of a user session or locked desktop. those windows will NOT have certain states such as "active" IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Juvigy Posted October 31, 2018 Share Posted October 31, 2018 Thanks for the clarification, it seems i didnt express myself correctly. 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