Keyboard macros: Difference between revisions
m
→{{header|Wren}}: Minor tidy
(Added Wren) |
m (→{{header|Wren}}: Minor tidy) |
||
(One intermediate revision by one other user not shown) | |||
Line 8:
=={{header|AutoHotkey}}==
<
{
TrayTip, counting, %A_Index% press alt-p to pause
Line 32:
TrayTip, resume, resuming, 2
Pause, off
}</
See [http://www.autohotkey.com/forum/topic44290.html&highlight=vim ahk-viper-mode] for a context sensitive vi key bindings example.
=={{header|BBC BASIC}}==
===Native===
<
*KEY 2 |!|B
REPEAT
Line 54:
DEF PROCmethod2
PRINT "You pressed F2"
ENDPROC</
===Windows===
{{works with|BBC BASIC for Windows}}
<
VK_F1 = &70
VK_F2 = &71
Line 89:
DEF PROCmethod2
PRINT "You pressed F2"
ENDPROC</
=={{header|C}}==
Line 95:
The following example grabs Alt+F6 and Alt+F7 system-wide on a X server.
<
#include <stdlib.h>
#include <X11/Xlib.h>
Line 132:
}
return EXIT_SUCCESS;
}</
=={{header|Clojure}}==
Line 138:
The following example is at application level, printing out what key was pressed:
<
(ns hello-seesaw.core
(:use seesaw.core))
Line 149:
pack!
show!)))
</syntaxhighlight>
=={{header|Delphi}}==
Version Console Application
<syntaxhighlight lang="delphi">
program Key_Bindings_test;
Line 276:
readln;
end.
</syntaxhighlight>
{{out}}
<pre>
Line 289:
=={{header|EchoLisp}}==
The '''(meta-key "key-value" "bound-string")''' function binds a modifier+key keypress to a string or function call.
<
;; see initial bindings : GREEK DICTIONARY
(meta-keys) → (("0" "❌") ("1" "❗️") ("2" "❓") ("3" "✔️") ("4" "⛔️") ("5" "✅") ("6" "🚩") ("7" "⌚️")
Line 306:
(meta-key "A" "Antoinette") ; string
(meta-key "H" "(begin (writeln 'HELLO) (date 'today))") ; function call
</syntaxhighlight>
=={{header|Go}}==
Line 315:
Note also that if you pass 'nil' to the XOpenDisplay function, it defaults to the value of the DISPLAY environment variable which has to be in a certain format to enable a connection to the X server to be established - check [https://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html the documentation] for details.
<
/*
Line 372:
fmt.Println("XOpenDisplay did not succeed")
}
}</
=={{header|HicEst}}==
<
CALL F2
! ...
Line 396:
! Fn is suspended if m > n AND n <= 5, else Fm is queued
! ...
END</
=={{header|Icon}} and {{header|Unicon}}==
This is application-specific and works in both languages:
<
global kMap
Line 422:
procedure italicsOff()
return "<\\i>"
end</
Sample run:
Line 432:
=={{header|Java}}==
<
package keybord.macro.demo;
Line 463:
}
}
</syntaxhighlight>
=={{header|JavaScript}}==
The example below captures the F7 key when pressed, if the document (that is, the web page) has focus. If the function returns ''false'', the event processing is halted. If it returns any other value, including ''undefined'', the event continues up the DOM tree ('bubbling').
<
if (evt.keyCode === 118) {
alert("You pressed F7!");
return false;
}
}</
See [http://www.quirksmode.org/js/keys.html quirksmode] for more information about key detection in JavaScript.
Line 479:
=={{header|Julia}}==
Macros are within the Gtk window.
<
function keypresswindow()
Line 501:
keypresswindow()
</syntaxhighlight>
=={{header|Kotlin}}==
{{trans|Java}}
<
import javax.swing.JFrame
Line 529:
isVisible = true
}
}</
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
Module CheckIt {
\\ Scan statement exist from version 1
Line 564:
}
Checkit
</syntaxhighlight>
=={{header|Mathematica}}/{{header|Wolfram Language}}==
Map the keystroke t to a simple script
<
=={{header|Nim}}==
{{libheader|gintro}}
As we need to catch the key press events, we give an example inside a Gtk3 application.
<
import gintro/[glib, gobject, gio]
Line 647:
let app = newApplication(App, "Rosetta.KeyboardMacros")
discard app.connect("activate", activate)
discard app.run()</
=={{header|Oz}}==
Window-specific key bindings:
<
[QTk] = {Module.link ['x-oz://system/wp/QTk.ozf']}
Label
Line 664:
action:toplevel#close
)}
{Window show}</
=={{header|Perl}}==
<
use warnings;
use Term::ReadKey;
Line 705:
}
ReadMode 0; # reset the terminal to normal mode</
=={{header|Phix}}==
Line 714:
a general key handler.
Obviously K_C and K_F2 could be swapped without any problem.
<!--<
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 744:
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</
===system===
Line 754:
of "keyboard macros" - though of course you could easily replace that
SendInput call with any routine of your choosing.
<!--<
<span style="color: #000080;font-style:italic;">--
-- demo\arwendemo\hotkey.exw
Line 899:
<span style="color: #000000;">WinMain</span><span style="color: #0000FF;">(</span><span style="color: #000000;">Main</span><span style="color: #0000FF;">,</span><span style="color: #000000;">SW_NORMAL</span><span style="color: #0000FF;">)</span>
<!--</
=={{header|PicoLisp}}==
Line 906:
global variable, 'Up' and 'Down' arrows to increment or decrement that value,
and 'Home' to print the current value to the console.
<
(fkey *XtF1
Line 918:
(fkey *XtHome
(prinl "Current value is " *Number) )</
Output when hitting 'F1', 'Down', 'Up', 'Up' and 'Home':
<pre>Initialized value to 1
Line 929:
PureBasic has support for shortcut/macro creation in any window that supports events. This allows for creation of both single and combinations as shown in the code below.
For full set of combinations on PC, Mac & Linux please see the official manual, [http://www.purebasic.com/documentation/window/addkeyboardshortcut.html here].
<
#Demo1 = 0
#Demo2 = 1
Line 954:
EndSelect
ForEver
EndIf</
=={{header|Python}}==
Works on Unix platforms.
<
import curses
Line 980:
curses.echo()
curses.endwin()
</syntaxhighlight>
=={{header|Racket}}==
<
#lang racket
Line 1,039:
macros '())]
[else (write-byte b) (flush-output) (loop inps v '())])))))
</syntaxhighlight>
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku"
my @INPUT;
Line 1,089:
default { log "Unrecognized key: $_"; }
}
}</
=={{header|REBOL}}==
<
Title: "Keyboard Macros"
URL: http://rosettacode.org/wiki/Keyboard_macros
Line 1,119:
pad 1x100 return
text "(c) 1977 G. Beker"
]</
=={{header|REXX}}==
Line 1,130:
<br><br>REXX programs not included are '''$T''' which is only used when specific options are used (used when TOPS is specified),
<br>the '''$ERR''' program which issues errors, and '''$H''' which shows '''help''' and other documentation.
<
trace off
parse arg !
Line 1,729:
syntax: !sigl=sigl; call er 13,!FID(2) !FID(3) !sigl !cal() condition('D') sourceline(!sigl)
whenstamp: arg whenFID; call lineout whenFID,strip(left(date('U'),6)left(date("S"),4) time() arg(2)); call lineout whenFID,' '; call lineout whenFID; return
</syntaxhighlight>
=={{header|Ring}}==
<
load "guilib.ring"
Line 1,756:
on 16777265 see "You pressed F2 " + nl
off
</syntaxhighlight>
Output:
<pre>
Line 1,767:
Here's a sample from the Shoes manual showing how to capture key sequences. This is application specific.
<
@info = para "NO KEY is PRESSED."
keypress do |k|
@info.replace "#{k.inspect} was PRESSED."
end
end</
A more specific example, using some emacs bindings
<
keypress do |key|
case key
Line 1,798:
end
end
end</
=={{header|Scala}}==
===Java Swing Interoperability===
{{libheader|Scala Java Swing interoperability}}
<
import javax.swing.{JFrame, JLabel, WindowConstants}
Line 1,826:
}
}</
=={{header|Tcl}}==
{{libheader|Tk}}
All Tk bindings are bound to a context that is no wider than a particular application and is frequently smaller (e.g., a single dialog box or an individual widget).
<
# Show off some emacs-like bindings...
pack [label .l -text "C-x C-s to save, C-x C-c to quit"]
Line 1,838:
tk_messageBox -message "We would save here"
}
bind . <Control-x><Control-c> {exit}</
===Key-to-key mapping macros===
A more direct macro-like facility (substituting one key sequence for another) would be:
<
foreach c [split "Macro demo!" {}] {
event generate %W $c
}
}</
This can then be wrapped up like this:
<
proc sendMacro {w string} {
foreach c [split $string {}] {
Line 1,862:
macro F2 "You pressed the F2 key"
macro F3 "I'm getting bored here..."
pack [text .t]; # A place for you to test the macros</
=={{header|Vedit macro language}}==
<
// The menu item may then contain the commands directly, or it may call a macro from disk.
// This has the advantage that the key binding is shown in the menu.
Line 1,883:
// Remove a key assignment. If INSERT option was used when the key was assigned, the old assignment will come in effect again.
Key_Delete("Ctrl-Shft-N")</
=={{header|Wren}}==
Line 1,890:
<br>
As it's not currently possible for Wren-cli to access Xlib directly, we embed a Wren script in a C application to complete this task.
<
var GrabModeAsync = 1
Line 1,949:
xd.ungrabKey(xd.keysymToKeycode(X.stringToKeysym("F7")), Mod1Mask, drw)
xd.ungrabKey(xd.keysymToKeycode(X.stringToKeysym("F6")), Mod1Mask, drw)
xd.closeDisplay()</
<br>
We now embed this Wren script in the following C program, compile and run it.
<
#include <stdlib.h>
#include <string.h>
Line 2,111:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 2,127:
free(script);
return 0;
}</
{{omit from|ACL2}}
|