macOS: Open application automatically when printing - macos

I need to open an application every time I print something to confirm my ID and I would like to automate that.
Is it possible to run a script when a new print job is created that opens a specific application?

Related

Need event when specific program is launched in order to attach process

I have a specific program that I want to run a script when its launched.
I have looked into batch scripts and what not but the problem is the associated program might not be launched through that specific batch script but opened through a saved project.
I would like to create an event whenever this specific program starts up that i can use to attach a script start when it does.
The issue is that when I start the program I can't find any corresponding event.
Perhaps I'm not looking for the correct thing.
If there is an event logged on startup of your application you can use the windows task scheduler -> Action - > Create Task -> Trigger and select Begin the task on event and find the event logged on startup.

How to let osascript not build applescript code which will not hit at runtime?

We have a script to send email using Microsoft outlook or Apple mail application. It will dynamically load the default email from system preference (maybe user input also), and using it to decide which mail client to use.
So the code is as following:
if (mailClientStr contains "outlook")
tell application id "com.microsoft.outlook"
-- <<< there will be error if there is no outlook installed
-- <<< even else branch will be run.
...
end tell
else
tell application id "com.apple.mail"
...
end tell
end if
On an machine which doesn't have outlook installed, and the mailClientStr will be "com.apple.mail", but this script cannot be run by osascript
It complains Can’t get application id "com.microsoft.outlook" even the first branch will not be executed. My understanding is osascript will need to access Outlook apple script interface when load and compile this script (before run it).
I can separate the outlook related code into a separate script, but because there is a lot of data to passing, it will be complex, so I don't want this workaround.
So does there any solution from the apple script language side?
From the AppleScript Language Guide:
Entering Script Information in Raw Format
You can enter double angle brackets, or chevrons («»), directly into a script by typing Option-Backslash and Shift-Option-Backslash. You might want to do this if you’re working on a script that needs to use terminology that isn’t available on your current machine—for example, if you’re working at home and don’t have the latest dictionary for a scriptable application you are developing, but you know the codes for a supported term.
You can also use AppleScript to display the underlying codes for a script, using the following steps:
Create a script using standard terms compiled against an available application or scripting addition.
Save the script as text and quit Script Editor.
Remove the application or scripting addition from the computer.
Open the script again and compile it.
When AppleScript asks you to locate the application or scripting addition, cancel the dialog.
Script Editor can compile the script, but displays chevron format for any terms that rely on a missing dictionary

How to display the main window of a process in another Windows session?

When running a Scheduled Task under Windows to launched batch processes under a dedicated account, you could want to see output of theses processes.
These sub-processes could be either or both graphical or character based applications
As there are running in a different Windows Logon session, I cannot find way to display their output. There are like ghost processes
I would expect being able to use the show Window command from Process Explorer, but even via running Process Explorer under the dedicated account used to run the task (via runas), it is not working
Is there a way to do it ?
References : http://www.brianbondy.com/blog/id/100/
I believe that once created, a window cannot be transferred to another window station. Also, I doubt it is possible to open windows in another session. For character-based applications you are better off writing the output to some file and examining that file. For graphical applications you are out of luck with task scheduler. You may want to write a simple VBS script that wakes up at a certain time and runs your graphical task(s) and run it upon user logon, e.g. along the lines of a script from this page:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/d9465815-87e2-43df-a0fe-4a23c16dca99/need-a-time-schedule-in-vbs-script-to-execute-something

How to create osx service that passes its service name to shell script?

I am creating osx service with automator to show context menu items for a file like how dropbox shows the menu below.
I understand that these are not osx services but however i would to like accomplish the same thing with osx services. Hence i have created 2 osx services using automator for files and folders in Finder.app and attached a shell script action to this.
Now i could see all of my 2 services (Share with a, Share with b) in the contextual menu like below
From the shell script(actions for those services) am launching an app. I wanted to launch the app with the file path and service name as two command line args.
Any idea how to get service name of user selected service inside shell script like we get file name from the command line parameter "$#"
"Basically my aim is to open a browser with an URL which is different for each of the menu item."
Something like the following AppleScript can be used to open a URL in the default web browser, using AppleScript:
tell application "Finder" to open location "http://learnbymac.com"
Something like the following shell script can be used to open a URL from the shell:
open -a "Finder" "http://learnbymac.com"
Using the Finder to open URLs is better than using Safari because when you use the Finder to open URLs, you get the default browser rather than always getting Safari.
" i will launch an app / exe from the shell script by passing path to the file & service name so that the app can construct url based on the service name by reading the file details from the data base and loads the url in the browser."
You may have to provide the name of your service in your workflow's "Run Shell Script" action when you launch your app. This might be best anyways because then if the user changed the name of the Service, your software would still run. I know that it would be ideal to not duplicate the name of the Service having it once in the workflow's bundle and again in your "Run Shell Script" action, but I don't know how to get the name of the currently running Service.
-- Kaydell
kaydell#yahoo.com

Microstation launching into a blank window (no menus or anything)

We have a VB6 application here that automates the process of opening drawings and printing them with a specific printer that turns them into TIFF files.
I'm in the process of testing the application as we upgrade from V8 to V8i and I'm running into some problems just launching the application.
If I open the Microstation normally via the exe file everything works ok. But when I do:
Set msApp = CreateObject("MicrostationDGN.Application")
It opens a blank microstation window with no menus or anything (basically what the window looks like behind the file open dialog)
And then I do
msApp.OpenDesignFile ("dummy.dgn")
that looks like this: imgur.com/A5rc4.png
Is there something new with v8i where it doesn't bother loading the gui when opened as an object?
Did your application depends on some user preference of Microstation? I think you can debug your aplication step by step.
You can call the ustation.exe with the parameter -debug. This creates a file called debug.txt in the current working directory.
There you might find some helpful info.

Resources