This repository has been archived on 2022-07-17. You can view files and clone it, but cannot push or open issues or pull requests.
arsenm-dev-site/public/docs/kbdemu/usage/index.html

53 lines
15 KiB
HTML
Raw Permalink Normal View History

2021-04-02 23:01:07 +00:00
<!doctype html><html lang=en-us><head><meta charset=utf-8><meta http-equiv=x-ua-compatible content="ie=edge"><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><script src=https://code.iconify.design/1/1.0.7/iconify.min.js></script><link rel=preload as=font href=/fonts/vendor/jost/jost-v4-latin-regular.woff2 type=font/woff2 crossorigin><link rel=preload as=font href=/fonts/vendor/jost/jost-v4-latin-700.woff2 type=font/woff2 crossorigin><link rel=stylesheet href=/main.db7090cddb6602125f0ed93682d138976ae6d5a9a2f2f92c4bcd4de73e6debc939331bf2ec54e8cd7b933fa961527404e59b7ddc6eede1ed4bb4cf90ad77caab.css integrity="sha512-23CQzdtmAhJfDtk2gtE4l2rm1ami8vksS81N5z5t68k5Mxvy7FTozXuTP6lhUnQE5Zt93G7t4e1LtM+QrXfKqw==" crossorigin=anonymous><noscript><style>img.lazyload{display:none}</style></noscript><meta name=robots content="index, follow"><meta name=googlebot content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><meta name=bingbot content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"><title>Usage | Arsen Dev</title><meta name=description content="Using kbdemu"><link rel=canonical href=/docs/kbdemu/usage/><meta name=twitter:card content="summary"><meta name=twitter:title content="Usage"><meta name=twitter:description content="Using kbdemu"><meta name=twitter:site content="@"><meta name=twitter:creator content="@"><meta property="og:title" content="Usage"><meta property="og:description" content="Using kbdemu"><meta property="og:type" content="article"><meta property="og:url" content="/docs/kbdemu/usage/"><meta property="og:site_name" content="Arsen Dev"><meta property="article:publisher" content="https://www.facebook.com/"><meta property="article:author" content="https://www.facebook.com/"><meta property="og:locale" content><script type=application/ld+json>{"@context":"http://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"\/"},{"@type":"ListItem","position":2,"name":"Docskbdemuusage","item":"\/docskbdemuusage\/"}]}</script><meta name=theme-color content="#fff"><link rel=apple-touch-icon sizes=180x180 href=/apple-touch-icon.png><link rel=icon type=image/png sizes=32x32 href=/favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=/favicon-16x16.png><link rel=manifest href=/site.webmanifest><link rel=stylesheet href=/css/highlightjs/dracula.min.css><script src=/js/highlightjs/highlight.min.js></script><script>hljs.initHighlightingOnLoad();</script></head><body class="docs single"><div class="header-bar fixed-top"></div><header class="navbar fixed-top navbar-expand-md navbar-light"><div class=container><input class="menu-btn order-0" type=checkbox id=menu-btn>
<label class="menu-icon d-md-none" for=menu-btn><span class=navicon></span></label><a class="navbar-brand order-1 order-md-0 mr-auto" href=/>Arsen Dev</a>
<button id=mode class="btn btn-link order-2 order-md-4" type=button aria-label="Toggle mode">
<span class=toggle-dark><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg></span><span class=toggle-light><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg></span></button><ul class="navbar-nav social-nav order-3 order-md-5"><li class=nav-item><a class=nav-link href=https://gitea.arsenm.dev/Arsen6331><span class=iconify data-icon=cib:gitea data-inline=false></span><span class="ml-2 sr-only">Gitea</span></a></li><li class=nav-item><a class=nav-link href=https://gitlab.com/moussaelianarsen><span class=iconify data-icon=fa-brands:gitlab data-inline=false></span><span class="ml-2 sr-only">GitLab</span></a></li></ul><div class="collapse navbar-collapse order-4 order-md-1"><ul class="navbar-nav main-nav mr-auto order-5 order-md-2"><li class=nav-item><a class=nav-link href=/>Home</a></li><li class="nav-item active"><a class=nav-link href=/docs/>Docs</a></li></ul><div class="break order-6 d-md-none"></div><form class="navbar-form flex-grow-1 order-7 order-md-3"><input id=userinput class="form-control is-search" type=search placeholder="Search docs..." aria-label="Search docs..." autocomplete=off><div id=suggestions class="shadow bg-white rounded"></div></form></div></div></header><div class="wrap container" role=document><div class=content><div class="row flex-xl-nowrap"><div class="col-lg-5 col-xl-4 docs-sidebar"><nav class=docs-links aria-label="Main navigation"><h3>Docs</h3><ul class=list-unstyled><li><a class=docs-link href=/docs/advmake/>AdvMake Docs</a></li><li><a class=docs-link href=/docs/kbdemu/>KbdEmu Docs</a></li><li><a class=docs-link href=/docs/opensend/>OpenSend Docs</a></li><li><a class=docs-link href=/docs/pak/>Pak Docs</a></li><li><a class=docs-link href=/docs/simpledash/>Simpledash Docs</a></li></ul></nav></div><nav class="docs-toc d-none d-xl-block col-xl-3" aria-label="Secondary navigation"><div class=page-links><h3>On this page</h3><nav id=TableOfContents><ul><li><a href=#scripts>Scripts</a></li><li><a href=#builtins>Builtins</a><ul><li><a href=#numcpu><code>numcpu</code></a></li><li><a href=#sleep><code>sleep</code></a></li><li><a href=#display-dialog><code>display-dialog</code></a></li><li><a href=#send-notification><code>send-notification</code></a></li><li><a href=#beep><code>beep</code></a></li><li><a href=#click><code>click</code></a></li><li><a href=#scroll><code>scroll</code></a></li><li><a href=#move-mouse><code>move-mouse</code></a></li><li><a href=#keystroke><code>keystroke</code></a></li><li><a href=#type><code>type</code></a></li><li><a href=#mouse-position><code>mouse-position</code></a></li><li><a href=#pixel-color><code>pixel-color</code></a></li><li><a href=#log><code>log</code></a></li><li><a href=#user-choice><code>user-choice</code></a></li><li><a href=#open-location><code>open-location</code></a></li></ul></li><li><a href=#variables>Variables</a><ul><li><a href=#goos><code>$GOOS</code></a></li><li><a href=#goarch><code>$GOARCH</code></a></li><li><a href=#arguments><code>$arguments</code></a></li></ul></li></ul></nav></div></nav><main class="docs-content col-lg-11 col-xl-9 mx-xl-auto"><a href=..>&lArr; KbdEmu Docs</a><h1 style=margin-top:.2rem>Usage</h1><p class=lead></p><p><a style=margin-left:1px;margin-right:1px;display:inline-block href=https://ci.appveyor.com/project/moussaelianarsen/kbdemu><img style=height:18px;width:100px src="ht
<a style=margin-left:1px;margin-right:1px;display:inline-block href=https://minio.arsenm.dev/minio/kbdemu><img style=height:18px;width:100px src="https://img.shields.io/static/v1.svg?label=download&message=binary&color=blue"></a></p><p>This page assumes you have already installed KbdEmu. If not, follow the installation instructions on the installation page:</p><a class=btn style=color:#fff;background-color:#357edd href=../installation>Installation</a><h2 id=scripts>Scripts<a href=#scripts class=anchor aria-hidden=true>#</a></h2><p>KbdEmu uses <a href=https://gitea.arsenm.dev/Arsen6331/scpt>scpt</a> as its scripting language. The example script for kbdemu looks like this:</p><pre><code>set testKey to &quot;x&quot;
keystroke $testKey with action &quot;hold&quot;
sleep &quot;1s&quot;
keystroke $testKey with action &quot;release&quot;
type &quot;AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz&quot;
scroll 5 with direction &quot;up&quot;
click &quot;right&quot;
move-mouse [0, 0]
send-notification &quot;Test&quot;
beep
open-location &quot;https://www.arsenm.dev/&quot;
set showDetails to (display-dialog &quot;Show details?&quot; with type &quot;yesno&quot;)
if $showDetails {
display-dialog {&quot;Color: &quot; + (pixel-color [100, 100]) + &quot;, Mouse: &quot; + (str (mouse-position))} with title &quot;Details&quot;
}
print {&quot;\n&quot; + (user-choice &quot;test&quot; with items [&quot;Hello&quot;, &quot;World&quot;, 3.1415926535, $GOOS, $GOARCH, true, false, (numcpu)])}
log &quot;Complete!&quot;
</code></pre><p>By default, the <code>kbdemu</code> command will look for and execute a file called <code>kbdemu.scpt</code>, but that can be changed using the <code>--file</code> flag.</p><hr><h2 id=builtins>Builtins<a href=#builtins class=anchor aria-hidden=true>#</a></h2><p>KbdEmu comes with some extra functions for automation</p><hr><h3 id=numcpu><code>numcpu</code><a href=#numcpu class=anchor aria-hidden=true>#</a></h3><p>Returns the amount of available CPUs as a number.</p><p>Example:</p><pre><code>print (numcpu)
</code></pre><hr><h3 id=sleep><code>sleep</code><a href=#sleep class=anchor aria-hidden=true>#</a></h3><p>Sleeps for a duration as specified by an unnamed string argument formatted according to the specification of golang&rsquo;s <code>time.ParseDuration()</code>:</p><a class=btn style=color:#fff;background-color:#00acd7 href=https://golang.org/pkg/time#ParseDuration><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><p>Examples:</p><pre><code>sleep &quot;1s&quot;
sleep &quot;1h2m&quot;
</code></pre><hr><h3 id=display-dialog><code>display-dialog</code><a href=#display-dialog class=anchor aria-hidden=true>#</a></h3><p>Displays a dialog window with the specified parameters.</p><p>Examples:</p><pre><code>display-dialog &quot;Test1&quot;
display-dialog &quot;Test2&quot; with title &quot;Title Test&quot;
print (display-dialog &quot;Test3&quot; with title &quot;Entry Test&quot; with type &quot;entry&quot;)
</code></pre><p>These are all the supported dialog types:</p><ul><li>info</li><li>warning</li><li>error</li><li>entry</li><li>yesno</li></ul><p>Default dialog type is info.</p><hr><h3 id=send-notification><code>send-notification</code><a href=#send-notification class=anchor aria-hidden=true>#</a></h3><p>Sends a notification according to the specified parameters</p><p>Examples:</p><pre><code>send-notification &quot;Test&quot;
send-notification &quot;Test&quot; with title &quot;Title&quot;
send-notification &quot;Test&quot; with title &quot;Title&quot; with icon &quot;test.png&quot;
</code></pre><hr><h3 id=beep><code>beep</code><a href=#beep class=anchor aria-hidden=true>#</a></h3><p>Creates a beep sound, if impossible, falls back to sending bell character.</p><p>Examples:</p><pre><code>beep
beep &quot;3s&quot;
</code></pre><hr><h3 id=click><code>click</code><a href=#click class=anchor aria-hidden=true>#</a></h3><p>Emulates a mouse click</p><p>Example:</p><pre><code>click &quot;right&quot;
</code></pre><hr><h3 id=scroll><code>scroll</code><a href=#scroll class=anchor aria-hidden=true>#</a></h3><p>Scrolls the specifed amount in the specified direction</p><p>Example:</p><pre><code>scroll 5 with direction &quot;up&quot;
</code></pre><hr><h3 id=move-mouse><code>move-mouse</code><a href=#move-mouse class=anchor aria-hidden=true>#</a></h3><p>Moves the cursor to the specified coordinates</p><p>Example:</p><pre><code>move-mouse [100, 200]
</code></pre><hr><h3 id=keystroke><code>keystroke</code><a href=#keystroke class=anchor aria-hidden=true>#</a></h3><p>Emulates a key event</p><p>Examples:</p><pre><code>keystroke &quot;y&quot; with action &quot;hold&quot;
sleep &quot;2s&quot;
keystroke &quot;y&quot; with action &quot;release&quot;
keystroke &quot;x&quot;
</code></pre><p>Default action is <code>tap</code> which presses and releases the key.</p><hr><h3 id=type><code>type</code><a href=#type class=anchor aria-hidden=true>#</a></h3><p>Types a string using the keyboard</p><p>Example:</p><pre><code>type &quot;Hello, World&quot;
</code></pre><hr><h3 id=mouse-position><code>mouse-position</code><a href=#mouse-position class=anchor aria-hidden=true>#</a></h3><p>Returns the current mouse position in the form of an array containing two number elements.</p><p>Example:</p><pre><code>print (mouse-position) # [0 0]
</code></pre><hr><h3 id=pixel-color><code>pixel-color</code><a href=#pixel-color class=anchor aria-hidden=true>#</a></h3><p>Returns a string containing the hex color of the given coordinates.</p><p>Example:</p><pre><code>print (pixel-color [100, 100]) # ffffff
</code></pre><hr><h3 id=log><code>log</code><a href=#log class=anchor aria-hidden=true>#</a></h3><p>Logs the provided message at the given level.</p><p>Examples:</p><pre><code>log &quot;Complete&quot;
log &quot;Error&quot; with level &quot;fatal&quot;
</code></pre><p>The available levels are:</p><ul><li>info</li><li>debug</li><li>warn</li><li>fatal</li></ul><p>Default log level is info</p><hr><h3 id=user-choice><code>user-choice</code><a href=#user-choice class=anchor aria-hidden=true>#</a></h3><p>Displays a user choice dialog window with provided items, returns selected item.</p><p>Example:</p><pre><code>user-choice &quot;Choose an option&quot; with items [&quot;Hello&quot;, &quot;World&quot;, 1, 3.14159, 6.28318]
</code></pre><hr><h3 id=open-location><code>open-location</code><a href=#open-location class=anchor aria-hidden=true>#</a></h3><p>Opens given URL in the default application set to open it.</p><p>Examples:</p><pre><code>open-location &quot;https://www.arsenm.dev&quot;
open-location &quot;/home&quot;
</code></pre><hr><h2 id=variables>Variables<a href=#variables class=anchor aria-hidden=true>#</a></h2><p>KbdEmu exposes some variables for use in scripts.</p><hr><h3 id=goos><code>$GOOS</code><a href=#goos class=anchor aria-hidden=true>#</a></h3><p>The value from golang&rsquo;s <code>runtime.GOOS</code></p><a class=btn style=color:#fff;background-color:#00acd7 href=https://golang.org/pkg/runtime#GOOS><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><hr><h3 id=goarch><code>$GOARCH</code><a href=#goarch class=anchor aria-hidden=true>#</a></h3><p>The value from golang&rsquo;s <code>runtime.GOARCH</code></p><a class=btn style=color:#fff;background-color:#00acd7 href=https://golang.org/pkg/runtime#GOARCH><span class="iconify icon:cib:go"></span>&nbsp;
Godoc</a><hr><h3 id=arguments><code>$arguments</code><a href=#arguments class=anchor aria-hidden=true>#</a></h3><p>Non-flag command line arguments provided to KbdEmu</p><p>Example:</p><p>Command:</p><div class=highlight><pre class=chroma><code class=language-bash data-lang=bash>kbdemu --file script.scpt <span class=s2>&#34;Hello, World&#34;</span>
</code></pre></div><p>Contents of <code>script.scpt</code>:</p><pre><code>print $arguments[0] # Hello, World
2021-04-02 23:11:42 +00:00
</code></pre></main></div></div></div><script src=/main.f6b484f556ad1f3bcf6061082139a2f21fa759f13930c39a25fe4a9f78f35e64122c2d86dffd56e67b292dabbda4095d8077194f196e0e348441c106a9f3d40e.js integrity="sha512-9rSE9VatHzvPYGEIITmi8h+nWfE5MMOaJf5Kn3jzXmQSLC2G3/1W5nspLau9pAldgHcZTxluDjSEQcEGqfPUDg==" crossorigin=anonymous defer></script><script src=/index.min.519647b94aaacaa6fa73ffc9e4bda4ccc0d6ab69b03000caea7466a9dc6806cf38f9d8c6926c09e49970a5fe43183e0d589a028bbf3b8ef0ef5c98fc6fb78206.js integrity="sha512-UZZHuUqqyqb6c//J5L2kzMDWq2mwMADK6nRmqdxoBs84+djGkmwJ5Jlwpf5DGD4NWJoCi787jvDvXJj8b7eCBg==" crossorigin=anonymous defer></script></body></html>