Notifier Positioning
  • I tried to post yesterday, but timed out on the submission and lost my message, so I posted to MacScripter and got some answers. Here's the thread:

    http://bbs.applescript.net/viewtopic.php?id=13252

    By the way; this doesn't work:
        display message \"foo\" at screen position center dismissing after delay 0
    set x to screen position of message window 1

    But this does:
     tell application \"FastScripts\"
    display message \"foo\" at screen position center dismissing after delay 0
    end tell
    get bounds of window 1 -- using the Finder to locate the window
  • Hi NovaScotian - sorry about the timeout issue. I'm not sure how I can improve the forum to prevent that. I tried to post a message and left it to idle for several hours and didn't experience the problem. I will poke around the PunBB forums and see if anybody has advice about that.

    Regarding the gist of the MacScripter discussion between you and JJ, I think JJ is right and has a great point about the failure of the "screen position" attribute of FastScripts message windows. This is definitely a bug and I will fix it for an upcoming release. The "display message" functionailty is sort of under-emphasized and I don't think many people have tried it out, so there are probably of nuanced improvements that can be made.

    As far as the requirement that scripts target FastScripts specifically, I think I am comfortable with this. In fact, I'm not really sure how it happened, and I'm not sure I could do anything to change it. But I think it's good for scripts to treat FastScripts as a service instead of a "default host" - it will make the script for flexible and, for example, ensure that it continues to operate as expected if it's saved as an application.

    Let me know if you have any other thoughts on these issues,

    Daniel
  • Straight AppleScript has only two rather ugly ways of communicating with a user: a display dialog window and the assorted choose options most of which just use system tools (choose from list being the exception). In pursuing more attractive means, I have tried (and use to some extent) Growl, LanOSD, iNotify, and now FastScripts' "display message".

    I like the window presented by FastScripts messages, I like that I can position it, and I like the simplicity of setting one up (unlike Growl which requires registering it). I like the "Smoke" notifier in Growl, but can't position it. iNotify is new and improving quite rapidly, but has the greatest flexibility with rollovers permitted, etc. LanOSD seems to have been abandoned by its author. There are lots of other comparitive details, too many for this post.

    FastScripts has the problem that notifications at the same position stack on top of one another, but there is as yet no way to find out where they are so that another notification, perhaps from another script, can avoid using the same position. That was the genesis of this thread.
  • Good summary. For what it's worth the behavior in FastScripts was mostly inspired by LanOSD, so it's probably going to be most similar to that. At the time, I didn't know about Growl or any of the other options.

    I think there are two things FastScripts should do. In the short term, I'm going to fix the screen position getting and setting issues. In the longer term, I think it might make sense for FastScripts to automatically tile notifications that are made to the same screen position. For instance, if you did two notifications to the top-left, then the first note would be at the very top-left, and the second note just below it.

    Daniel
  • Daniel Jalkut said:
    For instance, if you did two notifications to the top-left, then the first note would be at the very top-left, and the second note just below it.

    First, thanks for the email. Appreciated.

    Second, your quote above is what Growl does, but beware of a problem they have: if the number or size of notifications exceeds the screen height, they go off screen where they can't be read or reached.
  • Thanks, a good thing to keep in mind as I look into supporting that.
  • Along the same lines, having some of your positions expressed as two words is problematic if you want to program where the display goes in a handler like "on show(message, location)" because AppleScript won't accept a two-word location as an input variable.

    It would be better if "top center/top left/center/bottom right/bottom left/bottom center/top right" were expressed as
    "top_center/top_left/center/bottom_right/bottom_left/bottom_center/top_right".

    As another way, FastScripts could accept an integer from 1 through 8 corresponding to those locations in addition to the names. Then I could say "on show(message, 8)", etc. and get the text in the top right corner.

    Finally, FastScripts could require quotes around the location text because AppleScript will then accept that as a location in a handler.

    Just a suggestion.
  • Thanks - that's interesting. I didn't know about the limitation on multi-word parameters in AppleScript. I will have to look into this a bit more and consider how I should best address the situation.

    Daniel
  • Daniel Jalkut said:
    Thanks - that's interesting. I didn't know about the limitation on multi-word parameters in AppleScript. I will have to look into this a bit more and consider how I should best address the situation.

    Daniel

    The difficulty is that an AppleScript variable cannot be two words, but worse, I can't even set something like

    set location to center

    because I'll get a "center is undefined". - To the script, center is not a key word. I suppose a "using terms from" construction might do it, but I haven't tried. The problem is solved if the location is text.

    Then I can do something like this:

    set myHeader to "Some Title"
    set myMsg to "Hi There"
    set atLoc to "top right"
    show(myHeader, myMsg, atLoc)

    on show(theTitle, theWords, theLocation)
    -- organize the display, for example:
    set myNote to theTitle & return & return & space & space & theWords & return
    -- in my case, I want to display a matrix given a list of lists of elements but the principle is the same.
    tell application "FastScripts"
    display message myNote at screen position theLocation dismissing after delay 0
    end tell
    end show
  • I think it's pretty typical that an Application's types are only available within "tell" blocks. For example, this code works:

    tell application \"FastScripts\"
    set myPos to top left
    end tell

    ShowMessageAtPosition(\"hello there\", myPos)

    on ShowMessageAtPosition(message, position)
    tell application \"FastScripts\"
    display message message at screen position position
    end tell
    end ShowMessageAtPosition

    I can see your reasoning for wanting the convenience of variables that can be setup without a "tell" block, but I think it would defy the purpose of AppleScript's typing system to switch to completely text-based arguments.
  • Ahh - problem solved without any modifications required:

    using terms from application \"FastScripts\"
    set TR to top right
    set Ctr to center
    -- etc. for the other 6
    end using

    set myMsg to \"Hi There
    set myLoc to TR

    tell application \"FastScripts\"
    display message myMsg at screen position myLoc dismissing after 0
    end tell



    This works just fine.

    So does this which displays them all.

    using terms from application \"FastScripts\"
    set theLocs to {top center, top left, center, bottom right, bottom left, bottom center, top right}
    end using terms from

    set msg to \"Hi There\"
    repeat with anItem in theLocs
    set myLoc to anItem
    tell application \"FastScripts\"
    display message msg at screen position myLoc dismissing after delay 1
    end tell
    end repeat

  • Looks like a good solution. I guess you just have to let AppleScript know one way or another that the type is coming from FastScripts, but once you get it, you can pass it around freely.

    Daniel
  • Yup. Either of those solves my problem which involves constructing a table and displaying it in various stages of development so I have to be able to see them all.
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!