Sending message via Notification Center with AppleScript - applescript

Using OS X 10.9 Maverick, I am trying to write an AppleScript notification event.
I've successfully sent a title and a subtitle using this code:
set emailFrom to "Johnny Appleseed"
set emailTitle to "The Email Subject"
set emailMessage to "Hello, this is a test"
display notification with title emailFrom subtitle emailTitle
I am trying to display the emailFrom, emailTitle and emailMessage so it's formatted like this:
The AppleScript Notification Center documentation only discusses title and subtitle.
I have tried adding message to the display notification, but it has not worked.
set emailFrom to "Johnny Appleseed"
set emailTitle to "The Email Subject"
set emailMessage to "Hello, this is a test"
display notification with title emailFrom subtitle emailTitle message emailMessage
How can I add the "message" part to the notification?

Try it this way:
display notification "Notification Text" with title "Title" subtitle "SubTitle"
=>
set emailFrom to "Johnny Appleseed"
set emailTitle to "The Email Subject"
set emailMessage to "Hello, this is a test"
display notification emailMessage with title emailFrom subtitle emailTitle

Related

SwiftUI extension to display Image in Alert()

In SwiftUI the standard alert has the following actions:
public struct Alert {
/// Creates an alert with one button.
public init(title: Text, message: Text? = nil, dismissButton: Alert.Button? = nil)
/// Creates an alert with two buttons.
/// The system determines the visual ordering of the buttons.
public init(title: Text, message: Text? = nil, primaryButton: Alert.Button, secondaryButton: Alert.Button)
}
Is there a way to write an extension for this alert that would allow me to add an image between the title, and the message, so I can use it like this:
Alert(title: "Title", image: "image.png", message: "message text", dismissButton: Alert.Button)
Or would I have to create my own AlertController for this?

Push sharp Notification with Title and View Close Buttons

I am using push sharp to create remote notification.
But I get the notification with out a title and a View/Close buttons.
I am using a code adapted from
Here
Here is how I create my alert
AppleNotificationAlert alert = new AppleNotificationAlert();
alert.ActionLocalizedKey = "View Alert";
alert.Body = message;
alert.AddLocalizedArgs(new object[] { "title", "Test Title"});
pushBroker.QueueNotification(new AppleNotification() .ForDeviceToken(deviceToken).WithAlert(alert).WithBadge(1).WithSound("sound.caf").WithCustomItem("level", level).WithContentAvailable(1));
I also tried just specifying the Alert body as follows but it does not show View/Close buttons
pushBroker.QueueNotification(new AppleNotification() .ForDeviceToken(deviceToken).WithAlert("Alert Body").WithBadge(1).WithSound("sound.caf").WithCustomItem("level", level).WithContentAvailable(1));
Your code is right. I just spinned it out and it worked ! In your IOS device settings choose your app and then notifications and then change the notification type from banner to an alert and you will get your custom Buttons and Title!

Why are all my UIAlertView labels/text bold by default in iOS 8

I searched for this and the only solutions seem to be derive from the UIAlertViewDelegate. I don't want to do that just to eliminate bold text.
The code that I use to pop my alert view is the following:
NSString* errPrompt = #"some text here, anything that will not show bold :)";
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title
message:errPrompt
delegate:nil
cancelButtonTitle:[self getUiText:"OK"]
otherButtonTitles:nil];
[alert show];
This is a bug in iOS and affects all alerts which do not have a title set.
Interestingly most standard iOS alerts (like in App Store) are not affected.
This works for me on iOS 8. Just empty string in the title without space inside #"".
[[[UIAlertView alloc] initWithTitle:#""
message:#"My message"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil] show];
This happens when you do not set Alert title. (Weird, I know)
Set Alert's title as. empty if you. do not want to add any title
UIAlertController(title: "", message: "The alert message", preferredStyle: .alert)

How to create Event Handler for MessageBox OK button? (C#)

When the user will click the "OK" button on the MessageBox below, something will happen for example, it will clear out the searchResult string and set it to "". Just to clarify, a message box will open up and show some string message (searchResult), but as soon as the user clicks on "OK" on that message box, searchResult will be set to "". How can I achieve this? How to create an event handler for this particular message box's OK button?
if (searchResult != "")
{
MessageBox.Show(searchResult);
}
There is no need for a listener. Just set searchResult to an empty string right after calling MessageBox.Show:
if (searchResult != "")
{
MessageBox.Show(searchResult);
searchResult = "";
}
You can use this if you are interested :)
http://msdn.microsoft.com/en-AU/library/system.componentmodel.backgroundworker.runworkercompleted.aspx

How do I set WindowText on the Taskbar?

const char* title = "old title";
HWND hwnd = FindWindow(title, title);
SetWindowText(hwnd, "new title");
This sets the title bar to "new title", but the caption in the task bar is still "old title". How do I set both?
If relevant, this is being done in a DLL loaded in the process which owns the window.
This should set both, window title and task bar item. Your call
HWND hwnd = FindWindow(title, title);
does not look good, first parameter has to be class name (look at FindWindow). It looks to me that problem is somewhere else but I may be wrong.

Resources