How to execute system commands in keymando - keymando

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

Related

Is there a way to check if "System Preferences" is locked?

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

Safari 13.1.1 history, website data and cache cleaning with a single script

Hello dear Stackoverflow community,
I am looking in vain for an applescript with which I can delete the history, the website data, the cookies and the cache in my Safari browser 13.1.1. Unfortunately I only find scripts for older browser versions.
So far I've been experimenting with the following script only for the website data, but it may not work:
tell application "System Events" to tell process "Safari"
keystroke "," using command down
delay 1
click button "Privacy" of toolbar 1 of window 1
click button "Manage Website Data…" of group 1 of group 1 of window "Privacy"
delay 3
click button "Remove All"
click button "Done"
end tell
Since I am using the German Safari version, I have replaced the following terms:
"Privacy" → "Datenschutz"
"Manage Website Data…" → "Websitedaten verwalten ..."
"Remove All" → "Alle entfernen"
"Done" → "Fertig"
So my script looks like this:
tell application "System Events" to tell process "Safari"
keystroke "," using command down
delay 1
click button "Datenschutz" of toolbar 1 of window 1
click button "Websitedaten verwalten …" of group 1 of group 1 of window "Datenschutz"
delay 3
click button "Alle entfernen"
click button "Fertig"
end tell
Unfortunately it does not work even then and I assume that this script does not fit for Safari 13.1.1.
Can someone help me here?
However, I have to confess that I am not very well versed in programming.
Kind regards and thank you ever
Andy

How to make SAS to open with maximized window?

How to make SAS to open with the main window and the editor window automatically maximized?
One way to do this is to push the command AWSMAXIMIZE at startup. You could place this statement in your autoexec.sas
dm "awsmaximize";
I was also able to do this by editing the start menu entry and adding to the end of the SAS command: -initstmt "dm 'awsmaximize';"
More here: http://support.sas.com/documentation/cdl/en/hostwin/63285/HTML/default/viewer.htm#a000115355.htm#win-af-wincmds
Not sure if you can do this automatically at startup, but you can set a hotkey to do it.
Tools -> Options -> Keys
Choose a key and type this into the command:
AWSMAXIMIZE ON; WPGM; ZOOM
"AWSMAXIMIZE ON" is the SAS for Windows command to maximize itself.
"WPGM" is the command to bring focus to the Enhanced Program Manager
"ZOOM" is the command to maximize the in-focus window.

Dismissing Modal from Script / osx 10.7+ / safari / automator / objective-c

I am trying to give focus to a safari browser modal box and control its input and dismissal.
Example: Navigate to a website, it throws a modal box, is it possible to create an automator workflow or script that will be able to give the modal focus and interact with its content?
TIA,
BK
Try using System Events:
tell application "System Events" to tell process "Safari"
click button "OK" of window 1
end tell
tell application "System Events" to tell process "Safari"
set value of text field 1 of window 1 to "aa"
click button "OK" of window 1
end tell

CPP:How to pause resume a running script in cmd line console using mouse?

I am in desperate need of help.... :). I am running a script from cmd line console. It does a sequence of operations. whats the best way to pause the script in between to check the results and resume it back using mouse????? or any key
I would appreciate for your reply back,
-Abishek
If I understand your question correctly, and if your program is writing to the standard output (the console window) and you are running on Windows:
You can turn on 'quick edit' in the console window by editing the cmd.exe window properties.
Open a command prompt (start | run | cmd.exe)
Click the upper left corner of the window and choose 'Defaults'.
Click the Options tab and then in Edit Options section make sure the QuickEdit Mode box is checked.
Click OK and you should be set.
If you click with the mouse inside the console window when quick edit is enabled, it will block the program from continuing while it is waiting to be able to write the next message to the output. If you then hit 'esc', the program will continue.
It's a useful shortcut for pausing a running console program that I use all of the time.
try cin.get()
There isn't any easy way to do that. You'd need to create a wrapper to run the program (for example, a debugger is a wrapper to a program), and this wrapper would have to have mouse functions programmed into it.
Without use of the mouse, use cin.get();. It will take an input from the keyboard before continuing.
I'm not sure about using the mouse to pause, but you can pause the execution of command line process by pressing the Pause / Break key or Ctrl + NumLock .
You can then resume the execution with Ctrl + Z