From: APN on 12 Dec 2009 12:20 Here is short sample to start notepad and open the file dialog (myappdir) 67 % set pid [exec notepad.exe &] 1212 (myappdir) 68 % ::twapi::find_windows -pids [list $pid] -text "Untitled - Notepad" -toplevel true 0x140524 (myappdir) 69 % twapi::set_focus 0x140524 ; twapi::send_keys {%FOabc.txt{ENTER}} 22 (basically sending Alt-F O accelerator followed by name of file and ENTER. See documentation of send_keys for key syntax (follows Visual Basic syntax for keystrokes). If you can do the whole thing with keyboard accelerators, you might try something similar. For an example of painting with a mouse see http://wiki.tcl.tk/20231 However, as others have said, DO NOT USE THIS METHOD. Unless the sequence really short and simple, , this way lies madness. You might try Auto-It for something like this. I have not used it extensively but I think it does more under the covers to block other input, verify the correct windows have focus etc. With TWAPI, you have to do that work yourself using lower level commands. /Ashok On Dec 12, 9:30 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > On Dec 12, 3:05 am, oc_forums <oliviercolin...(a)gmail.com> wrote: > > > On 11 déc, 16:09, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > > > > On Dec 11, 9:43 pm, Harald Oehlmann <wortka...(a)yahoo.de> wrote: > > > > > > I am trying to control some CAD package through Tcl. The painful > > > > > thing is that, I have to control the CAD (only) through GUI. > > > Hello, > > > Does it have a COM exposition ? In that case you may have a look at :http://wfr.tcl.tk/1012 > > where there is some examples using tcom extension (Autocad, Catia,...) > > or seehttp://wiki.tcl.tk/13429 > > If so, you may have access to the "tree" directly ? > > > Olivier. > > Unfortunately, some of them have COM, but some don't. A lot of these > packages (FEA, CAE,...) are written by people like me, who just want > to have a usable GUI for the users. COM is just far too complicate for > us. > > I am thinking that, if there is a more systematic way in TWAPI to > invoke the simple actions like Clicking on File > Save as , or > something on the pull-down menu, without having to actually move the > mouse. I have been looking into AutoIt, but then that means I have to > include AutoIt in my application too. > > Any idea how can I do this in a more convenient way ? > > Regards > S-Y. Chen
From: Harald Oehlmann on 15 Dec 2009 11:14 > So, you said there is a special tool which does that. Can you tell > which one it is ? Hi S_Y. Chen, please try the given suggestions. IMHO they are all good and point basicly the same way. To resume on the issue "Read the menu of a foreign application and click on an item": - nobody how replied knows, how to read the captions of menu items of a foreign application. So this way and request stays unanswered. - I supposed, there might be a tool to read from screen output (OCR- Recognition). At least, this is possible to program but very difficult. I don't know of such a program existing. Regards, Harald
From: S-Y. Chen on 16 Dec 2009 12:26
On Dec 16, 12:14 am, Harald Oehlmann <wortka...(a)yahoo.de> wrote: > > So, you said there is a special tool which does that. Can you tell > > which one it is ? > > Hi S_Y. Chen, > > please try the given suggestions. IMHO they are all good and point > basicly the same way. > > To resume on the issue "Read the menu of a foreign application and > click on an item": > - nobody how replied knows, how to read the captions of menu items of > a foreign application. > So this way and request stays unanswered. > - I supposed, there might be a tool to read from screen output (OCR- > Recognition). > At least, this is possible to program but very difficult. > I don't know of such a program existing. > > Regards, > Harald I did some study, and played with WinSpy for a while. I guess I might have used the wrong language. I am still hoping to use TWAPI, because that will save me a lot of time. I should say that I already know the "Caption" on the child windows, belonging to the parent window. So, maybe it is possible (I am not sure) to 1. find the "handle" of that item with the specific caption, under the specific parent window 2. send key strokes, or mouse click to that "handle" From the previous examples, I can see that we can send key strokes to a window with specific handle. Is it not possible to loop through all the available child windows, get the caption, until the specific one is found ? Regards S-Y. Chen |