Gui scripting using AppleScript not working
Before i get too complicated, I am starting with getting a basic copy/paste using keyboard shortcuts to work. In theory if i can copy a cells value into another cell using keyboard shortcuts, i can use any keyboard shortcuts i need for more complicated scripts.
Can someone more knowledgable than I look over the below core code and tell me what i am doing wrong?
(I have added script editor to accessibilities security settings to allow it to control the computer.)
My code for a simple copy/paste in numbers (other programs also don't respond):
onrun
tellapplication "Numbers"
activate
ifnot (existsdocument 1) thenerrornumber 1000
telldocument 1
tell active sheet
settheselectedTableto (thefirsttablewhoseclassofselection rangeisrange)
setmyRowstocounttherowsinselectedTable
tell selectedTable
settheselection rangetocell 2 ofrow 3
sendCopy
settheselection rangetocell 4 ofrow 3
sendPaste
endtell
endtell
endtell
endtell
endrun
on sendCopy()
tellapplication "Numbers" toactivate
tellapplication "System Events"
tell application process "Numbers"
keystroke "C"
endtell
endtell
end sendCopy
on sendPaste()
tellapplication "Numbers" toactivate
tellapplication "System Events"
tell application process "Numbers"
keystroke "V"
endtell
endtell
end sendPaste
Thanks
Jason
iPad, iOS 9.3.2, iPad, macMini, iPhone