Sign in to follow this  
Followers 0
Negative1

wait function using ExStyle

4 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

I do know that there is a time lapse between the time the style changes and the time the window changes. That is about all I can help you with.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
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

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  
Followers 0