Jump to content
You must now use your email address to sign in [click for more info] ×

Recommended Posts

  • Staff
58 minutes ago, michalmph said:

Would be great to get an announcement when it hits the beta, I'll jump on the possibility to test it.

This thread will be notified when there is anything to look at, but that will not be 2.3 beta. There is a lot still to do

Patrick Connor
Serif Europe Ltd

"There is nothing noble in being superior to your fellow man. True nobility lies in being superior to your previous self."  W. L. Sheldon

 

Link to comment
Share on other sites

  • 2 weeks later...

I recently discovered Hammerspoon, which allows me to script (albeit inelegantly) actions with Affinity tools. Hammerspoon uses the Lua language and lets me simulate mouse clicks and text input, besides OS operations, which lets me, for instance, rotate an image one degree, export it with a unique name include the rotation angle, and repeat for the desired number of times.

The advantage of Hammerspoon is that as I use more and more apps (VSCode, Affinity) that will never add an AppleScript library, I still have scripting options.

I'll never be able to upgrade my Affinity tools since they stopped supporting Separated Mode for a 2-monitor Mac setup, so an external scripting tool like Hammerspoon is my best option. Infinitely simpler than learning Swift from the ground up.

Link to comment
Share on other sites

Lenovo IdeaPad 5 Ryzen 7 5700U Rx Vega 8 graphics 

16GB RAM (15.3 usable) 

Acer KB202 27in 1080p monitor

Affinity Photo 1.10.6

Affinity photo 2 2.4.2 Affinity Designer 2 2.4.2 Affinity Publisher 2 2.4.2 on Windows 11 Pro version 23H2

Beta builds as they come out.

canon 80d| sigma 18-200mm F3.5-6.3 DC MACRO OS HSM | Tamron SP AF 28-75mm f/2.8 XR Di LD | Canon EF-S 10-18mm f/4.5-5.6 IS STM Autofocus APS-C Lens, Black

 

Link to comment
Share on other sites

2 minutes ago, tzvi20 said:

What does that have to do with the ability to script Affinity Photo actions?

Link to comment
Share on other sites

I meant to put it in the AI forum oops.

Lenovo IdeaPad 5 Ryzen 7 5700U Rx Vega 8 graphics 

16GB RAM (15.3 usable) 

Acer KB202 27in 1080p monitor

Affinity Photo 1.10.6

Affinity photo 2 2.4.2 Affinity Designer 2 2.4.2 Affinity Publisher 2 2.4.2 on Windows 11 Pro version 23H2

Beta builds as they come out.

canon 80d| sigma 18-200mm F3.5-6.3 DC MACRO OS HSM | Tamron SP AF 28-75mm f/2.8 XR Di LD | Canon EF-S 10-18mm f/4.5-5.6 IS STM Autofocus APS-C Lens, Black

 

Link to comment
Share on other sites

On 8/27/2023 at 8:51 PM, spinhead said:

I recently discovered Hammerspoon, which allows me to script (albeit inelegantly) actions with Affinity tools. Hammerspoon uses the Lua language and lets me simulate mouse clicks and text input, besides OS operations, which lets me, for instance, rotate an image one degree, export it with a unique name include the rotation angle, and repeat for the desired number of times.

The advantage of Hammerspoon is that as I use more and more apps (VSCode, Affinity) that will never add an AppleScript library, I still have scripting options.

I'll never be able to upgrade my Affinity tools since they stopped supporting Separated Mode for a 2-monitor Mac setup, so an external scripting tool like Hammerspoon is my best option. Infinitely simpler than learning Swift from the ground up.

Well using Hammerspoon is better than nothing here and Lua is also a nice and easy to use (... especially for those comming from C). - Swift (or Obj-C) on the other hand is the common way to program mostly all for the Apple ecosystem. However, as far as there are no Affinity programming API and no associated scripting environment available, using third-party tools is actually the only way to slightly automate some limited things for the Affinity apps.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

55 minutes ago, v_kyr said:

Swift (or Obj-C) on the other hand is the common way to program mostly all for the Apple ecosystem

I spent months trying to get my head around Swift and never figured out how to move a window. Spent 20 minutes with Hammerspoon and had a working prototype for my needs. Perhaps I missed something important, but Swift feels like buying Russia because I want a bottle of vodka.

Link to comment
Share on other sites

1 hour ago, spinhead said:

I spent months trying to get my head around Swift and never figured out how to move a window.


let view = NSView()
view.window?.setFrameTopLeftPoint(CGPoint(x: 0, y: 0))

The net is usually full of examples and code hints here, it's just a matter to know to look after the right ones, depending on the Swift & MacOS versions, as both have evolved a lot over time.

1 hour ago, spinhead said:

Spent 20 minutes with Hammerspoon and had a working prototype for my needs.

Other than that via tools & apps ...

1 hour ago, spinhead said:

but Swift feels like buying Russia because I want a bottle of vodka

Well, Swift is more a full blown programming language for the Apple universe (like the older Obj-C/C++/C here too) and together with all the Apple macOS APIs and frameworks more meant to build all kind of apps. So things like Hammerspoon and the like, which in turn already do encapsulated the usual complexity here internally and offer for access a simpler Lua implemented scripting like functionality. So the later is better comparable with AppleScript & Automator like processings, or things I personally do use Python scripting for.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

12 minutes ago, v_kyr said:

The net is usually full of examples and code hints here, it's just a matter to know to look after the right ones...

comparable with AppleScript & Automator like processings, or things I personally do use Python scripting for.

1. all the usual rabbit holes I went down long ago (third link clearly says "this is NOT for moving windows in other apps" which essentially makes it the opposite of my needs) without success
2. yes, Hammerspoon is AppleScript but without needing the target app (Photo, VSCode, etc) to supply the dictionary. In other words, exactly what I was looking for.

Link to comment
Share on other sites

25 minutes ago, spinhead said:

... (third link clearly says "this is NOT for moving windows in other apps" which essentially makes it the opposite of my needs)

Then just refine your web search to include all the for you needed search terms "swift move another app window to a position" in order to get closer matches after what you are after. Then you will get results like this ...

... and there you can see then in one example how to get a list of all current app windows and how then to move the window of a specific app owner (aka the Terminal window in that example) to another position and how to give it a new size ...

let type = CGWindowListOption.optionOnScreenOnly
let windowList = CGWindowListCopyWindowInfo(type, kCGNullWindowID) as NSArray? as? [[String: AnyObject]]

for entry  in windowList!
{
  let owner = entry[kCGWindowOwnerName as String] as! String
  var bounds = entry[kCGWindowBounds as String] as? [String: Int]
  let pid = entry[kCGWindowOwnerPID as String] as? Int32

  if owner == "Terminal"
  {
    let appRef = AXUIElementCreateApplication(pid!);  //TopLevel Accessability Object of PID

    var value: AnyObject?
    let result = AXUIElementCopyAttributeValue(appRef, kAXWindowsAttribute as CFString, &value)

    if let windowList = value as? [AXUIElement]
    { print ("windowList #\(windowList)")
      if let window = windowList.first 
      {            
        var position : CFTypeRef
        var size : CFTypeRef
        var  newPoint = CGPoint(x: 0, y: 0)
        var newSize = CGSize(width: 800, height: 800)

        position = AXValueCreate(AXValueType(rawValue: kAXValueCGPointType)!,&newPoint)!;
        AXUIElementSetAttributeValue(windowList.first!, kAXPositionAttribute as CFString, position);

        size = AXValueCreate(AXValueType(rawValue: kAXValueCGSizeType)!,&newSize)!;
        AXUIElementSetAttributeValue(windowList.first!, kAXSizeAttribute as CFString, size);
      }
    } 
  }
}

Of course the whole is easier to do via a few lines of code in some adequate scripting capable tool here, so for example via Automator/AppleScript (and giving the resulting script then access for assistive devices) it would be just a few lines, so something like ...

Quote
tell application "System Events"
    tell application "Terminal" to activate
    set position of window 1 of application process "Terminal" to {100, 100}
end tell

... etc.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

5 minutes ago, v_kyr said:

Then just refine your web search to include all the for you needed search terms "swift move another app window to a position"

Automator/AppleScript (and giving the resulting script then access for assistive devices) it would be just a few lines, so something like ...

 

refining a search for something I don't need? I've found the perfect tool. Swift is in the past. it serves no purpose for me now; it's big, complicated, hard to learn, and has no value to me.

automator and AppleScript are PERFECT—except Affinity tools aren't exposed to AppleScript, so that's not terribly helpful.

I'm no longer sure if you're trying to help me with scripting or sharing information for others in this thread.

Link to comment
Share on other sites

1 hour ago, spinhead said:

refining a search for something I don't need? I've found the perfect tool. Swift is in the past. it serves no purpose for me now; it's big, complicated, hard to learn, and has no value to me.

automator and AppleScript are PERFECT—except Affinity tools aren't exposed to AppleScript, so that's not terribly helpful.

As you already know there are actually not that much scripting possibilities for the Affinity apps. Further since you've obviously already made up your mind about scripting here and found a solution that works for you, it doesn't seem necessary to mention everything else that is available as an external scripting app here!

1 hour ago, spinhead said:

I'm no longer sure if you're trying to help me with scripting or sharing information for others in this thread.

Neither of these, I was just saying that if you spend months with Swift (as you tell) just in order to move some desktop app windows, that you then probably did something essentiell wrong here, during your tryout phase to learn Swift.

☛ Affinity Designer 1.10.8 ◆ Affinity Photo 1.10.8 ◆ Affinity Publisher 1.10.8 ◆ OSX El Capitan
☛ Affinity V2.3 apps ◆ MacOS Sonoma 14.2 ◆ iPad OS 17.2

Link to comment
Share on other sites

  • 2 weeks later...

It's now been about 6 months since Tim France teased with some scripting news.

Given Adobe have just announced price increases for Creative Cloud, it would be nice if we could have any sort of update on any progress being made. Even the smallest glimmer of hope of when it might find its way into a beta.

It's hard to believe I started this thread over 5 years ago.

Link to comment
Share on other sites

VSCode has been around for 8 years and still doesn't have an AppleScript library. Affinity has discussed this possibility for even longer than that. 

If scripting these tools matters to you, find another way (like mentioned above.) It's not happening soon if it happens at all. 

Link to comment
Share on other sites

12 minutes ago, spinhead said:

VSCode has been around for 8 years and still doesn't have an AppleScript library. Affinity has discussed this possibility for even longer than that. 

If scripting these tools matters to you, find another way (like mentioned above.) It's not happening soon if it happens at all. 

VSCode was scriptable from the initial release. Affinity has already demonstrated this is work-in-progress. Some of us are excited about this news. Everyone is well aware of how long features have been desired. It really isn't productive input to this particular thread.

Link to comment
Share on other sites

  • Staff
On 9/16/2023 at 12:04 AM, kimtorch said:

[...] it would be nice if we could have any sort of update on any progress being made.

I'm happy to report that SDK development is progressing well. We are steadily working towards exposing enough app functionality to make useful plugins, but there's still quite a lot to do before we can consider even a "technology preview" release. 

Link to comment
Share on other sites

@Jon W Nice to hear that progress is being made. How much longer do you think it will be before it goes to beta?

Lenovo IdeaPad 5 Ryzen 7 5700U Rx Vega 8 graphics 

16GB RAM (15.3 usable) 

Acer KB202 27in 1080p monitor

Affinity Photo 1.10.6

Affinity photo 2 2.4.2 Affinity Designer 2 2.4.2 Affinity Publisher 2 2.4.2 on Windows 11 Pro version 23H2

Beta builds as they come out.

canon 80d| sigma 18-200mm F3.5-6.3 DC MACRO OS HSM | Tamron SP AF 28-75mm f/2.8 XR Di LD | Canon EF-S 10-18mm f/4.5-5.6 IS STM Autofocus APS-C Lens, Black

 

Link to comment
Share on other sites

I want to give appreciation to the Affinity team, I know all the hard work they have and are doing. 
The fact that we have an alternative to the expensive competition, it's already a big fresh of air.

Now that scripting is being worked on, and that JavaScript (and by direct relationship TypeScript) has been selected, 
I feel in good hands. I will be so excited when I can see the types of the elements highlighted in VSCode, and having intellisense of their properties 🔥🤯👏😍

Loved the video of the example, props to the person who coded it and recorded it! The circles animation was mindblowing! And the color pallete one too.

I've been very closely following this thread, and my feelings used to be disappointment. 

Now I have a smile on my face.

All the possibilities that scripting will bring to the Affinity Suite... wow...

All the repetitive tasks that will be avoided and all the time that will be gained... all the creative stuff people will come up with!

Feeling like a kid on Christmas! 😁🎁🎉🎊

Most of us in this thread are programmers, so let's be real, this will be implemented by version 3.0 or 4.0. Programming is a hard and time consuming job, even with the aid of A.I. we have today.
There are many recent libraries and frameworks that for example [INSERT THE MOST FAMOUS A.I. NAME HERE NOT TO ATTRACT SPAM] is not being able to provide correct information about.

Let's appreciate the fact that at least they are finally doing "something about it" and taking decisions and taking our feedback into consideration.

Most of the features I've requested in this forum have already been implemented and I shocked to realize the fact (only Live/Bitmap trace remaining).

Good things need time. Rushed things get messy. And this comes from a very impatient person with generalized anxiety.

I used to have a lot of fun coding VisualBasic to control MS Power Point 2007 and JSFL (JSAPI) for Ad*** Flash Professional CS6.

Will have fun with TypeScript controlling the Affinity Suite to automate my design flow and possibly sprite generating flow for some basic Turn-based/Adventure RPG games.

Wishing health, peace, and success to everyone, and my apologies if I've hurt someone with my comments. I used to be very angry all the time. Learned to pick my battles. This world needs more kindness, empathy, personal responsibility, forgiveness, patience. 

Link to comment
Share on other sites

  • 1 month later...

I am very glad the Affinity Team is getting around to automation in their software. From my point of view, they are adding a complex infrastructure in the apps to enable automation that we need. Keep in mind they are dealing with a very large code base and it is manual labor for computer science; so the bottle-neck are the developers themselves; I would rather they are responsible for their health first and not over tax their individual wellbeing. 

Link to comment
Share on other sites

  • 2 weeks later...

Thanks for the work you are doing on this. I want to help you make a product that will be seen by others (and myself) as being very useful and I think one of the very best places that scripting should be designed for is time savings and batch processing. I have hundreds of articles that need to use the exact same template. I need to be able to swap out the template on every one of them, and then click a button to recreate PDFs for them all. Can scripting do this? It should. Failing this type of usefulness, scripting is of very little value to me. And I would say probably of very little value to others, as well. "Batch processing is it" when it comes to scripting. Please don't forget batch processing. Otherwise, affinity publisher cannot serve me in the end. Thank you.

Link to comment
Share on other sites

  • Staff

Hi all,

The team has been making good progress. I don't have any updates on a release date but please be assured we are not sitting on our haunches - we want to get this feature out as much as you want it out!

Naturally we've been exposing more of the apps' functionality to scripts, but we've been working on plugin-specific technology too. For example, there's a new asynchronous file i/o and networking API, initially driven by the Javascript layer but then we thought it would be good for the lower level C/C++ plugins to have access too. Obviously with local and remote i/o, we've had to be careful that a script isn't covertly sending user data somewhere, so we've introduced a permissions system for Javascript plugins - unless you allow a particular script network access, it won't be able to use the networking API. It may not be a big shiny WOW! feature, but it's important to get these things right.

Anecdotally, I can tell you we've actually used some scripts internally to do some genuinely useful stuff that would have taken literally days to do manually. One script I wrote optimised a document and removed about 60000 layers. There have also been relatively simple layout and alignment tasks that scripts can munch through in the blink of an eye. Last week I wrote a script that split a pixel layer into new pixel layers containing the blocks of grouped pixels. Even the pixel processing was done in the script - I didn't have to rely on the app to do the heavy lifting for me because our performance is good enough to implement DBSCAN in Javascript.

Please be patient. We know you all want scripting available yesterday, but we're getting there!

Link to comment
Share on other sites

2 hours ago, Tim France said:

I don't have any updates on a release date but please be assured we are not sitting on our haunches - we want to get this feature out as much as you want it out!

Any progress report on this front is more than appreciated.

From what I know a lot of new development in inDesign is done in JavaScript, so I'm not surprised at all that JavaScript is performing so well in Affinity apps too.

2017 27” iMac 4.2 GHz Quad-Core Intel Core i7 • Radeon Pr 580 8GB • 64GB • Ventura 13.6.4.

iPad Pro (10.5-inch) • 256GB • Version 16.4

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.