Prev: Tcl/TK is indeed dying
Next: How to get Tk to map and XputImage a (proper) image file upon window event?
From: S-Y. Chen on 13 Dec 2009 11:08 On Dec 13, 1:20 am, APN <palm...(a)yahoo.com> wrote: > 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 seehttp://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 > Ashok Well this helps a lot. I will begin from there. Thanks a lot !! By the way, is there a way to locate the position of a specific text (string) on the menu in a window (for example, those File, Edit, Draw........etc on the menu bar), and then move the mouse there ? The reason I have to do this, is, well, you may not believe it, but many of these packages do not even have a short cut key....... Thanks again Regards S-Y. Chen
From: APN on 13 Dec 2009 11:25 On Dec 13, 9:08 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > On Dec 13, 1:20 am, APN <palm...(a)yahoo.com> wrote: > > > > > 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 seehttp://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 > > Ashok > > Well this helps a lot. I will begin from there. Thanks a lot !! > > By the way, is there a way to locate the position of a specific text > (string) on the menu in a window (for example, those File, Edit, > Draw........etc on the menu bar), and then move the mouse there ? > > The reason I have to do this, is, well, you may not believe it, but > many of these packages do not even have a short cut key....... > > Thanks again > > Regards > S-Y. Chen Moving the mouse is easy, use move_mouse :-) but finding the individual text string, not sure how you would do that other than trying it out (and then hope no one changes system font sizes!) /Ashok
From: S-Y. Chen on 13 Dec 2009 12:00 On Dec 14, 12:25 am, APN <palm...(a)yahoo.com> wrote: > On Dec 13, 9:08 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > > > > > On Dec 13, 1:20 am, APN <palm...(a)yahoo.com> wrote: > > > > 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 seehttp://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 > > > Ashok > > > Well this helps a lot. I will begin from there. Thanks a lot !! > > > By the way, is there a way to locate the position of a specific text > > (string) on the menu in a window (for example, those File, Edit, > > Draw........etc on the menu bar), and then move the mouse there ? > > > The reason I have to do this, is, well, you may not believe it, but > > many of these packages do not even have a short cut key....... > > > Thanks again > > > Regards > > S-Y. Chen > > Moving the mouse is easy, use move_mouse :-) but finding the > individual text string, not sure how you would do that other than > trying it out (and then hope no one changes system font sizes!) > > /Ashok Well, I am just thinking that if those captions on the menu (like "File", "Edit", etc.) can be "searched" and "located" or "found" as a string through TWAPI, maybe it will be easier for me to locate the menu position in a more general case. (maybe not ?). If it can be "searched" and "located" as a string, there is nothing to do with the font size right ? I am just afraid that, the position of the menu may change from machine to machine, and I just need to do it in a machine independent fashion. Anyway, is it possible to do that ? Regards S-Y. Chen
From: S-Y. Chen on 13 Dec 2009 12:01 On Dec 14, 12:25 am, APN <palm...(a)yahoo.com> wrote: > On Dec 13, 9:08 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > > > > > On Dec 13, 1:20 am, APN <palm...(a)yahoo.com> wrote: > > > > 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 seehttp://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 > > > Ashok > > > Well this helps a lot. I will begin from there. Thanks a lot !! > > > By the way, is there a way to locate the position of a specific text > > (string) on the menu in a window (for example, those File, Edit, > > Draw........etc on the menu bar), and then move the mouse there ? > > > The reason I have to do this, is, well, you may not believe it, but > > many of these packages do not even have a short cut key....... > > > Thanks again > > > Regards > > S-Y. Chen > > Moving the mouse is easy, use move_mouse :-) but finding the > individual text string, not sure how you would do that other than > trying it out (and then hope no one changes system font sizes!) > > /Ashok Well, I am just thinking that if those captions on the menu (like "File", "Edit", etc.) can be "searched" and "located" or "found" as a string through TWAPI, maybe it will be easier for me to locate the menu position in a more general case. (maybe not ?). If it can be "searched" and "located" as a string, there is nothing to do with the font size right ? I am just afraid that, the position of the menu may change from machine to machine, and I just need to do it in a machine independent fashion. Anyway, is it possible to do that ? Regards S-Y. Chen
From: APN on 13 Dec 2009 12:06 On Dec 13, 10:01 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > On Dec 14, 12:25 am, APN <palm...(a)yahoo.com> wrote: > > > > > On Dec 13, 9:08 pm, "S-Y. Chen" <shenyeh_c...(a)hotmail.com> wrote: > > > > On Dec 13, 1:20 am, APN <palm...(a)yahoo.com> wrote: > > > > > 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 seehttp://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 > > > > Ashok > > > > Well this helps a lot. I will begin from there. Thanks a lot !! > > > > By the way, is there a way to locate the position of a specific text > > > (string) on the menu in a window (for example, those File, Edit, > > > Draw........etc on the menu bar), and then move the mouse there ? > > > > The reason I have to do this, is, well, you may not believe it, but > > > many of these packages do not even have a short cut key....... > > > > Thanks again > > > > Regards > > > S-Y. Chen > > > Moving the mouse is easy, use move_mouse :-) but finding the > > individual text string, not sure how you would do that other than > > trying it out (and then hope no one changes system font sizes!) > > > /Ashok > > Well, I am just thinking that if those captions on the menu (like > "File", "Edit", etc.) can be "searched" and "located" or "found" as a > string through TWAPI, maybe it will be easier for me to locate the > menu position in a more general case. (maybe not ?). If it can be > "searched" and "located" as a string, there is nothing to do with the > font size right ? > > I am just afraid that, the position of the menu may change from > machine to machine, and I just need to do it in a machine independent > fashion. > > Anyway, is it possible to do that ? > > Regards > S-Y. Chen I understood what you were looking for, I just don't know how you would locate the string at a menu position. /Ashok
|
Next
|
Last
Pages: 1 2 Prev: Tcl/TK is indeed dying Next: How to get Tk to map and XputImage a (proper) image file upon window event? |