Mini-guide 2 re 'no appmask'

Once again making use of @jokoum’s discoveries regarding selectors, you can automate both web and desktop applications without appmasks. You can easily build up a library of snippets like those shown to reuse.

In all likelihood you’ll have to use appmasks every time you encounter a new application, web or desktop. However, the following code should help you create shortcuts make your scripts more portable and faster to write (I hope!) :grinning:

Use your favorite snippet manager to paste in selector components and it will go even faster.

Here are steps suggested, and in basic fashion shown in the code below. As you can see when examining the code, you can break down components even further for future reassembly.

Create a selector separator to use in other components.
Create a partial selector for desktop apps.
Create a partial selector for web apps.
Build a library control selectors (both web and desktop).

#The first two variables are script-specific"
set appName to '"Untitled - Notepad"'
set appProcess to '"notepad"'
set webAttribute to '"query"'

# These variables can be reused in any script.
set selectorSeparator to '{<{<{<SelectorSeparator>}>}>}uia3://'
set webSelector to 'domcontainer' + selectorSeparator

# You can keep a list of selectors like these to reuse in your scripts
set notepadEditSelector to '  > edit[class=""Edit""]' # e.g. for Notepad
set startpageSelector to ' *[id="query"]'

# This comes in handy (not used here). Build your own list of snippets.
set newLine to """

# If you are consistent in naming your variables, you can reuse these snippets as well.

# Alternative to variable below, using '%' syntax: \
# set deskSelector to $""":desktop > window[name="%appName%"][process="%appProcess%"]"""
set deskSelector to ':desktop > window[name="' + appName + '"][process="' + appProcess + '"]'
set fullDeskSelector to deskSelector + selectorSeparator + notepadEditSelector
set fullWebSelector to webSelector + startpageSelector

Console.Write Message: fullDeskSelector # For testing
Console.Write Message: fullWebSelector

System.RunApplication \
    ApplicationPath: 'Notepad.exe' \
    CommandLineArguments:'' \
    WorkingDirectory:'' \
    WindowStyle:System.ProcessWindowStyle.Normal \
    ProcessId=> ProcessId

UIAutomation.FormFilling.PopulateTextField \
    TextField: fullDeskSelector \
    Text: "Hello, Robin!"

wait 3

System.TerminateProcessByName ProcessName: 'notepad'

WebAutomation.LaunchChrome \
    Url:  '' \
    WindowState:WebAutomation.BrowserWindowState.Normal \
    ClearCache:False \
    ClearCookies:False \
    BrowserInstance=> Browser

WebAutomation.FormFilling.PopulateTextField \
    BrowserInstance:  Browser \
    Control: fullWebSelector \
    Text: '' \
    EmulateTyping:True \

wait 2

WebAutomation.CloseWebBrowser BrowserInstance: Browser

Screenshot (get out your magnifying glass :grinning:):

Output (just for debugging and showing what selectors look like when assembled):

Please don’t hesitate to let me know if this doesn’t work for you, and to add your suggestions.