Jump to content
Sign in to follow this  
DerKiLLa

Run Application behind Lockscreen

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

@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!

Share this post


Link to post
Share on other sites

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. 

 

2018-10-25 16_07_49-mRemoteNG - confCons.xml - de001ap0015 - SAP_Maringo DB_SQL.png

Share this post


Link to post
Share on other sites

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.

 


hmm... I guess I have to have a signature...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

@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 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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...