npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vavanya/flaui-js

v0.1.1

Published

FlaUI.js provides the ability to use the power of FlaUI in the Node.js world.

Downloads

17

Readme

npm downloads gzip size version

FlaUI.js

Motivation

FlaUI is a .Net open-source framework that allows the development of automated scripts for testing Windows desktop GUI applications using Microsoft UIA technology. We love the Node.js environment and JavaScript/TypeScript, so the idea of FlaUI.js came into play.

FlaUI.js provides the ability to use the power of FlaUI in the Node.js world.

Installation

You can install FlaUI.js via NPM

npm install @vavanya/flaui-js

Usage

Create the Node.js package

npm init -y

Add FlaUI.js support

npm install @vavanya/flaui-js

Create a file calculator.mjs file

// calculator.mjs
import { init } from '@vavanya/flaui-js';

let d = await init();

const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));

const findAndWaitForElement = async (mainWindow, xPath) => {
    let element;
    let counter = 0;
    do {
        element = mainWindow.FindFirstByXPath(xPath);
        if (element === null) {
            await sleep(500);
        }
    } while (element === null && ++counter < 60); // wait for 60 * 500 ms = 30 secs
    return element;
}

const UIA3 = d.FlaUI.UIA3;
const UI_Input = d.FlaUI.Core.Input;
const Application = d.FlaUI.Core.Application;

const uiAutomation = new UIA3.UIA3Automation();
let app = Application.LaunchStoreApp("Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
let wnd = app.GetMainWindow(uiAutomation);
app.WaitWhileBusy();

// Find the buttons
let btn0 = await findAndWaitForElement(wnd, "//Button[@Name='Zero']");
let btn1 = await findAndWaitForElement(wnd, "//Button[@Name='One']");
let btn2 = await findAndWaitForElement(wnd, "//Button[@Name='Two']");
let btn3 = await findAndWaitForElement(wnd, "//Button[@Name='Three']");
let btn4 = await findAndWaitForElement(wnd, "//Button[@Name='Four']");
let btn5 = await findAndWaitForElement(wnd, "//Button[@Name='Five']");
let btn6 = await findAndWaitForElement(wnd, "//Button[@Name='Six']");
let btn7 = await findAndWaitForElement(wnd, "//Button[@Name='Seven']");
let btn8 = await findAndWaitForElement(wnd, "//Button[@Name='Eight']");
let btn9 = await findAndWaitForElement(wnd, "//Button[@Name='Nine']");
let btnPlus = await findAndWaitForElement(wnd, "//Button[@Name='Plus']");
let btnEqual = await findAndWaitForElement(wnd, "//Button[@Name='Equals']");
let result = await findAndWaitForElement(wnd, "//Text[@AutomationId='CalculatorResults']");

// Enter 123
btn1.Click();
btn2.Click();
btn3.Click();

// Click "+" sign
btnPlus.Click();

// Enter 4057
btn4.Click();
btn0.Click();
btn5.Click();
btn7.Click();

// Click "=" sign
btnEqual.Click();

// Print the result
// output: Result:  Display is 4,180
console.log('Result: ', result.Name);

// Just to see the result on screen
await sleep(5000); 
app.Close();

Run the file with Node.js

node calculator.mjs

NOTE this code was tested with Node.js v21.2.0 and NPM v10.2.3 on OS Windows 11 64-bit.

Support

Support can be obtained by submitting Issues here on Gitlab.

Roadmap

We follow the upstream FlaUI project - if new features are applicable to our use case we will implement them.

Contributing

All contributions to this project are welcome: use cases, documentation, code, patches, bug reports, feature requests, etc. Any and all contributions may be made by submitting Issues and Pull Requests here on GitLab.

Please note that by submitting a pull request or otherwise contributing to this project, you warrant that each of your contributions is an original work and that you have full authority to grant rights to said contribution and by so doing you grant the owners of this project, and those who receive the contribution directly or indirectly, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable licence to make, have made, use, offer to sell, sell and import or otherwise dispose of the contributions alone or with this project in its entirety.

Third-Party Softwares

See ThirdPartyNotices

Licence

This work is licensed under the MIT license. See LICENSE file for details.