Heya, so, ive been trying to make it so Text thats entered in a text field in Xcode is displayed in my game. I have a script where a popup window comes up on execute and allows me to type in what i want and have it spammed in game. But i was trying to make it so i can just enter it in a text field on the program, with no popup window.
i was trying something like this
on «event coVScliI» theObject
tell application "WoW Enhancer"
set keys to content of text field "Enter .go Coord:" of window "main"
tell application "world of warcraft" to keystroke keys
end tell
end «event coVScliI»
first, when i build this in my main script in Xcode i get this error
if i am on the right track with the code im trying to use, any ideas on how to fix that error? and if im not on track, can anyone share a code for what im trying to do please
two notes:
¢ «event coVScliI» is the equivalent to on clicked
¢ keystroke is a keyword of System Events, the usual syntax to perform keystrokes is
on clicked theObject
set keys to content of text field "Enter .go Coord:" of window "main"
activate application "WoW Enhancer"
tell application "System Events" to tell process "WoW Enhancer" to keystroke keys
end clicked
ah ok cool, so i made a cocoa text field in my interface and named it Enter .go Coord:
but do i need to now make a seperate button to activate it so it displays in My game? or press enter… or something like that.
on clicked theObject
set keys to content of text field "Enter .go Coord:" of window "main"
activate application "WoW Enhancer"
tell application "System Events" to tell process "WoW Enhancer" to keystroke keys
end clicked
is for the text field right?
what i dont understand still is like, dont i need to make a button to activate the text field? or is this script for the button and not the text field? just a tad confused
edit:
alright so
ive been trying this, but still aint workin.
clicked theObject
if name of theObject is "enter" then
set win to window of theObject
set enter to contents of text field of win
tell application "world of warcraft" to activate
enter
alright… so i tried to use this script and use the test " check" to test it. but when i try to do it it says,. “error, world of warcraft cant get keystroke check”
=/
on clicked theobject
set keys to content of text field "whatever" of window "window"
tell application "Microsoft Word" to keystroke keys
end clicked
end
end
end clicked
you have either define an object like a button which evokes the on clicked handler or connect the text field to the end editing handler,
which will be called e.g when pressing the return key
bleh i dunno why i cant get this. all these havent worked. i tried doing what you said stefan and came up with this
on clicked theobject
repeat 1 times
tell application "System Events"
set keys to content of text field "whatever" of window "main"
tell application "Microsoft Word" to activate
keystroke keys
end tell
delay 1
end repeat
if theobject is "Enter" then
tell application "Microsoft Word" to activate
keystroke keys
end if
(*Add your script here.*)
end clicked
i think this mite be it, almost, but when i run the app and type what i want and hit the button etc. it says
i think its saying like, i dont have my text field named properly? or using the wrong kind of text field? anyone? :-X
this seems like its so simple and should just Work, but i dont get it!
three notes:
¢ you should separate the code which belongs to Xcode from the applications to talk to.
¢ keystrokes via System Events should be send to the application process of the application
¢ repeat 1 times is the same as omitting the repeat block
try this:
on clicked theobject
set keys to contents of text field "whatever" of window "main"
activate application "Microsoft Word"
tell application "System Events"
tell process "Microsoft Word" to keystroke keys
end tell
if theobject is "Enter" then
tell application "System Events"
tell process "Microsoft Word" to keystroke keys
end if
(*Add your script here.*)
end clicked
Mmmk so i tried that, changed a few of the “end” parts so it would compile. so:
on clicked theobject
set keys to contents of text field "whatever" of window "main"
activate application "Microsoft Word"
tell application "System Events"
tell process "Microsoft Word" to keystroke keys
end tell
if theobject is "Enter" then
tell application "System Events"
tell process "Microsoft Word" to keystroke keys
end tell
end if
end clicked
when i do this and try to use the program i get the error again
could it like … be the version of xcode im running or something lol? any other thoughts would be well appreciated
on clicked theobject
set keys to contents of text field "whatever" of window "main"
activate application "Microsoft Word"
tell application "System Events"
tell process "Microsoft Word" to keystroke keys
end tell
if name of theobject is "Enter" then
tell application "System Events"
tell process "Microsoft Word" to keystroke keys
end tell
end if
end clicked
still no workey lol
keep getting this error, i tried puttin it in a new project and trying different text boxes jsut to test, but no luck :-[