Can Applescripts affect Windows XP via network?

Hi,

I’m very new to applescript (I read a MacWorld article, but that’s about it), but not scripting concepts. The printshop at which I work wants to use applescripts to improve workflow. I wanted to know if it was possible to do the following:

Have an applescript pop up a windows messenger alert on an XP Professional system.

We have an art department which is mac-based (currently Classic, but OSX somemonth soon, I hope). They routinely transfer files to a shared snap server which is also accessible by a PC which controls the printers (just read that over–I hope it made sense). When an art job is transferred, I’d like to pop up an alert for the PC-user (printer operator).

I’m open to any suggestions or thoughts–at the worst, this can’t be done, but I’ll learn something useful anyway.

Thanks,

Adam
Plum Grove Printers

The short answer is “no”. AppleScript has no way to hook into a Windows system and effect it. An alternative might be to have an AppleScript send the operator an e-mail. While I dont’ use AppleScript to send e-mail, I know there are various ways to do it from either pre-OS X or X systems.

Email is a good idea. But I had another thought, have the XP box keep an HTML file open that refreshes every, say 15-30 seconds, or less if you want. Make sure that HTML file is on a shared volume like your Snap server or something. Then, when you want to send the dialog, have Applescript update that HTML document to throw up a javascript alert, (dialog), onLoad in the body so the next time the PC refreshes the HTML the dialog is triggered. This would not be an instantaneous event, but very close to it. I’m thinking have the Applescript reset the page a minute or two after, to give the XP box time to refresh the page and catch the dialog.

I got curious and tried it. It does work but the dialog doesn’t pop up to the user if they are in another app. I have a very crappy PC and am not sure if this dialog will beep on another box, mine does not.

But the code works pretty good, the following script will write HTML to a shared page. Depending on the user’s selection, the script will write a page with either an alert that will pop on load, or do nothing. It is set to refresh every 5 seconds.

--make sure the shared volume that the HTML is located on is mounted...
try
	set aliasCheck to "Snap Server:" as alias
on error
	--try to log in here
end try


--this is the html that contains the onLoad javascript which alerts the user
property htmlAlertOn : "<html>
<head>
	<title>Job Monitor</title>
	<META HTTP-EQUIV="Refresh" CONTENT="5">
</head>
<body bgcolor="#ffffff" leftmargin="15" marginheight="15" marginwidth="15" topmargin="5" onLoad="alert('Check the job folder for new files!')">
</body>
</html>
"
--this is the same blank page but without the javascript alert.  Dress up the Html if you have the time...
property htmlAlertOff : "<html>
<head>
	<title>Job Monitor</title>
	<META HTTP-EQUIV="Refresh" CONTENT="5">
</head>

<body bgcolor="#ffffff" leftmargin="15" marginheight="15" marginwidth="15" topmargin="5">
</body>
</html>
"
property htmlFilePath : "Snap Server:Some Folder:JobMonitor.htm" --path to html file

--you can trigger the alert any way you please, I just chose a dialog box.
set lightSwitch to display dialog "Should I alert the PC" default answer "yes" with icon note
set lightSwitch to the text returned of the result
if lightSwitch = "yes" then --if you want the alert switched on...
	set eof htmlFilePath to 0 --set the end of the file to 0
	write htmlAlertOn to htmlFilePath --write the html with the alert on to the file
else --or if you want the alert off...
	set eof htmlFilePath to 0 --set the end of the file to 0
	write htmlAlertOff to htmlFilePath --write the html with the alert off to the file
end if

Best,

I’m not that experience with JavaScript’s alert functions, but it might work if you have it spawn a new browser window. The main problem I see with this method is that you would need to make sure that the web page is reset to the default (“no file ready”) state after the alert was triggered. I can’t see any non-race condition way of doing this. Wait, I retract that. (Stream of consciousness). What you could do is have webpageX.html, where X is a number. When a file is ready you write the javascript alert in AND a forward to a new page, where X’s value is one higher. So if you had webpage1.html, then you would re-wrtie webpage1.html to contain the alert code and a forward command to redirect to webpage2.html, which would contain normal state code. You’d probably also want to write a cleanup function to either periodically remove the old files or to do it immediately after writing the newest html file.

How about if you script it to send an instant message to the pc user via ichat or aol instant messenger?

-john

Yet another great idea. I don’t have AIM but I’m thinking this might work…

tell application "Internet Explorer"
	OpenURL "aim:goim?screenname=ArtPeeCee&message=Check+Your+Job+Folder!"
end tell