I want to check if the "Security & Privacy" tab is locked or unlocked without doing any modifications to it.
I found a way to do it with AppleScript:
tell application "System Events"
tell process "System Preferences"
if title of button 1 of window 1 is "Click the lock to make changes." then
log "LOCKED"
end if
end tell
end tell
But I get this error:
"System Events got an error: Script Editor is not allowed assistive access." number -1719 from window 1 of process "System Preferences"
I want to be able to execute this code on clients' machines so to add Script Editor to Accessibility is not an option for me.
My question is is there a way (objective-c, c++ or appleScript) to just check if the tab is locked or not?
While you could write your own NSPreferencePane if needed you can also go the official way making the user aware of whats going on by opening the PrefPane you want. So the user can unlock PrefPane them self.
NSURL *url = [NSURL URLWithString:#"x-apple.systempreferences:com.apple.preference.security?Firewall"];
[[NSWorkspace sharedWorkspace] openURL:url];
To obtain access to locations outside of your app, you must request appropriate entitlements.
To change preferences programmatically read
https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFPreferences/CFPreferences.html
Related
I need a context menu entry for each program in the taskbar. Want to add an entry which immediately terminates (UNIX/Linux-like signal SIGKILL) the process. There a lot of questions on this site, how it's done for the explorer or desktop. But is it also possible to add such an option to the context menu of the taskbar?
To clarify the question, according to my comments:
The current problem:
I have a program (not Firefox) which randomly crashes. The program is in fullscreen mode. But if I want to close the window of the program with Exit window, it takes a long time that Windows kill the program. When I try to open the Task Manager the program immediately grabs the user input and I have no chance to interact with the Task Manager. So my solution was to add a context menu item in the taskbar to quit the task of the program. According to a user comment, I test the option "Always on top" in the Task Manager. Didn't know that. But I haven't tried it yet. I'm also interested for further projects, if there is a function in WINAPI or Windows Registry to add an item.
To avoid down-votes:
I'm not interested to hack Windows or the application. Solutions with code injection are taboo for me. Want a clean solution, if even possible. I want improve my Windows version. Adding also some additional information (process information) in the context menu.
Have currently found this (Registering shell extension handlers).
Has anybody used this before? I think it's sound promising.
There is no API to extend this menu like that. Applications can customize the top of the menu with ICustomDestinationList but there is no way to add entries for all applications.
For a personal use project, you could inject a .dll in the taskbar instance of Explorer.exe and add your item after figuring out the address of the function where the menu is created. This address can of course change after you upgrade Windows so it is not a very generic solution. Using the public symbols might help but you still have to expect it to break from time to time when Microsoft changes part of their taskbar code.
You don't need to change code in explorer.exe, because you can close a program by doing the keyboard shortcut: Alt + F4.
ALL,
We have a an application written with wxWidgets (wxGTK) and Qt.It is running on RHEL6 with FVWM window manager.
One of the window we have in that application is "Lock Screen" which is shown in the full-screen mode and does not have any decorations. The only way to get out of it should be to enter the password and press the "Authenticate" button.
However what we discover is that if the user starts up Terminal and then pulls up that "Lock Screen", (s)he can press ALT+TAB, switch to the Terminal and type whatever (s)he wants. We'd like to avoid it.
Is there any way possible to catch the "ALT+TAB" keystroke and do nothing when this "Lock Screen" window is displayed. The window is written with wxWidgets, but I'm asking about c++/Linux/gtk/qt in general.
TIA for any hints/advice community can provide.
[EDIT]
All I want is for the user to not be able to switch focus from the password field until the password is given and the "Authenticate" button is pressed.
[/EDIT]
And before you ask - there are couple of related questions on SO, which says solved, but they are for Windows/C#/WinForms/JAVA. If you can find something that will work on Linux with either GTK or Qt or maybe even FVWM internal settings I will gladly accept the answer.
i need to show notification on tizen.
i've try the below code.
Tizen::Shell::NotificationManager notiMgr;
notiMgr.Construct();
NotificationRequest request;
request.SetAlertText(L"AlertText");
request.SetTitleText(L"TitleText");
request.SetAppMessage(L"AppMessage");
request.SetNotificationStyle(NOTIFICATION_STYLE_NORMAL);
notiMgr.Notify(request);
i will get notification while put this code into tizen notification example.That means this code works any form in the example.However,in my simple button click i can't.There is no error occur while click the button.But nothing happens.
As the logs say: "The application does not have the privilege to call this method."
If you look up NotificationManager::Notify you'll see that it requires the privilege http://tizen.org/privilege/notification.
To request this priviledge for your app, open your manifest.xml file, click on the Privileges tab, click Add..., enter the string http://tizen.org/privilege/notification, click OK and rebuild/deploy your app.
I need to be able to force a "Detect Display" via Keymando. I didn't see any examples on how to execute system commands. Any thoughts on how to do this?
You can do this the same way you do in ruby, with backticks or system().
For example:
map "<Ctrl-u>" do
`osascript -e 'set volume output volume (output volume of (get volume settings) + 7)'`
end
Thanks to Kevin and this article I got this working using this script. Hope this helps someone in the future.
# Detect Displays
map "<Cmd-Ctrl-d>" do
`osascript -e '
tell application "System Preferences" to activate
tell application "System Events"
tell process "System Preferences"
click menu item "Displays" of menu "View" of menu bar 1
tell button "Detect Displays" of window 1 to click
end tell
end tell
tell application "System Preferences" to quit
'`
end
I have rules set to move some email messages into different folders. I would like this to still show the envelope in the notification area but there is no option in the rules wizard to do this. It looks like I would either have to have the rule "run a script" or "perform a custom action" allowing either vba or c/c++ respectively.
Anyone else have a better solution?
You can also achieve it not by using a rule, but doing the rule-like action in code. For example:
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim mai As Object
Dim strEntryId
For Each strEntryId In Split(EntryIDCollection, ",")
Set mai = Application.Session.GetItemFromID(strEntryId)
If mai.Parent = "Inbox" Then
If mai.SenderEmailAddress = "the-email-address-the-rule-applies-to" Then
mai.Move Application.GetNamespace("MAPI").GetFolderFromID("the-entry-ID-of-the-folder-you-want-to-move-the-message-to")
End If
End If
Set mai = Nothing
Next
End Sub
How to get the folder ID (i.e., entryID of the folder):
This is just a manual way, you could make a recursive procedure but for simple purposes this is fine. For instance, I had a structure like:
Mailbox - My_Name_Here
Inbox
The Subfolder I'm Looking For
Sent Items
...
So in the Immediate window I typed:
? Application.GetNamespace("MAPI").Folders(1)
and increased the number until I got "Mailbox - My_Name_Here"
then, I typed:
? Application.GetNamespace("MAPI").Folders(the_number_of_my_mailbox).Folders(1)
increasing the number until I got "Inbox".
Then:
? Application.GetNamespace("MAPI").Folders(the_number_of_my_mailbox).Folders(the_number_of_my_Inbox).Folders(1)
increasing the number until I got "The Subfolder I'm Looking For"
Then:
? Application.GetNamespace("MAPI").Folders(the_number_of_my_mailbox).Folders(the_number_of_my_Inbox).Folders(the_number_of_the_subfolder_i_was_looking_for).EntryID
And that was it: the entryID of the folder I wanted to move the message to. You get the point, I'm sure :)
Check out MailAlert, an Outlook plug-in that does exactly that. It still works in Outlook 2007 (although I've had some instabilities since I installed it again recently, which may or may not be related).
The new version of Mail Alert, which was just released, will allow you to control the notification icon as well as the popup alert and sound alerts. Here are some of the new features in 2.0:
Audible alerts - plays a sound for incoming e-mails
Notification area alerts - displays a notification area (system tray) icon
Program alerts - runs a program and can pass information from the incoming e-mail to that program
Mute feature - to quickly suppress all alerts
Microsoft Outlook 2007 support
Multi-monitor support
Unicode Exchange server support
And more desktop alert features:
Aero Glass style alert windows (on Windows Vista)
Ability to easily dismiss the alert window
Ability to quickly open, reply [to all] or forward a message directly from the alert window's buttons
Ability to convert a message into a task, flag a message for follow up or move a message to another folder; all directly from the alert window's context menu
Ability to set the default position of alerts to be where ever you want them
Privacy option to require a click before showing the preview of the message body
there is an option "display a Desktop Alert" on the Step 1 of the Rules Wizard. it does the trick. this wizard can be run when editing the concrete rule.