I tried to set up Voice Control to restart my mac by running the applescript:
tell application "System Events"
restart
end tell
I set it up for voice control. I'd say "Restart the Mac"
However this put my mac into an infinite restart loop!
Had to trash the script.
Is there a solution to this problem with a different applescript that doesn't go into a loop? It would be great to simply say "Restart the Mac" and then presto it restarts.
I use Voice Control every day, without error, to restart my computer.
These are the steps I took.
Paste this following AppleScript code into a new Script Editor document and save it as "Restart Computer.scpt" (Don't save it to any "Startup Items" Folder)
tell application "System Events" to restart
Make sure you grant access in System Preferences for System Events.app to be allowed to control your computer.
With Voice Control currently active, select the new "Restart Computer.scpt" file in Finder, then speak the command "Make This Speakable".
You Should then see a pop-up window like this...
Just insert the voice command you want to use (I use "Restart Computer") and click Save.
Note: Before doing all of this, you should remove any previous custom commands you have set for restarting the computer, from your Commands list in System Preferences.
As an added bonus, this following AppleScript code will reveal the file which stores all of your custom voice commands, in Finder. It's a good idea to backup this file from time to time. Also copying this file to a different computer will allow you to use the custom commands on that computer.
set customDictationCommands to (path to preferences folder as text) & ¬
"com.apple.speech.recognition.AppleSpeechRecognition.CustomCommands.plist"
tell application "Finder" to reveal alias customDictationCommands
I don't think AppleScript is the best tool for this. In System Preferences→Accessibility→Voice Control you can enable Apple's built-in voice command system, which should work out-of-the-box. They don't have a built-in Restart command so you'll have to create one, but that's easy enough. Click the 'Commands...' button at the bottom right, then click the '+' button at the bottom left, and you can choose any of several ways of implementing it.
With restarting script saved as application the simple restart command will enter into infinite reboot loop. This is because of unsaved state of application.
To solve this problem, use following script application instead:
tell application "System Events" to restart with state saving preference
Related
I have a python script which uses Selenium WebDriver to start a Chrome, open an URL, enter simple captcha, check if some data available (time for visit government organization) and repeat this process in 5 minutes.
I want it work in background. Headless mode is not an option because site would show DDos Guard in that case.
I have tried to use driver.minimize_window() but the windows activates for short periods for number input and click of button which is annoying when I work on PC.
Is it possible to make it work completely in background without activate Chrome window?
You can packaging your script using PyInstaller, then run it with Windows Task Scheduler (assuming you are using Windows)
Install pyinstaller
pip install -U pyinstaller
2. Packaging your script (run in cmd)
pyinstaller --onefile --name=your-package-name yourscript.py
Check pyinstaller docs and make sure add --hidden-import or --collect-data flag if needed.
Setup your task scheduler:
Create basic task, choose task name, and description (if needed)
Create trigger
Set action to start a program then define your script name in Program/script and make sure put your script folder path in Start in
Then voila. You can custom the trigger more detail in task properties (creating multiple triggers, specific conditions, etc...)
You could try to start your exe file as process manually using cmd/powershell like this SO answer, and some kind of process/service manager but I have never tried it yet.
When I use selenium and headless option don't work with me, I always do this trick by changing the window size and just leave it.
So, set the window size in the driver itself, like this:
driver.set_window_size(1, 1)
Or, set it as an argument, like this:
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('window-size=1,1')
Or use both.
I hope this helps you.
I'm using a thrid-party screen capturing application (Screenpresso). It's configured to start screen-capturing when I press PrtSc. And indeed it works except when Intellij has Windows focus. In fact, to screen capture code I have to focus on any other window press PrtSc and then select the area within Intellij.
I've looked through all the settings, and especially the Keymap settings, and I can't see anything else that has been assigned to PrtSc. Of course, I'm not really sure; when I try to find a setting via nothing happens, as pressing PrtSc has no effect.
I know this used to work for me in previous versions of Intellij (though I can't remember what versions). But PrtSc used to work in Intellij just like every other application.
So I guess the question is, why is Intellij eating the PrtSc keypress event? And can I turn it off so that the event gets correctly passed to my dedicated screen capturing application.
Intellij 2019.2.4
Windows 10, 64b
This turned out to be an issue with Screenpresso:
https://www.screenpresso.com/support/hot-keys/
Why shortcut [print screen] key does not always work?
This must be because you run your application with elevated
privileges (with admin rights) (the UAC must have displayed a popup
at startup).
For security reasons, Screenpresso can handle shortcuts
from Windows running with elevated privileges only when it is
installed in Program Files folder.
To fix this, you should install
Screenpresso in Program Files folder which is not the default
behavior:
Uninstall Screenpresso
Run again Screenpresso: Right click Screenpresso.exe and select Run as administrator
Click on the INSTALL on this computer button while holding the Control key or click on the sub-menu Install for all users:
Some users have this problem, first reported 5 years ago: Find here
Crash dumps (java_error_in_*.log in the user's home directory) can help to understand it better.
I have developed a wpf app and want it to run whenever the computer starts up.However I have been unable to do so......I have tried editing registry like this answer...
Launch Window on Windows startup
Interesting thing is the app does autostart when there is internet connection.It doesn't when there is no internet. I do need internet connection at some point of time to sync the data to internet application. However this should not have affected the startup of the application.
Any ideas???
I guess you can set up a timer, and after several minutes, check out your internet, if the internet is ok, then run your application continuely. If not, reset the timer, and check again.
Go to the run line (Windows + R). Type "shell:common startup" press "enter". Place a shortcut in that folder and restart your machine (depending on what the *.exe is doing you may need to set its properties to run as administrator).
I'm trying to make a C program that modifies my host file, but I can't just straight up open the file with the program, because Windows blocks it. Is there any way that I can make the program request administrative privileges within the code, or any script I can use to start the program in admin mode?
Right clicking is a solution that allows you to run any program with Administrator privileges. That includes ticking the box in "Properties".
On Windows 7 and later, you can also rename your program so that its name contains setup (like hosts_setup.exe), and it'll automatically be run in Administrator mode (brings up the UAC prompt) if double-clicked in Explorer. Note this only works from double-clicking in Explorer.
You can also take a look at How can I run a child process that requires elevation and wait? . It calls WinAPI and is a fairly native approach. The best solution is to add it in menifest so your program requests Admin at startup.
Shoot, okay, seconds after posting this question, I found a solution. It turns out that you can right click the executable, click properties, and on the compatibility tab, select "Run this program as administrator". Just in case anyone else needed this information.
I'm not sure if this is technically a Kiosk, but it's basically the same idea. I have a program that runs full screen all the time from boot to shutdown to control a machine that the computer is hooked to.
Right now I just have a shortcut to the exe in the Startup folder so it starts when the system boots up and logs in. Is there any better way to do this? I'd really like the user to never see the Windows environment (just the windows loading progress bar on boot) if at all possible, but I'm guessing that's not possible.
Just thought I'd ask and see if there is a better way to do this than putting it in the startup folder?
The best option is to use Windows Embedded. This gives you much more control over the shell, and what is run and installed with the system.
If you have to do this with a consumer OS, you can try to bypass the login prompts to auto-login your user, and have your program setup in the registry to startup. Disable any other services you don't need. That will minimize the time the shell is displayed (but it's very difficult to remove it).