how to get "minitest" Notification Center alerts on macOS Catalina? - minitest

How can I get a "Macos Notification Center" alert when minitests pass or fail?
I'm on macOS Catalina.

A crude but obvious way on a Mac is to pass thru AppleScript:
s = 'display notification \"Your toast is ready.\" with title \"Done\"'
`osascript -e "#{s}"`

Related

Running 'System Events' from Excel For Mac Via VBA Results in Invalid Procedure 5 Error

I am trying to run a very simple apple script from VBA. The VBA code is:
NavigationJunk = AppleScriptTask("Budget Report Apple Scripts/NavigationMoveWindowsAppleScript.scpt", "NavigationMoveWindowLeftHandler", "")
The script reads:
on NavigationMoveWindowLeftHandler(Junk)
tell application "System Events" to key code 123 using {option down, control down}
end NavigationMoveWindowLeftHandler
where the complete path for the .scpt is: "/Users/Andrew/Library/Application Scripts/com.microsoft.Excel/Budget Report Apple Scripts/NavigationMoveWindowsAppleScript.scpt" (this is the correct path as documented here: Apple Script Task Throwing an Error 5
This code simply performs the key stroke cntrl+option+left arrow. That key stroke is a shortcut for the app Magnet to move the window to be half screen left.
This worked prior to updating my system to MacOS Ventura. I attempted to restart, uninstall Excel, reset the permissions in System Settings/Privacy/Automation (as documented here: Reset MacOS Privacy Settings) and reinstall Excel. When I tried to run the VBA code I was prompted to grant permission to system events and still received an invalid procedure error. I verified that when I call the handler from within the Apple Script Editor the system performs the keystrokes with no issues. I assume this is some sort of permission thing...How do I fix this?
Of note: this code called prior to the AppleScriptTask above runs just fine:
AppleScriptResult = Split(AppleScriptTask("Budget Report Apple Scripts/NavigationMoveWindowsAppleScript.scpt", "NavigationGetScreenResolution", ""), " ")
This is curious because the .scpt is the same file and calls a different handler:
on NavigationGetScreenResolution(Junk)
return do shell script "system_profiler SPDisplaysDataType | grep Resolution"
end NavigationGetScreenResolution
and runs just fine. Any help here would be greatly appreciated

pywhatkit.sendwhatmsg_to_group function is not working

It might sound crazy but yesterday the function pywhatkit.sendwhatmsg_to_group worked fine with me but today I do not seem to make it work. The message was sent using the group id.
pywhatkit.sendwhatmsg_to_group('Groupid','Testing message',11,51)
But it just worked once. Now the window opens and the particular group also gets selected but the message doesn't get typed not sent.
Has this function worked for anyone?
I am using it on windows machine and python3.
I am using:
OS: macOs Big Sur 11.4
Browser:O Google Chrome 91.0.4472.114
IDE: PyCharm CE 2021.1.3
Pywhatkit: 5.0
I changed a line of code of the sendwhatmsg_to_group function to work in my environment.
I replaced the code (line 166):
pg.click(width / 2, height - height / 10)
with this:
pg.click(width / 2, height / 2)
And then it worked.
PS: The previous code was opening an application from my program bar.
Try this. It worked for me on Python 3.9.12 jupyter notebook
pwt.sendwhatmsg_to_group_instantly('Groupid','Testing message')

A visible window cannot be recognized in pywinauto

While writing scripts, I am attempting to look at some items in the Device Manager. The only issue is that pywinauto cannot see the device manager. Below is what I get when looking for "Device Manager":
Could not find 'Device Manager' in 'dict_keys(['', 'Pane', 'Taskbar', 'Pane0', 'Pane1', 'Pane2', 'TaskbarPane',
'Pane3', 'NetBannerPane', 'Pane4', 'NetBanner', 'ListBox', 'Program ManagerPane', 'Program Manager', 'Pane5'])'
I have attempted to print_control_identifiers() for all of the items listed here however, none of them are the device manager. Looking within Inspect.exe, I can clearly see that there is a window with the title of "Device Manager".
I've even tried to access it via:
dlg=Desktop(background='uia')
dlg.window(class_name="MMCMainFrame").print_control_identifiers()
However, it also provides an error stating that it's an invalid name for the element and it cannot be found. Has anyone else ever attempted to use pywinauto to look at the Device Manager? Or had an issue being unable to find an element
try using this code:
dlg = Desktop(background="uia")
dlg.window(title="Device Manager").print_control_identifiers()
Use title or title_re instead of class_name. dlg.window(title="Device Manger") returns device manager window handler if window is opened already.
Heres find window documentation

Cannot export Sketch file to Zeplin. Forbidden 403 Error

I am new to both Sketch and Zeplin.
When I am exporting my artboard by pressing cmd + E everything seems to be fine.
Zeplin prompts me to select a project. When I select a project to export into, I get a notification saying "Exported 1 screen(s) to ProjectName".
However a short time later it gives me a error dialog and I cannot see any screen in my Zeplin project.
Here is the error dialog:
Note: My sketch app is in its trial period. But it's functioning well, besides this problem.
Thanks to #zeplin_io's fast support on Twitter I solved my problem.
Adjusting my Mac's Date & Time Pref.s to Auto solved issue.

"Silent" Printing in a Web Application

I'm working on a web application that needs to prints silently -- that is without user involvement. What's the best way to accomplish this? It doesn't like it can be done with strictly with Javascript, nor Flash and/or AIR. The closest I've seen involves a Java applet.
I can understand why it would a Bad Idea for just any website to be able to do this. This specific instance is for an internal application, and it's perfectly acceptable if the user needs to add the URL to a trusted site list, install an addon, etc.
Here’s what you need to do to enable Firefox immediately print without showing the print preferences dialog box.
Type about:config at Firefox’s location bar and hit Enter.
Right click at anywhere on the page and select New > Boolean
Enter the preference name as print.always_print_silent and click OK.
I found that somewhere and it helped me
As #Axel wrote, Firefox has the print.always_print_silent option.
For Chrome, use the --kiosk-printing option to skip the Print Preview dialog:
Edit the shortcut you use to start Chrome and add "--kiosk-printing" then restart Chrome.
Note: If it doesn't work it is most likely because you did not completely stop Chrome, logging out and back in will surely do the trick.
Here are two code samples you can try:
1:
<script>
function Print() {
alert ("THUD.. another tree bites the dust!")
if (document.layers)
{
window.print();
}
else if (document.all)
{
WebBrowser1.ExecWB(6, 1);
//use 6, 1 to prompt the print dialog or 6, 6 to omit it
//some websites also indicate that 6,2 should be used to omit the box
WebBrowser1.outerHTML = "";
}
}
</script>
<object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
2:
if (navigator.appName == "Microsoft Internet Explorer")
{
var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = "";
}
else {
window.print();
}
You may need to add the site/page you are testing on to you local intranet zone.
We struggled with a similar problem. We needed to print checks to a check printer, labels to a label printer, and customer invoices to an invoice printer for retail store embrasse-moi. We have dummy computers, nooks, ipads, iphones with no printing capabilities. The printing an invoice feature was basically a silent print. A pdf was written to the server, and a shell script was used locally to retrieve it and print.
We used the following for a perfect solution with minimal libraries:
use TCPDF in PHP to create PDF. Store the PDF on the server. Put it in a 'Print Queue' Folder. Kudos for TCPDF, a bit difficult to learn, but SICK SICK SICK. Note we are printing 80 labels per page using avery 5167 with a bar code with perfect accuracy. We have a labels, check, and invoice print queue. Different folders basically for different printers.
Use the included shell script to connect to the server via FTP, download the PDF, delete the PDF off the server, send the PDF to the printer, and again, delete the PDF.
Using a local computer attached to the printer, run the script in terminal. obviously modify your printers and paths.
Because you always want this running, and because you use a MAC, create an 'app' using automator. Start automator, put the script in a 'run shell script' and save. Then stick that app in a login item. See the script below the shell script if you want to see the 'output' window on the MAC.
BAM - works sick.
Here is the shell script
#!/bin/bash
# Get a remote directory Folder
# List the contents every second
# Copy the files to a local folder
# delete the file from server
# send the file to a printer
# delete the file
# compliments of embrasse-moi.com
clear # clear terminal window
echo "##########################################"
echo "Embrasse-Moi's Remote Print Queue Script"
echo "##########################################"
#Local Print Queue Directory
COPY_TO_DIRECTORY=/volumes/DATA/test/
echo "Local Directory: $COPY_TO_DIRECTORY"
#Priter
PRINTER='Brother_MFC_7820N'
echo "Printer Name: $PRINTER"
#FTP Info
USER="user"
PASS="pass"
HOST="ftp.yourserver.com"
#remote path
COPY_REMOTE_DIRECTORY_FILES=/path
echo "Remote Print Queue Directory: $HOST$COPY_REMOTE_DIRECTORY_FILES"
echo 'Entering Repeating Loop'
while true; do
#make the copy to directory if not exist
echo "Making Directory If it Does Not Exist"
mkdir -p $COPY_TO_DIRECTORY
cd $COPY_TO_DIRECTORY
######################### WGET ATTEMPTS ############################################
#NOTE wget will need to be installed
echo "NOT Using wget to retrieve remote files..."
# wget --tries=45 -o log --ftp-user=$USER --ftp-password=$PASS ftp://ftp.yourserver.com$COPY_REMOTE_DIRECTORY_FILES/*.pdf
######################### FTP ATTEMPTS ############################################
echo "NOT Using ftp to retrieve and delete remote files..."
#This seems to fail at mget, plus not sure how to delete file or loop through files
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASS
cd $COPY_REMOTE_DIRECTORY_FILES
ls
prompt
mget *
mdel *
END_SCRIPT
echo "Examining Files in $COPY_TO_DIRECTORY"
for f in $COPY_TO_DIRECTORY/*.pdf
do
# take action on each file. $f store current file name
#print
echo "Printing File: $f To: $PRINTER"
lpr -P $PRINTER $f
# This will remove the file.....
echo "Deleting File: $f"
rm "$f"
done
echo "Script Complete... now repeat until killed..."
sleep 5
done
and the automator script if you want to see output, keep the app with the script
choose a run apple script option:
on run {input, parameters}
tell application "Finder" to get folder of (path to me) as Unicode text
set workingDir to POSIX path of result
tell application "Terminal"
do script "sh " & "'" & workingDir & "script1.sh" & "'"
end tell
return input
end run
I know this is an older thread, but it's still the top Google search for 'silent printing' so I'll add my findings for the benefit of anyone coming across this now.
We had a similar issue with printing labels of various types to various printers for a stocksystem. It took some trial and error, but we got around it by having the system create a pdf of the labels, with printer name and page qty's encoded in the pdf. All you then have to do is:
IN IE, go to Internet Options >> Security >> Trusted Sites >> Sites
Clear 'Require server verification (https:) for all sites in this zone'
add "http://[yoururl]"
and the pdf will print out automatically.
When we originally set this up we were using Chrome as the default browser, but in September 2015, Chrome dropped the ability to run NPAPI plugins. This meant that you could no longer select the Adobe pdf plugin as the default pdf handler, and the built in pdf plugin does not handle silent printing :-(
It does still work in Internet Explorer (IE11 at time of writing) but I've not tried any other browsers.
HTH
Cheers,
Nige
I wrote a python tsr that polled the server every so often (it pulled its polling frequency from the server) and would print out to label printer. Was relatively nice.
Once written in python, I used py2exe on it, then inno setup compiler, then put on intranet and had user install it.
It was not great, but it worked. Users would launch it in the morning, and the program would receive the kill switch from the server at night.
I have it working all day long using a simple JSP page and the Java PDF Renderer library (https://pdf-renderer.dev.java.net). This works because Java prints using the OS and not the browser. Supposedly "silent printing" is considered a browser vulnerability/exploit and was patched after IE 6 so good luck getting it to work via Javascript or Active X. Maybe its possible but I couldn't get it to work without Java.
I have to be honest, I am kinda thinking out loud here.. But could it not be done with an applet or some sort (be it Java or whatever) that is given trusted permissions (such as that within the Intranet zone) or something?
May be worth investigating what permissions can be given to each zone?
Following a Google, I think you definately have a challenge, so far most of the articles I have seen involve printing to printers connected to the server.
If its internal, would it be possible to route printing from the server to department/user printers or something?
If it is just an internal application, then you can avoid printing from the browser, and send a printout directly from the server to the nearest printer to the user.
I'm on the same issue here, this is what i learn so far.
A.: You need to setup an IPP PrintServer
You have multiple print server implementations you may try.
Hardware IPP print server: like DLINK DPR-1020 or similar, some printer have this functionality builtin.
Linux server with CUPPS : http://www.howtoforge.com/ipp_based_print_server_cups
XP-Pro server with ISS: http://www.michaelphipps.com/ipp-print-server-windows-xp-solution
B.: You need to make your WebApp a client of this IPP Server so you pick-process-send every user's print request to the PrintServer.
PHP::PRINT::IPP is a php lib you may try (it's well tested on cups servers).
You should have a look at PrintNode. They provide a silent remote printing services for web applications. You install a piece of software on the desktop which syncs to their servers. You can then send printjobs using an json request and they are instantly printed out.

Resources