In our college we all share the iMacs with same user account, say- Anonymous. So when some other user comes and uses my system, he/she generally changes some of the properties in system preferences.
It always wastes some of my precious time when I restore its setting according to mine.
So, I am thinking -
can I make an apple script which when
executed sets setting in system
preferences according to my choices?
Thanks in advance for any help, suggestion or useful link!
Miraaj
Mac OS X Automation has an entire section with example scripts. Depending on the preferences you wish to alter, you will have to go through the System Preferences application or the System Events addition. Some you might still have to use GUI scripting to set.
Related
I am writing desktop programs for windows and when I need to put some program to start automatically I always use one of those options:
1 - Put a shortcut to the program in the startup group
2 - Create a value key on Windows Registry ("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
Which of this options is a best practice?
It depends on how much weight you would apply to the following questions:
As a user, should I be able to deactivate the automatic startup easily, even temporarily?
As a user, should I get the feeling that the developer trusts me to know what I'm doing?
Clarification:
If I have a shortcut in the AutoStart folder, I know that I can quickly disable this part by myself and the developer trusts me to do this.
If I don't have this visual clue, I have to actively look for it using more-or-less arcane tools (speaking from experience here).
If the automatic startup is essential for the correct function of the program, by all means, put it somewhere I can't get to it. But if it's a nice-to-have thing, like a "quickstarter", then please don't.
Since Apple have dropped Spin Control.app—the unresponsive state process monitoring and logging utility—I am in need of a replacement.
I know I can use spindump directly, but I really liked the automated graphical front-end for it.
Can anyone suggest a good replacement?
My needs are: automatically sample my process by name and store the log when the process becomes unresponsive.
I've been desperately looking for a spin control alternative, and I noticed within Intruments there's a tool called "spin monitor". Annoyingly, this isn't shown within the initial template wizard, you have to find it by clicking library in the titlebar first (see screenshot):
I'm not particularly experienced with development in XCode so this answer might not be what you are looking for, but after a while searching and reading up on Spin Control.app I found this article in the Apple Developer documentation.
It appears that there is no single tool that replaces Spin Control.app. Instead, Apple wish for you to now use a combination of Instruments, their unified collection of utilities for debugging and monitoring iOS/OSX apps, and Shark, an advanced tool for sampling/tracing a single application or all running applications.
In particular, you may find this feature of Shark to be useful:
Shark also offers the windowed time facility feature for several of
its sampling options. The windowed time facility tells Shark to record
and process a finite buffer of the most recently acquired samples.
This feature lets Shark record data continuously and for long periods
of time in the background. You can then direct Shark to stop sampling
only after something interesting occurs in your code
A guess
Whilst Spin Control.app is no longer present, the operating system might respect changes to preferences in the com.apple.spincontrol domain.
If that is true, then a change to the value for hangDelay could effectively change the delay before sampling begins:
sh-3.2$ defaults read com.apple.spincontrol
{
hangDelay = 5;
watchOnlyApplication = 0;
}
sh-3.2$ defaults write com.apple.spincontrol hangDelay 10
sh-3.2$ defaults read com.apple.spincontrol
{
hangDelay = 10;
watchOnlyApplication = 0;
}
sh-3.2$
Less likely
For when a single application was watched, I guess that the value for watchOnlyApplication could be either the name or PID of the process (thanks to #Aeyoun for a comment). There's a description of the feature but not the values in a 2006 MacTech article, OS X Investigation and Troubleshooting - Part 2: The Secrets to OS X success.
I doubt that setting watchOnlyApplication to anything other than 0 can have any use on a system that is without Spin Control.app.
You can see all the spin dumps within Console.app under the section Spin Reports
You may use Activity Monitor to manually run spin control:
Klick on the process you'd like to observe
Use Menu View > Sample Process
Use Menu View > Run Spindump
As of macos 12.
If you've developed a remote control application as I've done, you must know that screen capture doesn't capture the UAC dialog when that dialog is pop up, and as a result the control can't be continued.
Anybody know a solution to this?
From what I understand, I believe what you're asking about is possible.
In addition to remote control software, test automation software and accessibility apps for those with disabilities also need a way to interact with protected UI and the secure desktop.
Regarding the issues UAC presents for remote control software, see:
http://www.uvnc.com/vista/
http://groups.google.com/group/microsoft.public.platformsdk.security/browse_thread/thread/acb3a0ccb7682506/d05b0a3026366423
Those links contain info on how the UltraVNC project works around UAC. UltraVNC is open source, so the code might be a good resource as well.
I think the solution to this type of problem probably always involves delegating high-integrity tasks to a service. I don't think there's any other way around it (besides disabling various UAC settings).
And needless to say, writing an app that has an unusually high level of control over the system is a tricky matter - a lot of care must go into the design to make sure it's safe for use without exploitation. :)
See also:
http://www.codeproject.com/KB/vista-security/SubvertingVistaUAC.aspx
http://www.codeproject.com/KB/vista-security/VistaSessions.aspx
http://social.msdn.microsoft.com/Forums/en-US/windowssecurity/thread/4aadadbd-fc3d-4239-ba0f-4d81f17ec938
That is the entire point of the UAC dialog.
So, to answer your question, "No, nobody knows - because it isn't or shouldn't be possible".
I wish to build my own application which can send keyboard commands(messages) to the Windows OS.
For example when I press the combination ctrl+shift+n, I wish to launch the notepad.exe . How can I do that? Do you have some advice for me about the concept used.
I've read that is possible when are used keyboard hooks? That's the only way? Do you know a free and open-source application which does this as simple is possible?
Your particular example can be done without any programming at all, by right clicking on Notepad, selecting Properties, and setting the "hot key" (various Windows versions might call it by a different name) to Ctrl+Shift+N.
If you still would like to write a program to do this, have a look at the RegisterHotKey Win32 API function.
AutoHotkey is a free, open-source utility for Windows.
You can automate many tasks with the above utility, check it out.
Things to bear in mind:
A system-wide keyboard hook requires the writing of a DLL. There's example keyboard hook code on my website here.
Hooks cannot be installed from a low to a high integrity level application in Vista and Windows 7/8/10. So there's no guarantee your hook will work, depending upon what the foreground application is when the key gets hit.
As Greg pointed out, a lot of the time, RegisterHotKey is a much simpler solution for this problem.
Personally I hate auto-created desktop shortcut icons, but some folks seem to think that unless your installer clutters up your desktop, it hasn't worked correctly!
Are there definite guidelines for this (for Windows?)
(Having a "Leave clutter on my desktop?" checkbox in the installer is one option, but to my mind, that's just put MORE clutter into the installer...)
From here: https://learn.microsoft.com/en-us/windows/win32/uxguide/winenv-desktop
If your users are very likely to use your program frequently, provide an option during setup to put a program shortcut on the desktop. Most programs won't be used frequently enough to warrant offering this option.
Present the option unselected by default. Requiring users to select the option is important because once undesired icons are on the desktop, many users are reluctant to remove them. This can lead to unnecessary desktop clutter.
If users select the option, provide only a single program shortcut. If your product consists of multiple programs, provide a shortcut only to the main program.
Put only program shortcuts on the desktop. Don't put the actual program or other types of files.
My take is this: the installer must ask me if I want a desktop icon - to which I can reply yes or no.
Any app that just blindly and without asking installs its icon on my desktop is a bad installation in my opinion.
Ask for permission - if I deem your app important enough to me personally, I might say yes (but most likely I won't). Give your users a choice - don't just assume since it's your app, it's so darn important to everyone that everyone will want to clutter up their desktop with your program icon.
The same goes for the installation directory - unless you have a very good technical reason why you can't install anywhere, allow me to change the program's installation target directory. Not everyone is a big fan of the "c:\program files" folder hierarchy (I'm not, for one - I like to keep my apps in C:\bin for instance).
So in general: any decent installer should ASK the user installing for these things and present sensible defaults - but always give me the option to change the settings to my liking (to my standards).
I don't know of any meaningful guidelines, other than your conscience. As a programmer, I sympathize: I don't want icons on my desktop, either :-) However, having watched non-technical family members struggle with installing software and then trying to run it, I think it's worth noting that
1) There are more non-techies than techies
2) Techies can cope with checkboxes on installers
Based on that, I usually go for having a checkbox on the installer for creating icons, which defaults to on. I don't mind anything other than the "always create icons" approach. (I'm looking at you, Adobe.)
I think that depends on what you see your client doing with the app, the level of the client's expertise with computers and how frequently you see him using it.
If the client is not very well versed with computers he would prefer to have the icon on the desktop where he can access it. If you target market is experienced users you don't need to bother because he can make the icon himself if he wants it.
If the application is for daily frequent use like a web browser the client would want it on his desktop for quick access.
Finally the decision rests on you. If you're being obnoxious you can create 4 icons on the desktop (I've seen apps that do that).
I don't think asking for permission is a bad idea. After all the installation needs to be done only once and it's just one checkbox to tick.
I've no particular love for desktop (or quick launch) shortcut icons either, but I think that you should still give your users the option in the installer to install neither, one or both of these shortcuts.
Depending on how computer literate your users are (if it's possible to determine this) you can default the two options to either enabled or disabled accordingly.