Jump to content

wait function using ExStyle


Recommended Posts

I am currently writing a script for SAP without using the scripting GUI.

In order to account for the many times that i have to wait on SAP to process something I have wrote this function:

Func sapwait()
    $hWnd = WinGetHandle("[active]")
    $exstyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    while $exstyle <> 272;sap exstyle 256 means sap is processing something. 272 means SAP is Idle
        $hWnd = WinGetHandle("[active]")
        $exstyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
        sleep(250)
    WEnd

EndFunc

When SAP is processing something ExStyle = 0x00000100 Idle ExStyle = 0x00000110 according to autoit window info tool.

However i find this function usually returns to the main program too quickly and therefore my script starts back up at the wrong time.

Any Ideas?

Thanks,

-1

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

Try this:

Func sapwait()    $hWnd = WinGetHandle("[active]")


    $exstyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    while $exstyle <> 272;sap exstyle 256 means sap is processing something. 272 means SAP is Idle
       $hWnd = WinGetHandle("[active]")
       $exstyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
       sleep(250)
    WEnd

       sleep(250); added

EndFunc

I have some Autoit scripts for our IS similar to SAP and I use this for waiting till button is enabled:

While ControlCommand('Title', "", "Button1","IsEnabled","") = 0
 Sleep(50)
WEnd

While ControlCommand("Title", "", "ListBox1", "FindString", " ---------- Finished" ) = -1
       Sleep(100)
    WEnd

While 1
 $text = WinGetText('Title') 
 If StringInStr($text, 'Some text') > 0 Then ExitLoop
 Sleep(100)
WEnd
Sleep(500)

You may also check state of cursor or some controls inside main application.

Edited by Zedna
Link to comment
Share on other sites

I am currently writing a script for SAP without using the scripting GUI.

In order to account for the many times that i have to wait on SAP to process something I have wrote this function:

Func sapwait()
    $hWnd = WinGetHandle("[active]")
    $exstyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
    while $exstyle <> 272;sap exstyle 256 means sap is processing something. 272 means SAP is Idle
        $hWnd = WinGetHandle("[active]")
        $exstyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE)
        sleep(250)
    WEnd

EndFunc

When SAP is processing something ExStyle = 0x00000100 Idle ExStyle = 0x00000110 according to autoit window info tool.

However i find this function usually returns to the main program too quickly and therefore my script starts back up at the wrong time.

Any Ideas?

Thanks,

-1

Hi Negative1,

I agree. Autoit needs longer break's soo i put after every sapwait a sleep 250. Your 250 miliseconds are not executed at the end of the cript, so i alwys put an extra wait of 250 miliseconds. This works fine........

Sometime's i also wait at a message to come in the statusbar. Thanks for the code by-the-way.

If there is an other option, please share!

Best regards,

Rody

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...