Mit AppleScript zu einem virtuellen Zehnerblock

Mittwoch, 25 August 2010
0.0/5 Bewertung (0 Stimmen)
Beschreibung

Die Tastaturen auf MacBooks und nun auch bei Desktops haben keinen Zehnerblock mehr. Eine zeitlang hatten die Tastaturen von MacBooks ein Numlock-Taste mit der Sie die Buchstabentasten auf der rechten Seite der Tastatur als Zehnerblock benutzen konnten, aber auch diese Feature scheint verschwunden zu sein. Es kann jedoch wieder mit AplleScript zurückgeholt werden. [crarko: Dies funktioniert auch durch Drücken der ”fn”-Taste, was aber genauso unhandlich ist.]
Der nachfolgende Kode erlaubt Ihnen die Zahleneingabe als ob der Zehnerblock existiert. Es konvertiert die Buchstaben in die entsprechenden Zahlen und kopiert das Resultat in die Zwischenablage. Wenn Sie einen Zehnerblock benötigen, starten Sie einfach dieses Programm, gehen zurück auf das vorherige Programm und fügen den Inhalt der Zwischenablage ein. Sie können auch ganz normal mit der Eingabe fortfahren, in dem Sie zwei Leerzeichen benutzen. Das schaltet in den Text-Modus bzw. zurück. Beispiel: ”jkl jkl jkl” produziert ”123jkl123”. Wenn Sie drei Leerzeichen benutzen, wird ein Leerzeichen dargestellt (”123 jkl 123”). Sie können eingeben: ”Meine Lieblingszahl lautet jkluio789 .” und erhalten ”Meine Lieblingszahl lautet 123456789.” Tasten, die keine Zahlen repräsentieren erscheinen unverändert. Im Folgenden sehen Sie, was jede Taste darstellt [crarko: Das Bild unter Download weiter unten, stellt das ganze etwas besser dar]:
[COLOR=Sienna]U=4 I=5 O=6 P=+
J=1 K=2 L=3
M=0 ,=00
7, 8 und 9 bleiben das selbe.[/COLOR]
Normalerweise werden Zehnerblock-Tasten nicht gepuffert, sodass dies hier ein wenig dauert. Aber, ich finde, dass hier geht schneller als die Zahlen in der oberen Reihe zu benutzen.

 set toQuit to false
repeat while toQuit is false
set dd to display dialog ”Enter text...” with title ”Numpad” buttons {”Quit”, ”Continue”} default button 2 default answer ””
set ddText to text returned of dd as string
set ddBtn to button returned of dd as string
if ddBtn is ”Quit” then set toQuit to true
if ddBtn is ”Continue” then
set oldDel to AppleScript”s text item delimiters as string
set AppleScript”s text item delimiters to ”” as string
set chars to items of ddText as list
set AppleScript”s text item delimiters to oldDel as string
set nums to chars
set sp to false
set spSet to false
set spUnSet to false
considering case
set valNum to 1 as integer
repeat with val in nums
if spSet is true then
set spSet to false
set valNum to valNum + 1
else
if spUnSet is true then
set spUnSet to false
set valNum to valNum + 1
else
if sp is true then
if (val as string) is ” ” then
if (item (valNum + 1) of nums) is ” ” then
set sp to false
set spUnSet to true
end if
end if
set valNum to valNum + 1
else
if (val as string) is ”u” then set item valNum of nums to ”4”
if (val as string) is ”i” then set item valNum of nums to ”5”
if (val as string) is ”o” then set item valNum of nums to ”6”
if (val as string) is ”p” then set item valNum of nums to ”+”
if (val as string) is ”j” then set item valNum of nums to ”1”
if (val as string) is ”k” then set item valNum of nums to ”2”
if (val as string) is ”l” then set item valNum of nums to ”3”
if (val as string) is ”m” then set item valNum of nums to ”0”
if (val as string) is ”,” then set item valNum of nums to ”00”
if (val as string) is ” ” then
if (item (valNum + 1) of nums) is ” ” then
set sp to true
set spSet to true
end if
end if
set valNum to valNum + 1
end if
end if
end if
end repeat
end considering
set numsText to nums as string
if numsText contains ” ” then
set oldDel to AppleScript”s text item delimiters as string
set AppleScript”s text item delimiters to ” ” as string
set num to 1
set sps to (count text items of numsText) as integer
set numsText2 to ”” as string
repeat with num from 1 to sps
set numsText2 to (numsText2 & text item num of numsText) as string
set num to num + 1
end repeat
set AppleScript”s text item delimiters to oldDel as string
else
set numsText2 to numsText
end if
set the clipboard to numsText2
end if
end repeat

[crarko: Wenn Sie dieses Beispiel testen wollen, müssen Sie den Text eingeben, Kopieren und Einfügen funktioniert hier nicht. Es dauert zwar ein paar Minuten den Modus zu ändern, aber es funktioniert. Der Quell-Kode, eine kompilierte Version der App und ein Bild mit dem virtuellen Zehnerblock ist [url=http://www.macosxhints.com/dlfiles/AS_Numpad.zip]hier[/url] zu finden.]

Spezifikationen

Hits

1352

© by macjaner.ch | Powered by GoeGG-ArT.ch