Applescript to simulate key strokes to application
I am making an onscreen keyboard for use inside jweb and other text fields in max. The only way I think I can make this work inside jweb (and EVERYWHERE) in max is to simulate key presses at the OS level...much like onscreen 3rd party keyboard applications do. I got this code from a site:
tell application "iTunes"
activate
if player state is not stopped then
tell application "System Events" to key code 37 using command down
end if
end tell
I'm using this as an example for inputting key codes...not getting it to work.
For this test: I want the user to be able to click inside textedit or jweb and then hit that message box...a lower case 'l' should appear in the youtube search box or the textedit...any ideas?
looks promising. I placed the autobot.class file under java/classes but [mxj autobot] does not work...
Only works on my windows machine...I use osx mainly. Either way if you use autobot you still cannot send key strokes to a textedit or jweb item that is not in focus... The problem remains.
I don't think this problem is solvable...even if you can communicate to the OS to do a keystroke, if the MAX item that you want to send it to is not highlighted, it will never receive it...
marcoskohler wrote on Wed, 01 July 2009 02:35I don't think this problem is solvable...even if you can communicate to the OS to do a keystroke, if the MAX item that you want to send it to is not highlighted, it will never receive it...
What do you mean by highlighted: displayed, frontmost?
If the item is displayed, this item is AppleScriptable via the System Events.
If the item is not displayed, that becomes more complicated but doable.
marcoskohler wrote on Tue, 30 June 2009 18:35I don't think this problem is solvable...even if you can communicate to the OS to do a keystroke, if the MAX item that you want to send it to is not highlighted, it will never receive it...
That's not true at all...even Rui's example in the other thread showed this. You just need to keep track of what "element" of your patch called up the keyboard and route all the on screen clicks towards that element/object/whatever. You certainly have a more complicated task getting this outside max, but within max I don't see where the problem is. Patch to illustrate your woes?
David
David Beaudry wrote on Wed, 01 July 2009 00:59marcoskohler wrote on Tue, 30 June 2009 18:35I don't think this problem is solvable...even if you can communicate to the OS to do a keystroke, if the MAX item that you want to send it to is not highlighted, it will never receive it...
That's not true at all...even Rui's example in the other thread showed this. You just need to keep track of what "element" of your patch called up the keyboard and route all the on screen clicks towards that element/object/whatever. You certainly have a more complicated task getting this outside max, but within max I don't see where the problem is. Patch to illustrate your woes?
David
I posted it. Show me a "black box" that will accept a message box with the letter "m", that when clicked, will go to a the currently selected text edit box as well as any currently selected field in a jweb...youtube's search box for example.
Have a look at the patch below. The annoying part is getting the focus onto the [textedit] before executing the applescript because obviously the focus is moved to the last object that's been interacted with, in this case the [button].
lh