<commit_before><!doctype html>
<html class="default no-js">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>win32-api</title>
	<meta name="description" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<header>
	<div class="tsd-page-toolbar">
		<div class="container">
			<div class="table-wrap">
				<div class="table-cell" id="tsd-search" data-index="assets/js/search.js" data-base=".">
					<div class="field">
						<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
						<input id="tsd-search-field" type="text" />
					</div>
					<ul class="results">
						<li class="state loading">Preparing search index...</li>
						<li class="state failure">The search index is not available</li>
					</ul>
					<a href="index.html" class="title">win32-api</a>
				</div>
				<div class="table-cell" id="tsd-widgets">
					<div id="tsd-filter">
						<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
						<div class="tsd-filter-group">
							<div class="tsd-select" id="tsd-filter-visibility">
								<span class="tsd-select-label">All</span>
								<ul class="tsd-select-list">
									<li data-value="public">Public</li>
									<li data-value="protected">Public/Protected</li>
									<li data-value="private" class="selected">All</li>
								</ul>
							</div>
							<input type="checkbox" id="tsd-filter-inherited" checked />
							<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
						</div>
					</div>
					<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
				</div>
			</div>
		</div>
	</div>
	<div class="tsd-page-title">
		<div class="container">
			<ul class="tsd-breadcrumb">
				<li>
					<a href="globals.html">Globals</a>
				</li>
			</ul>
			<h1> win32-api</h1>
		</div>
	</div>
</header>
<div class="container container-main">
	<div class="row">
		<div class="col-8 col-content">
			<div class="tsd-panel tsd-typography">
				<a href="#win32-api" id="win32-api" style="color: inherit; text-decoration: none;">
					<h1>win32-api</h1>
				</a>
				<p>FFI Definitions of Windows win32 api for <a href="https://github.com/node-ffi-napi/node-ffi-napi">node-ffi-napi</a></p>
				<p><a href=""><img src="https://img.shields.io/github/tag/waitingsong/node-win32-api.svg" alt="GitHub tag"></a>
					<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
					<img src="https://img.shields.io/badge/lang-TypeScript-blue.svg" alt="">
					<img src="https://img.shields.io/badge/platform-win32-blue.svg" alt="Available platform">
					<a href="https://coveralls.io/github/waitingsong/node-win32-api"><img src="https://coveralls.io/repos/github/waitingsong/node-win32-api/badge.svg" alt="Coverage Status"></a>
					<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits"></a>
				<a href="https://lernajs.io/"><img src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg" alt="lerna"></a></p>
				<a href="#initialization" id="initialization" style="color: inherit; text-decoration: none;">
					<h2>Initialization</h2>
				</a>
				<pre><code class="language-sh">npm run repo:init</code></pre>
				<a href="#packages" id="packages" style="color: inherit; text-decoration: none;">
					<h2>Packages</h2>
				</a>
				<table>
					<thead>
						<tr>
							<th>Package</th>
							<th>Version</th>
							<th>Dependencies</th>
							<th>DevDependencies</th>
						</tr>
					</thead>
					<tbody><tr>
							<td><a href="https://github.com/waitingsong/node-win32-api/tree/master/packages/win32-api"><code>win32-api</code></a></td>
							<td><a href="https://github.com/waitingsong/node-win32-api/tree/master/packages/win32-api/CHANGELOG.md"><img src="https://img.shields.io/npm/v/win32-api.svg?maxAge=86400" alt="main-svg"></a></td>
							<td><a href="https://david-dm.org/waitingsong/node-win32-api.svg?path=packages/win32-api"><img src="https://david-dm.org/waitingsong/node-win32-api.svg?path=packages/win32-api" alt="main-d-svg"></a></td>
							<td><a href="https://david-dm.org/waitingsong/node-win32-api?path=packages/win32-api#info=devDependencies"><img src="https://david-dm.org/waitingsong/node-win32-api/dev-status.svg?path=packages/win32-api" alt="main-dd-svg"></a></td>
						</tr>
						<tr>
							<td><a href="https://github.com/waitingsong/node-win32-api/tree/master/packages/win32-def"><code>win32-def</code></a></td>
							<td><a href="https://github.com/waitingsong/node-win32-api/tree/master/packages/win32-def/CHANGELOG.md"><img src="https://img.shields.io/npm/v/win32-def.svg?maxAge=86400" alt="def-svg"></a></td>
							<td><a href="https://david-dm.org/waitingsong/node-win32-api.svg?path=packages/win32-def"><img src="https://david-dm.org/waitingsong/node-win32-api.svg?path=packages/win32-def" alt="def-d-svg"></a></td>
							<td><a href="https://david-dm.org/waitingsong/node-win32-api?path=packages/win32-def#info=devDependencies"><img src="https://david-dm.org/waitingsong/node-win32-api/dev-status.svg?path=packages/win32-def" alt="def-dd-svg"></a></td>
						</tr>
				</tbody></table>
				<a href="#what-can-i-do-with-this" id="what-can-i-do-with-this" style="color: inherit; text-decoration: none;">
					<h2>What can I do with this?</h2>
				</a>
				<p>Calling win32 native functions come from user32.dll, kernel32.dll, comctl32.dll by Node.js via <a href="https://github.com/node-ffi-napi/node-ffi-napi">node-ffi-napi</a></p>
				<a href="#installing" id="installing" style="color: inherit; text-decoration: none;">
					<h2>Installing</h2>
				</a>
				<pre><code class="language-sh">npm install win32-api</code></pre>
				<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
					<h2>Usage</h2>
				</a>
				<a href="#find-window-and-set-window-title" id="find-window-and-set-window-title" style="color: inherit; text-decoration: none;">
					<h3>Find window and set window title</h3>
				</a>
				<pre><code class="language-ts"><span class="hljs-comment">// **Find calc's hWnd, need running a calculator program manually at first**</span>

<span class="hljs-comment">/**
 * exposed modules:
 * C, Comctl32 for Comctl32 from lib/comctl32/api
 * K, Kernel32 for kernel32 from lib/kernel32/api
 * U, User32 for user32 from lib/user32/api
 */</span>
<span class="hljs-keyword">import</span> { K, U } <span class="hljs-keyword">from</span> <span class="hljs-string">'win32-api'</span>
<span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> ref <span class="hljs-keyword">from</span> <span class="hljs-string">'ref-napi'</span>

<span class="hljs-keyword">const</span> knl32 = K.load()
<span class="hljs-keyword">const</span> user32 = U.load()  <span class="hljs-comment">// load all apis defined in lib/{dll}/api from user32.dll</span>
<span class="hljs-comment">// const user32 = U.load(['FindWindowExW'])  // load only one api defined in lib/{dll}/api from user32.dll</span>

<span class="hljs-keyword">const</span> title = <span class="hljs-string">'Calculator\0'</span>    <span class="hljs-comment">// null-terminated string</span>
<span class="hljs-comment">// const title = '计算器\0'    // null-terminated string 字符串必须以\0即null结尾!</span>

<span class="hljs-keyword">const</span> lpszWindow = Buffer.from(title, <span class="hljs-string">'ucs2'</span>)
<span class="hljs-keyword">const</span> hWnd = user32.FindWindowExW(<span class="hljs-literal">null</span>, <span class="hljs-literal">null</span>, <span class="hljs-literal">null</span>, lpszWindow)

<span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> hWnd === <span class="hljs-string">'number'</span> &amp;&amp; hWnd &gt; <span class="hljs-number">0</span><commit_msg>docs: update documentation<commit_after><!doctype html>
<html class="default no-js">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>win32-api</title>
	<meta name="description" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<header>
	<div class="tsd-page-toolbar">
		<div class="container">
			<div class="table-wrap">
				<div class="table-cell" id="tsd-search" data-index="assets/js/search.js" data-base=".">
					<div class="field">
						<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
						<input id="tsd-search-field" type="text" />
					</div>
					<ul class="results">
						<li class="state loading">Preparing search index...</li>
						<li class="state failure">The search index is not available</li>
					</ul>
					<a href="index.html" class="title">win32-api</a>
				</div>
				<div class="table-cell" id="tsd-widgets">
					<div id="tsd-filter">
						<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
						<div class="tsd-filter-group">
							<div class="tsd-select" id="tsd-filter-visibility">
								<span class="tsd-select-label">All</span>
								<ul class="tsd-select-list">
									<li data-value="public">Public</li>
									<li data-value="protected">Public/Protected</li>
									<li data-value="private" class="selected">All</li>
								</ul>
							</div>
							<input type="checkbox" id="tsd-filter-inherited" checked />
							<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
						</div>
					</div>
					<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
				</div>
			</div>
		</div>
	</div>
	<div class="tsd-page-title">
		<div class="container">
			<ul class="tsd-breadcrumb">
				<li>
					<a href="globals.html">Globals</a>
				</li>
			</ul>
			<h1> win32-api</h1>
		</div>
	</div>
</header>
<div class="container container-main">
	<div class="row">
		<div class="col-8 col-content">
			<div class="tsd-panel tsd-typography">
				<a href="#win32-api" id="win32-api" style="color: inherit; text-decoration: none;">
					<h1>win32-api</h1>
				</a>
				<p>FFI Definitions of Windows win32 api for <a href="https://github.com/node-ffi-napi/node-ffi-napi">node-ffi-napi</a></p>
				<p><a href=""><img src="https://img.shields.io/github/tag/waitingsong/node-win32-api.svg" alt="GitHub tag"></a>
					<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"></a>
					<img src="https://img.shields.io/badge/lang-TypeScript-blue.svg" alt="">
					<img src="https://img.shields.io/badge/platform-win32-blue.svg" alt="Available platform">
					<a href="https://ci.appveyor.com/project/waitingsong/node-win32-api/branch/master"><img src="https://ci.appveyor.com/api/projects/status/nrivtykm5uf84fbl/branch/master?svg=true" alt="Build status"></a>
					<a href="https://coveralls.io/github/waitingsong/node-win32-api"><img src="https://coveralls.io/repos/github/waitingsong/node-win32-api/badge.svg" alt="Coverage Status"></a>
					<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits"></a>
				<a href="https://lernajs.io/"><img src="https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg" alt="lerna"></a></p>
				<a href="#initialization" id="initialization" style="color: inherit; text-decoration: none;">
					<h2>Initialization</h2>
				</a>
				<pre><code class="language-sh">npm run repo:init</code></pre>
				<a href="#packages" id="packages" style="color: inherit; text-decoration: none;">
					<h2>Packages</h2>
				</a>
				<table>
					<thead>
						<tr>
							<th>Package</th>
							<th>Version</th>
							<th>Dependencies</th>
							<th>DevDependencies</th>
						</tr>
					</thead>
					<tbody><tr>
							<td><a href="https://github.com/waitingsong/node-win32-api/tree/master/packages/win32-api"><code>win32-api</code></a></td>
							<td><a href="https://github.com/waitingsong/node-win32-api/tree/master/packages/win32-api/CHANGELOG.md"><img src="https://img.shields.io/npm/v/win32-api.svg?maxAge=86400" alt="main-svg"></a></td>
							<td><a href="https://david-dm.org/waitingsong/node-win32-api.svg?path=packages/win32-api"><img src="https://david-dm.org/waitingsong/node-win32-api.svg?path=packages/win32-api" alt="main-d-svg"></a></td>
							<td><a href="https://david-dm.org/waitingsong/node-win32-api?path=packages/win32-api#info=devDependencies"><img src="https://david-dm.org/waitingsong/node-win32-api/dev-status.svg?path=packages/win32-api" alt="main-dd-svg"></a></td>
						</tr>
						<tr>
							<td><a href="https://github.com/waitingsong/node-win32-api/tree/master/packages/win32-def"><code>win32-def</code></a></td>
							<td><a href="https://github.com/waitingsong/node-win32-api/tree/master/packages/win32-def/CHANGELOG.md"><img src="https://img.shields.io/npm/v/win32-def.svg?maxAge=86400" alt="def-svg"></a></td>
							<td><a href="https://david-dm.org/waitingsong/node-win32-api.svg?path=packages/win32-def"><img src="https://david-dm.org/waitingsong/node-win32-api.svg?path=packages/win32-def" alt="def-d-svg"></a></td>
							<td><a href="https://david-dm.org/waitingsong/node-win32-api?path=packages/win32-def#info=devDependencies"><img src="https://david-dm.org/waitingsong/node-win32-api/dev-status.svg?path=packages/win32-def" alt="def-dd-svg"></a></td>
						</tr>
				</tbody></table>
				<a href="#what-can-i-do-with-this" id="what-can-i-do-with-this" style="color: inherit; text-decoration: none;">
					<h2>What can I do with this?</h2>
				</a>
				<p>Calling win32 native functions come from user32.dll, kernel32.dll, comctl32.dll by Node.js via <a href="https://github.com/node-ffi-napi/node-ffi-napi">node-ffi-napi</a></p>
				<a href="#installing" id="installing" style="color: inherit; text-decoration: none;">
					<h2>Installing</h2>
				</a>
				<pre><code class="language-sh">npm install win32-api</code></pre>
				<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
					<h2>Usage</h2>
				</a>
				<a href="#find-window-and-set-window-title" id="find-window-and-set-window-title" style="color: inherit; text-decoration: none;">
					<h3>Find window and set window title</h3>
				</a>
				<pre><code class="language-ts"><span class="hljs-comment">// **Find calc's hWnd, need running a calculator program manually at first**</span>

<span class="hljs-comment">/**
 * exposed modules:
 * C, Comctl32 for Comctl32 from lib/comctl32/api
 * K, Kernel32 for kernel32 from lib/kernel32/api
 * U, User32 for user32 from lib/user32/api
 */</span>
<span class="hljs-keyword">import</span> { K, U } <span class="hljs-keyword">from</span> <span class="hljs-string">'win32-api'</span>
<span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> ref <span class="hljs-keyword">from</span> <span class="hljs-string">'ref-napi'</span>

<span class="hljs-keyword">const</span> knl32 = K.load()
<span class="hljs-keyword">const</span> user32 = U.load()  <span class="hljs-comment">// load all apis defined in lib/{dll}/api from user32.dll</span>
<span class="hljs-comment">// const user32 = U.load(['FindWindowExW'])  // load only one api defined in lib/{dll}/api from user32.dll</span>

<span class="hljs-keyword">const</span> title = <span class="hljs-string">'Calculator\0'</span>    <span class="hljs-comment">// null-terminated string</span>
<span class="hljs-comment">// const title = '计算器\0'    // null-terminated string 字符串必须以\0即null结尾!</span>

<span class="hljs-keyword">const</span> lpszWindow = Buffer.from(title, <span class="hljs-string">'ucs2'</span>)
<span class="hljs-keyword">const</span> hWnd = user32.FindWindowExW(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-literal">null</span>, lpszWindow)

<span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span> hWnd === <span class="hljs-string">'number'</span> &amp;&amp; hWnd &gt; <span class="hljs-number">0</span>
{'fraction_non_alphanumeric': 0.21373009013458452, 'fraction_numerical': 0.020558093591801458, 'mean_word_length': 4.105263157894737, 'pattern_counts': {'":': 0, '<': 520, '<?xml version=': 0, '>': 520, 'https://': 56, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3775944', 'n_tokens_mistral': 7000, 'n_tokens_neox': 5863, 'n_words': 904}