Problem with running from Command line

Hi! This is my first topic:grinning: . If I’m doing something wrong please tell me to get it right.

About the problem.
Until recently I was using Ui.vision from the command line and everything was working just fine. But when I was going to run again I got this: ‘[error] Can’t find macro with name “DemoAutofill”’. Maybe I was doing something wrong, so I reinstalled and tried to run the source code from Github (python), but the error is still there.

I am missing something ? thanks for any help.

Can you post the command line you are using?

As a test, if you enter the command line URL string directly in the browser address bar, does it work then?

It’s the .py on Github. The only difference being the path to the .html file
here it is:

import sys
import os
import datetime
import subprocess
import time


def PlayAndWait(macro, timeout_seconds=10, var1='-', var2='-', var3='-', path_downloaddir=None, path_autorun_html=None, browser_path=None):

    assert os.path.exists(path_downloaddir)
    assert os.path.exists(path_autorun_html)
    assert os.path.exists(browser_path)

    log = 'log_' + datetime.datetime.now().strftime('%m-%d-%Y_%H_%M_%S') + '.txt'

    path_log = os.path.join(path_downloaddir, log)

    args = r'file:///' + path_autorun_html + '?macro=' + macro + '&cmd_var1=' + var1 + \
        '&cmd_var2=' + var2 + '&cmd_var3=' + var3 + \
        '&closeKantu=0&direct=1&savelog=' + log

    proc = subprocess.Popen([browser_path, args])

    status_runtime = 0

    print("Log File with show up at " + path_log)

    while(not os.path.exists(path_log) and status_runtime < timeout_seconds):
        print("Waiting for macro to finish, seconds=%d" % status_runtime)
        time.sleep(1)
        status_runtime = status_runtime + 1

    if status_runtime < timeout_seconds:
        with open(path_log) as f:
            status_text = f.readline()

        status_init = 1 if status_text.find('Status=OK') != -1 else -1
    else:
        status_text = "Macro did not complete withing the time given: %d" % timeout_seconds
        status_init = -2
        proc.kill()

    print(status_text)
    sys.exit(status_init)


if __name__ == '__main__':
    PlayAndWait('DemoAutofill', timeout_seconds=35, path_downloaddir='C:\\Users\\Lmac\\Downloads', path_autorun_html=r'C:\\Users\\Lmac\\Downloads\\DemoAutofill.html',
                browser_path=r'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe')

I am trying to run the DemoAutofill.html. When i run the .py code it open’s on the browser. but…


Am i missing something ?

You should create a new macro “DemoAutofill” in the root, do not use the prepared “DemoAutofill” that is in the Demo/Core document.

Or just fix the path to Demo/Core/Sub/DemoAutofill

your solution is also OK