I've looked everywhere for an answer but can't find anything on this. When I run this code the action AXShowMenu executes correctly. But the script continues to run for a few seconds and throws the error:
"action "AXShowMenu" of menu button of text field of scroll area 3 of splitter group 1 of window "Messages" of process "Messages" doesn’t understand the “perform” message."
Am I missing something painfully obvious here? How can I get Applescript to move on after it executes the AXShowMenu action?
tell application "System Events"
tell process "Messages"
perform action "AXShowMenu" of menu button of text field of scroll area 3 of splitter group 1 of window "Messages"
end tell
end tell
AXShowMenu
This is the link to the menu i'm trying to access. The element can be created if you create a new message and input some text in the text field.
Having established your end goal is to determine whether the number entered into the To: field in the Messages app operates under the iMessage service or the SMS service, you could try using properties of the buddies and services objects to determine whether they can be used to discriminate effectively between the types of numbers.
As I don't have an iPhone, I lack SMS capability from my Messages app. However, what I've observed when I enter some random number is that it will be categorised by the Messages app into the type of service that, I assume, will be the most appropriate for the nature of the number:
use application "Messages"
service type of services of buddy "12343" = iMessage
For me, this returns true, simply because iMessage is the only active service type that operates in my Messages app. However, this response is inline with what appears in the popup menu within the app.
So, assuming the logic follows, I would hope that you could either make use of those two lines as they are, swapping out the number as needed, and working off a value that will either be true or false; or perhaps first working out if your Messages app has a "default" service into which it will categorise numbers of uncertain nature. My guess is that it will favour "SMS" rather than iMessage given both available services to choose from, in which case the following script might be more suitable:
use application "Messages"
name of service of buddy "12343" = "SMS"
NB: It's possible that different locales use different service names, and what AppleScript on a British system refers to as service "SMS" might be service "Text Message" on a US system, or wherever you're located.
You can easily perform a quick initial check on the names of each Messages service by running tell application "Messages" to get the name of every service. The list will contain 4 or 5 potential services, but it'll be clear which applies to text messaging, and slightly ambiguous but eventually apparent which applies to iMessaging.
Related
We are looking to use Mail.app's rules to define certain criteria and, when such criteria is met, to use AppleScript to send a single text message separately to multiple individuals (not as a group text). How can this be accomplished?
This 2006 post on Mac OS X Hints looked to do something similar, but the code referenced is inaccessible due to link rot. This question shows how to send an SMS, but it only sends a single message.
You'll first need to set up iMessage in Messages so you can send texts from your Mac.
Then, open Script Editor, create a new script, and paste in the following code:
property recipients : {"+1 (999) 999-9999", "email#icloud.com"}
repeat with recipient in recipients
tell application "Messages"
send "your message here" to participant recipient
end tell
end repeat
In recipients, add as many phone numbers or emails that can receive texts as needed between the curly brackets, each in quotations and separated from the previous one by a comma, and edit your message here to the message you want to send.
Save the script in ~/Library/Application Scripts/com.apple.mail, as explained here.
Create your mail rule and, under Perform the following actions:, include a Run AppleScript action and select the saved script. Once the rule is saved, you're all done.
Upon receiving an email that meets the criteria of the rule you set up, the script will loop through each phone number or email in recipients and send them the specified message. The script has no problem sending a message to a contact you've never messaged before.
I often have to use the event model in an application based on Windows messages to notify the main thread of the application about some of the results of other threads. This approach allows you to get rid of blocking between threads.
The documentation says that system message IDs must be unique. But I did not find such a condition for application messages. At the same time, very often on the Internet you can find the opinion that within the application, message identifiers must be unique.
I see no point in being unique within the application. When sending a message, we specify a specific window handle that should process the message. I can use the same message ID in different windows, but it is the window handle that determines the recipient of the message. And it works.
Are there any obvious reasons to keep track of the uniqueness of message IDs in the application?
There is no requirement that all message IDs be unique within an application. In fact, we are using multiply assigned message IDs all the time: WM_USER-based messages are used by window classes to implement class-specific behavior. The most prominent example are the Common Controls that implement control-specific behavior using the [WM_USER..WM_APP) range of message IDs.
If you are calling RegisterClassEx you opt in to using WM_USER-based messages. You are free to reuse any value used by a different window class without risking a collision. It's the combination of the receiving window's class and the message ID that controls the behavior.
If you don't have a receiver (e.g. when calling PostThreadMessage) you would need to make sure that you can uniquely identify a message (and its payload). The easiest way in this case is to use unique message IDs in the WM_APP range.
I am trying to leverage Apple Mail's search capability to quickly get to a list of emails based on content. If I step through with AppleScript and extract each emails content, it takes about 100 times longer:
repeat with aMessage in (messages of inbox whose date received ≥ dDate)
set tContent to content of aMessage as rich text
if "findtext" is in tContent then
do stuff
end if
end repeat
How can do one of the following:
1. Use the UI commands to type in a search term and access the selected messages in a script.
2. Use the UI commands to switch to a custom or favorite MailBox and then access the selected messages in a script.
Thanks in advance.
There does not seem to be a way to actually do this in Outlook. I switched to Apple Mail and was able to get it to work a little faster using similar code.
I’m a beginner at Camunda/BPMN and I want to use it to control what is going on in nodejs, mostly likely using a REST API, at least for now. (Unless folks have a better idea for how nodejs should talk to Camunda.) My goal is to deliver systems where non-programmers can update the business logic in very practical ways.
I'd like to trigger the start of perhaps more-than-one process by sending a REST message, say to reflect that "a new insurance policy has been sold" and that might trigger the instantiation of say 2 processes on Monday but perhaps on Tuesday we add a third and now the same REST API call should now trigger more activity on Wednesday. (I figure it is better for nodejs to know about events but not about the process definitions. After all, my goal is to use Camunda as a sort of business logic server for my application. The less the nodejs code needs to know, the better.)
Which REST API should I be using to express the message that, say "a new insurance policy has been sold"? When I look at:
https://docs.camunda.org/manual/develop/reference/rest/signal/post-signal/
I find it very confusing. What should "name" match in the biz process definitions? I assume I don't need an executionId? I assume I can leave out tenantId?
Would some string in the message match the ID of a start event in one or more process definitions (or what has to match what)?
When I look at a process, is there an easy way to tell what variables I need to supply to start that process running?
Should I perhaps avoid using this event-oriented style of kicking off processes and just use the POST /process-definition/key/{key}/start? It would seem to me to be better form to trigger activity with events or signals or something like that rather than to have my nodejs code know about the specific process definition by name.
Should I be using events or signals in this case?
I gather that the start event should not be a "None Start Event" but I'm not clear on what type of start event TO use if I want automatic triggering based on events or signals or something? Would a "Non-interrupting - Message Start Event" be the right sort? I'm finding this confusing.
Once I have triggered the process to start, what does nodejs need to send to step the process forward from one task in that instance to the next?
Thanks!
In order to instantiate a new workflow instance you have the following possibilities:
Start exactly one instance:
Start a workflow instance by its known "key": https://docs.camunda.org/manual/develop/reference/rest/process-definition/post-start-process-instance/
Start a workflow by a message start event: https://docs.camunda.org/manual/develop/reference/rest/message/post-message/. A message can only start one specific workflow instance, it is not allowed that this is not a unique relationship. The message start event is the one you have to use in your BPMN process model. See also https://docs.camunda.org/manual/develop/reference/bpmn20/events/message-events/. This might indeed be the better approach to make your client independent of the process definition key.
Start multiple instances:
- Start a workflow instance by a BPMN signal event: https://docs.camunda.org/manual/develop/reference/rest/signal/post-signal/. The signal name could start many instances as once.
The name of the message or name of signal would be configured in the BPMN model. Both could work for your use case.
Once a process instance is started it will move automatically execute the next steps.
Probably following this example (https://blog.bernd-ruecker.com/use-camunda-without-touching-java-and-get-an-easy-to-use-rest-based-orchestration-and-workflow-7bdf25ac198e) step by step can give you some better idea?
I just found out about AppleScript, and I'm in the process of learning. I'd like to create something that'll check my email to see if I have a new email. If yes, I want it to return a value (i.e. "Mail"). If not, then I want it to return a different value (i.e. "No Mail"). My idea is to use the Mail application to achieve this.
Looking at the Dictionary for the Mail application (http://www.mugginsoft.com/html/kosmictask/ASDictionaryDocs/Apple/Mail/OS-X-10.7/Mail-5.2/html/), this doesn't look possible since it doesn't seem like you can check for unread mails in particular.
Yes, this is possible. I used to use it with Geektool to show a list of read messages that I hadn’t dealt with yet.
In your case, it’s even easier, since you don’t want to keep a list of unread messages, but simply exit as soon as any are discovered.
The flag you’re looking for is “read status”.
tell application "Mail"
if exists (messages of inbox whose read status is false) then
"Mail"
else
"No Mail"
end if
end tell
Note that you do have to be looking in a particular mailbox; in this case, I’m looking at inbox. If you are presorting messages to other mailboxes using rules, I’m not aware of any way of doing this using AppleScript without checking each mailbox separately. (Though it might be possible using sqlite directly on Mail’s database file.)
This might also work if you need to look for unread mail in other mailboxes:
tell application "Mail"
if exists (messages of inbox whose read status is false) then
return "Mail"
else
repeat with box in mailboxes
tell box
if exists (messages whose read status is false) then
return "Mail"
end if
end tell
end repeat
end if
return "No Mail"
end tell
However, my anecdotal experience is that if you have a complicated setup, running scripts like this (and including this one) will tend to get Mail’s smart (and dumb) mailboxes out of sync with the read status of the messages within them.