We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Learning to program
Page Index Toggle Pages: 1
Learning to program (Read 489 times)
Learning to program
Sep 16th, 2008, 9:18am
 
Hey i was just wondering if anyone would be able to lead me in the write direction for a program i am starting,I have had a couple attempts but have failed.

I am trying to get processing to open a word program and instantly type text that i have specified into the page/type field.

Any feed back would be great,
Thanks.
Re: Learning to program
Reply #1 - Sep 16th, 2008, 10:01am
 
I fear that's not the main area of competence of Processing (interacting with system/other programs). I suppose you can do that, one way or another, but it will be a stretch.
BTW, you don't even specify which system you target (Win, Mac, Unix?) and what word processor you plan to pilot.
On Windows, I suppose you can ask Java to do Ole/Com (no idea how, though). On Mac, perhaps AppleScript can be used.
[EDIT] The Robot class can be used too, although it is brittle (depending on window size/place, etc.).

If that's a learning exercise, I advice to target more graphical applications... If that's a standalone need, you would do better using some automation language (AutoHotkey or AutoIt on Windows, for example). If you need that in conjunction with a Processing sketch... well, there is some work involved!
Re: Learning to program
Reply #2 - Jan 21st, 2009, 6:01am
 
Under Win32 one application can communicate with another across process boundaries using named pipes. Under .NET, an IpcChannel is used.

This is fine, if you've written the apps yourself as you can hook everything up yourself. Arbitrary 3rd party apps? No.

Or perhaps you could try grabbing the HWND (assuming u know its name) and sending it WM_KEYDOWN messages. For example, here I'm going to close SomeApp by sending it a WM_CLOSE message:

array^ someProcess = Process::GetProcessesByName("SomeApp");

HANDLE hp = OpenProcess(SYNCHRONIZE | PROCESS_TERMINATE,
                       FALSE,
                       someProcess[0]->Id);

HWND hWnd = FindWindow(NULL, L"SomeAppHwnd");
PostMessage(hWnd, WM_CLOSE, 0, 0);
WaitForSingleObject(hp, 5000);
Page Index Toggle Pages: 1