When I click a button it gets stuck

I developed a simple swift/cocoa application, and I am scripting it using system events. Sometimes when I click the button in my applescript the button stays pressed (with a blue color). Could it be related to the action the button does ? It is currently showing a progress window while in the background some files are uploaded. It does not happen all the time. I have tried putting more delay after the button click to allow it’s action to finish but it still happens sometimes.


I can’t answer your question, but I can ask you one: Why not just make your app scriptable? UI scripting should be a last resort.

My problem was my application. I changed the implementation of the button, and now it doesn’t get stuck anymore. At least the script ran all night without doing that.

I would like to make it scriptable. Need to make a google search on how to do that. Or maybe you can give me some references on any sites that teach that.


Apple’s docs are as good a place as any to start: