Jump to content

waiting for window for to long (time out 500+?)


Go to solution Solved by SmOke_N,

Recommended Posts

Just to be clear by "AdLibRegister was able to register the function" you means it found the window, or that its run trhough the function?

With AdLibRegister you tell AutoIt to call a function every x milliseconds. AdLibRegister returns 1 (success) when the function you specifies exists. It doesn't tell you that the function was executed, just that it was registered successfully.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators
  • Solution

I'm not sure if I understand all of what is being asked.  It sounds like the app is hung up during all of the processing and you're just waiting for it to become usable again.

Then it's you and water testing different things and I start to lose site of the original question.

Anyway, I'll just throw this in, there's an api call IsHungWindow that may come in handy for it... wrapping it around a timer function could help your endeavor... something like:

#include <WinAPISys.au3>

Func _WaitForNotHung($hWnd, $iTimeOutSeconds = Default) ; default = no timeout waiting

    ; best to pass a hwnd than to go through all this no?
    If Not IsHWnd($hWnd) Then
        $hWnd = WinGetHandle($hWnd)
        If Not IsHWnd($hWnd) Then
            $hWnd = HWnd($hWnd)
            If Not IsHWnd($hWnd) Then
                Return SetError (1, 0, 0)
            EndIf
        EndIf
    EndIf

    $iTimeOutSeconds = ((IsKeyword($iTimeOutSeconds) Or _
        $iTimeOutSeconds > 0) ? 0 : ($iTimeOutSeconds * 1000))

    Local $iTimer = TimerInit()

    While _WinAPI_IsHungAppWindow($hWnd)
        Sleep(250)
        If $iTimeOutSeconds And TimerDiff($iTimer) > $iTimeOutSeconds Then
            Return SetError(1, 0, 0)
        EndIf
    WEnd

    Return 1
EndFunc

This could eliminate the need for adlibregister/unregister.  But this will wait for that window to become un-hung indefinitely if a timer is not set ahead of time.

Edited by SmOke_N
fixed ternary output

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Edit: I was digging around and after searching different functins i found the Func...Return...EndFunc shouldn't i use this instead of adlib register? I mean it could theoraticly be like that i call a function which always return 0 for example untill he doesn't find the window, then it returns 1 and that is the signal/flag for UD_informaciok to pop a window of complete! and return the entire thing in to idle

AdLibRegister was used because WinWaitActive can't be interrupted. You wanted to display a GUI while waiting for a Window to exist PLUS the ability for the user to cancel the process anytime.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I tink I get it, that would explain why all my previus tries went wrong :)

Func Figyelmeztetes()

    Local $ans
    If Not WinExists("UD Operátor") Then
        MsgBox(0, "Üzenet", "Kérem nyissa meg az UD_OPER programot!", 10)
        Return
    EndIf
    $ans = MsgBox(4, "Üzenet", "Ez a lekérdezés több mint 10 percig is eltarthat!" & @CRLF & "Kívánja futtatni?")

    If $ans = 6 Then UD_informaciok()
    If $ans = 7 Then Return

EndFunc   ;==>Figyelmeztetes

Func UD_informaciok()

    ;Local $bWindowFound = False
    Local $checkwindow = 0
    ControlClick("UD Operátor", "", "[CLASSNN:TAdvBitBtn6]")
    WinWaitActive("Dátum beállítás", "")
    ControlClick("Dátum beállítás", "", "[CLASSNN:TBitBtn1]")

    AdlibRegister("_CheckWindow", 1000)

    While True
        Switch AdlibRegister("_CheckWindow", 1000)
            Case 0
                ExitLoop ;goes back to While True loop
            Case 1
                Return ;goeas back to idle, ready for the next order or anything
        EndSwitch
    WEnd


    #cs
        While True
        If AdlibRegister("_CheckWindow", 1000) = 1 Then $checkwindow = 1
        If $checkwindow = 1 Then
        MsgBox(0, "Test", "Window found")
        AdlibUnRegister("_CheckWindow")
        Return
        EndIf
        WEnd
    #ce
EndFunc   ;==>UD_informaciok

Func _CheckWindow()

    Local $sTitle = "Információk"
    If WinExists($sTitle) Then
        MsgBox(0, "Üzenet", "Lekérdezés kész", 10) ;meaning: "Message", "Query complete"
        AdlibUnRegister("_CheckWindow")
    EndIf

EndFunc   ;==>_CheckWindow

i switched to this, right now, and the results were kind of the same (it returned idle as i wanted to so its better :) )

Link to comment
Share on other sites

Thnaks SmOke_N I will look into it!

Well I'm not sure if my original goal had anypoint at all, I mean once we started the query the user cant really interrupt it using my scripts, I try to teach my script to find the window when it pops up and tell the user that now he can continue to do what ever, and till then "froze" my script to somehow so they dont try to cummunicate with the program since its unresponsive mostly while its working on this specific thing. Thus if i allowe my user to return idle and start other function while the program its working on is still trying to geather the query I just invite errors left and right!

Pls tell me if my logic flow is incorrect, or if you think i should set different goals

Link to comment
Share on other sites

What is this line supposed to do?

    Switch AdlibRegister("_CheckWindow", 1000)




			
		

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

When I wrote this I still thought that Adlib returns 1 when it found the window, now that isn't sounding that possible, since it doesn't really understand what's the function is doing there, and _CheckWindow doesnt have any return value

Edit: I tried to build it according to the help file, it used @HOUR for it there and basicly did something similar

Edited by SorryButImaNewbie
Link to comment
Share on other sites

  • Moderators

If you want to tell the user if a window is able to be used, use the _WinAPI_IsHungAppWindow method (you don't really need the wrapper I wrote).

As far as intervals in checking, well it seems you and water have that under control.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I'm not sure if I understand all of what is being asked.  It sounds like the app is hung up during all of the processing and you're just waiting for it to become usable again.

Then it's you and water testing different things and I start to lose site of the original question.

code

This could eliminate the need for adlibregister/unregister.  But this will wait for that window to become un-hung indefinitely if a timer is not set ahead of time.

I dont blame you for that Master Smoke_N , I'm not sure I would be able to follow from the start while every 2 comment is mine   :D There wasn't really an original question but an aim. Master Water here tries to help me and i learn (i hope so) with every turn basicly for which im thankful.

Also I think this API could be just the thing that solve the problem, I'm not sure that the window is totaly unresponsive all the time, but there could be an innate defense in the program not to allow the users to do things while it works, basicly just like what i wanted to do, and this way I could just follow their (the other coders) original solution basicly!

Edited by SorryButImaNewbie
Link to comment
Share on other sites

Glad to be of service :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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