Dispatch Keyboard Event (Left arrow)

534 views
Skip to first unread message

entrada70

unread,
Nov 22, 2010, 5:24:22 PM11/22/10
to Fake
Hello I need to Dispatch Keyboard Event. Just press the Left arrow. I
have read that the javascript Key Code for Left Arrow is '37'. But I
can't do it in fake. Please, could someone help me using 'Dispatch
Keyboard Event' ?

Thanks so much. Your program is really useful

Todd Ditchendorf

unread,
Nov 22, 2010, 7:55:57 PM11/22/10
to fak...@googlegroups.com
Hi entrada,

I am able to produce the JS keydown and keyup events associated with a
left arrow keystroke (there is no 'keypress' event for this keystroke)
in two ways:

https://skitch.com/itod/rb1bm/left-arrow-key-events

or

https://skitch.com/itod/rb1bt/autotype-a-left-arrow-key


The first should be self-explanatory. the second utilizes an
under-publicized feature of Fake.app where you can produce control key
keystrokes by doing things like:

{{opt}} or {{back}} {{up}}

in a "Set Value of HTML Element" Action


The good news is that both techniques produce the correct JS
keydown/keyup event sequence. the bad news is that neither actually
causes the cursor to move to the left.

Does anyone know if it is possible to actually move the cursor in JS?
window.selection object? maybe?

not sure.... but that's a general JS question, not a fake question. If
it can be done, it should be possible with a "Do JavaScript" Action.

hope that helps.
TD

David Marsh

unread,
Dec 7, 2013, 10:12:18 PM12/7/13
to fak...@googlegroups.com
This applescript worked for me, but YYMV:

tell application "System Events"
tell application "Fake" to activate
keystroke (key code 123)
end tell

Christopher Stone

unread,
Dec 8, 2013, 10:50:28 PM12/8/13
to Fake
On Dec 07, 2013, at 21:12, David Marsh <rdm...@gmail.com> wrote:
This applescript worked for me, but YYMV:
______________________________________________________________________

Hey David,

If Fake is already running this is the more canonical way of writing that:

tell application "System Events"
# Only if Fake is not frontmost when you run the script.
tell process "BBEdit" to set frontmost to true


keystroke (get key code 123)
end tell

--
Best Regards,
Chris

Christopher Stone

unread,
Dec 8, 2013, 11:00:52 PM12/8/13
to Fake
On Dec 08, 2013, at 21:50, Christopher Stone <listm...@thestoneforge.com> wrote:
tell process "BBEdit" to set frontmost to true
______________________________________________________________________

Whups.  I was testing with BBEdit.  :)

--
Best Regards,
Chris

Reply all
Reply to author
Forward
0 new messages