Xcode 4 - Create shortcut for tabs - xcode

Is there a way to assign shortcut to applescript that can control tabs on Xcode 4 ? Something like this works for Safari, but not Xcode 4 :
try
tell front window of application "Xcode" to set current tab to tab 1
on error
tell front window of application "Xcode" to set current tab to last tab
end try
(I have an error : A property can’t go after this identifier.)
I know I can switch tabs with cmd-}, I want to be able to go to a tab by its number

Because Xcode 4 is so young, the Applescript dictionary is basically empty. You may have to wait for Xcode 4.1 or 4.2 before you can do any kind of complicated scripting.
I would file a radar bug if this is really important to you. It's like voting. If you are lucky enough to have a WWDC ticket, make sure to mention it to all the apple engineers you meet there.
Xcode 4 was an ambitious redesign. In an effort to ship, quite a few features got cut (applescript, user scripts being the more glaring). I would expect them to make a comeback over time, but you need to make your needs known.

Related

Minimalist cocoa app, how to create a menu bar?

I’m just trying to create a window in cocoa. I wanted to use this code as a basis but somehow the app menu does not show up (still shows the one from the terminal, un-clickable though).
Can anybody give me a hint what might have changed in cocoa since that article was written? I’m using Yosemite.
It works fine for me, but I had to Cmd-Tab switch away and back again to the running executable before the app menu became active. I tried appending a space and the ampersand symbol to the end of the code, which tells the shell to background the task, thinking it may launch normally then, but to no avail.
You might try appending an AppleScript command such as tell application MinimalistCocoaApp to activate after the command to launch ./MinimalistCocoaApp (separated by a semicolon). I'm not sure the "compile and run" terminal command for AppleScript, but that should be easily Googled.

Keynote properties not being passed to Applescript

I need my Mac to say the number of the current slide when presenting. I've written the below script, but it's not working as expected.
on slideNumber()
tell application "Keynote"
return the slide number of the current slide of the front document
end tell
end slideNumber
repeat
say slideNumber()
delay 1
end repeat
When I run this is will correctly say the current slide number in Keynote, however if I go to Keynote and change slides, or start presenting the slides, the Applescript doesn't update the slide number. If I go back to the Applescript window it immediately starts saying the correct slide number.
I've also tried this using:
on idle
say slideNumber()
return 1
end idle
and exporting as a stay-open application, but the same problem occurs.
Is it not possible to have the Applescript application return the correct slide number without the application/script being in the foreground? I'm using Keynote 6.2 if that's relevant.
I realize this question is old. For what it's worth, having seen it just now, your script works perfectly fine for me. I'm on macOS Sierra (10.12.1) using Keynote version 7.0.5. Copy/pasted your script into Script Editor and ran it. Speaks correct slide number as I switch between slides both in edit mode and while presenting.
Could there have been something wrong with the scripting interface of Keynote 6.2? I have seen cases where a buggy app just doesn't do what it advertises, and a later version fixes it. Do you still specifically need this to run against Keynote 6.2?

Keyboard events don't work with irrlicht on Xcode

When I run my Irrlicht application in Xcode, I can't use keyboard input:
If I press a key while the application is running, I end up writing that letter on whichever window was opened before the application, for example: I'm editing my code, than I press Build/run, the application opens (I press with the mouse on the window just to make sure it is focused) and than I press a key and that letter is written in the editor window...
I am certain the problem is not from the code, because if I press the top bar of the application's window, press the key, and release the mouse button (in a fast motion) the event gets fired..
Now, from what I read in this link (fourth post), it seems there's an incompatibility between command-line application with Xcode and irrlicht. The guy changed to a Cocoa application and got it to work. I don't know how to do this, since Irrlicht uses lots of namespaces and with cocoa I get loads of problems with it..
Any idea? thanks!
Well after a random search i found this guide:
http://irrlicht.sourceforge.net/forum/viewtopic.php?f=5&t=13890&start=60
Some things were different with my Xcode 3.2.6 (e.g. i had no *AppDelegate.m, *AppDelegate.h nor *.xib file) but easy to get to the end of the tutorial.
In the end i got like 1000 errors, something to do with precompile appkit.h errors, and with a quick search here is the solution for all those errors:
http://www.cocoabuilder.com/archive/cocoa/194905-xcode-cocoa-project-with.html#195211
easy peasy :)

How to move a window to a certain desktop with AppleScript?

I have an application/window on Desktop 1 (OS X Lion) and I'd like to move it to Desktop 3. Any insights on how to do this? Not as big a deal, but if possible I'd like to ensure there are 3 and only 3 Desktops available.
This answer should offer clues on how to do place applications, specifically...
tell application "System Events"
set x to application bindings of spaces preferences of expose preferences
set x to {|com.apple.textedit|:4} & x -- Have TextEdit appear in space 4
set application bindings of spaces preferences of expose preferences to x
end tell
I would imagine moving a window is not too different.
I realize this question is old, but in case anyone still needs this functionality, I thought I'd share my solution.
Because there aren't any real scripting exposures in Mission Control, you'll need to manipulate the cursor and thus will need access to the Objective-C bridge. This requires using the JXA variant of AppleScript, but still allows things to run natively without any plugins.
If you're still interested I've shared the solution on my GitHub repository, stephan-hates-osascript.
Moving a window works while switching to different desktops with a keyboard shortcut.
With the mouse, click and hold the title bar as if you are moving the window around your desktop, then press ctrl+3. Ctrl+3 has to be mapped to move to desktop 3 in the keyboard shortcuts interface. Ctrl+Right twice also works. Then release the mouse button.

Instruments 4.1 unresponsive to projects launched from Xcode 4.1 until pressing Cmd-Tab

If I open Instruments and select a standard application (e.g. Mail or MS Word) it has no issue.
If I am in Xcode and I go to Product > Profile (or press Cmd + I), it launches Instruments, allows me to select a template, and loads the standard screen. Then the downward arrow starts tracing to the right as it should, and the iOS simulator launches the program. However, nothing is plotted in Instruments. It shows no changes to anything no matter what the app is doing. I can't click anything in Instruments: no menu's, can't stop recording, can't open tabs, etc.
I randomly discovered that if I hit Cmd + Tab, Instruments will start behaving normally. This seems really strange to me. Either it's a bug or it's a hole in my knowledge about how to operate Instruments.
Strange bug is fixed in XCode 4.2!
The problem was the hidden password dialog, so sometime it works and sometimes not.
One of possible solutions was:
Run Instruments
Cmd Tab to Xcode covering the instruments. Cycle and hide messages until password dialog is found.
Close Xcode.
PS: I know it is a few years to late for the answer, I was just looking for unanswered questions. Just check as answered - > it's good for both of us. )

Resources