Jonovision77

Need help with winwaitactive

9 posts in this topic

Hi this is my first time asking for help, I usually find a solution online but this one has stumped me. I am working with a business retail software and I have noticed a very annoying feature with the software, it doesn't matter what window or tab I am on the hidden text is almost always the same because the more tabs I visit the number of hidden text items grow, which pretty much eliminates the usefulness of the text portion of winwaitactive("title", "text"). Is there a way that I can use only the visible text in identifying a window/tab? The reason I need this to work is because I have a while loop that is intended to only activate the hotkeys on the final page of the software.

While 1
  WinWaitActive("Retail Merchant","") ;no text here because the software in open
    While WinWaitActive("Retail Merchant","visible text")
    Call("_HotKeys")
    Sleep(200)
  WEnd
  Sleep(200)
WEnd
 
Or is there any other way of identifying a page with a unique value that doesn't change upon reloading the system or software?
 
Thank you

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

WinGetHandle() will return the internal handle of a window.

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

Because the hot keys are active the moment the receipt page is visited, which has a hidden text value of TenderPage but it is not listed under visible text until the final receipt page is visited. This is the text I used on the second while command and the loop activates early.

Share this post


Link to post
Share on other sites

Is there a way that I can use only the visible text in identifying a window/tab?

Use

Opt("WinDetectHiddenText", 0)

to specify that hidden window text can not be "seen" by the window matching functions.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

What do you mean by 'tab'.

Output the AutoIT window info tool, while focused on your tab.

If it truly is a tab, you can use the _GuiCtrlTab_* functions to see which one is active, and move the correct tab as required...example:

_GUICtrlTab_GetCurSel ; returns the current tab's instance
_GUICtrlTab_GetItemText ; get the text of the return of the above call
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

#7 ·  Posted (edited)

While 1
    WinWaitActive("Retail Merchant", "") ;no text here because the software in open
    If StringInStr(WinGetText("Retail Merchant"), "hidden Text") Then
        Beep(800, 100)
        _HotKeys()
        Sleep(200)
    EndIf
    Sleep(200)
WEnd

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Final Solution that worked 100%
 
Opt("WinDetectHiddenText", 0)
 
While 1
WinWaitActive("Retail Merchant", "Receipts") ;restricted to only run at the first page with receipt in the name
If WinActive("Retail Merchant", "TenderPage") Then
Call (_HotKeys)
Sleep(100)
Else
Call (_ClearHotKeys)
Sleep(100)
EndIf
Sleep(200)
WEnd
 
Thanks Water for the very helpful bit of code, a simple command. Of course this revealed that my coding was inherently flawed and I needed to adjust it before the hot keys became disabled upon leaving the final page.
Edited by Jonovision77

Share this post


Link to post
Share on other sites

Glad you got it working :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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