| View previous topic :: View next topic |
| Author |
Message |
SAbboushi
Joined: 18 Sep 2004 Posts: 60
|
Posted: Sat Feb 19, 2005 4:31 pm Post subject: Right click and copy to clipboard |
|
|
Hi-
I have an application (MetaStock) that runs a report and displays a list of results in rows. The rows can be highlighted. I do an ALT/A to select all rows. Then I right-click in the highlighted rows to get a shortcut menu where I can select "Copy to clipboard". It is the right click and "Copy to clipboard" I am trying to automate with AHK. Sadly, neither CTRL/C nor CTRL/Insert will copy the rows to the clipboard.
The details on the list are:
Windows Spy:
ClassNN: SysListView321
Text: List4
(Class Name: SysListView32 in WinSpector - not sure why the class name differs from Window Spy??)
I went through Rajat's post message tutorial - cool stuff. Using Winspector, was able to see the number of rows selected (LVM_SELECTEDCOUNT: Count: 3) but was unable to see how I can automate the 'copy to clipboard'.
I was able to use MouseClick with coordinates to do what I want, but I am concerned something about the window will change and the automation will break.
Anybody have any ideas on how I can automate the copy to clipboard without using coordinates? Thanks |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Sat Feb 19, 2005 5:58 pm Post subject: |
|
|
| Quote: | ControlGetText, OutputVar, SysListView321, MetaStock Window Title
clipboard := OutputVar |
The reason the classname of the control is different is that Window Spy reports the ClassNN rather than just the Class; that is, instead of SysListView32 (Name), it reports SysListView321 (Name + Instance Number (1)).
Also, the above code might not work, since it was made for edit controls and their like. |
|
| Back to top |
|
 |
SAbboushi
Joined: 18 Sep 2004 Posts: 60
|
Posted: Sat Feb 19, 2005 6:31 pm Post subject: |
|
|
Thanks Jonny-
Regarding the code, I am looking for any method that will allow me to right click somewhere in the highlighted rows without using coordinates - or to launch the shortcut menu that right clicking causes to display. It does not have to be via postmessage  |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Sat Feb 19, 2005 6:49 pm Post subject: |
|
|
Dunno.  |
|
| Back to top |
|
 |
SAbboushi
Joined: 18 Sep 2004 Posts: 60
|
Posted: Sat Feb 19, 2005 10:24 pm Post subject: |
|
|
Does anyone else have any thoughts on this?  |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2421
|
Posted: Sat Feb 19, 2005 10:29 pm Post subject: |
|
|
| Could you provide a link to download the application (or a trial version)? |
|
| Back to top |
|
 |
SAbboushi
Joined: 18 Sep 2004 Posts: 60
|
Posted: Sat Feb 19, 2005 10:39 pm Post subject: |
|
|
Only available on CD...
I guess my generic question would be: how can I execute a right mouse click anywhere within the window defined by ClassNN: SysListView321
Text: List4 without having to provide coordinates? |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1270
|
Posted: Sat Feb 19, 2005 10:49 pm Post subject: |
|
|
Have you tried sending the tab key? That sometimes works to get mouse focus on a SysListView32 control and items within it. I had similar issues when writing the open/save dialog script. _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
SAbboushi
Joined: 18 Sep 2004 Posts: 60
|
Posted: Sun Feb 20, 2005 12:19 am Post subject: |
|
|
johhny-
Sorry - I missed the code you posted earlier and thought you were referring to 'postmessage' as the code that might not work.
I just tried
| Code: | ControlGetText, OutputVar, SysListView321,Enhanced System Tester
clipboard := OutputVar
MsgBox, %OutputVar%
|
OutputVar was "List4" - which is the Text parameter that Windows Spy displays... which is not the contents of the highlighted rows...
Serenity - I'm not following you - I did press tab to see what happens - the focus moves away from the highlighted rows I want to copy to clipboard. The mouse pointer does not move. Am not sure I see what you are getting at and how this might help me send a right click to SysListView321... |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1270
|
Posted: Sun Feb 20, 2005 12:26 am Post subject: |
|
|
To clarify- for the SysList32 view you can select and navigate list items with Tab and the arrow keys, maybe this also works in MetaStock? Then perhaps you can send Tab, Up arrow (to select first item) or Ctrl+A to select all, and then send Ctrl+C instead of sending mouseclick/coords. _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
SAbboushi
Joined: 18 Sep 2004 Posts: 60
|
Posted: Sun Feb 20, 2005 12:44 am Post subject: |
|
|
Thanks Serenity - got it. Actually, I am already at the point where the rows are highlighted with CTRL/A - and sadly (per my initial post), CTRL/C does not copy the highlighted rows to the clipboard.
I am trying to use ControlClick right now:
| Code: | ControlClick, SysListView321,Enhanced System Tester,,RIGHT
|
It looks promising because it does display the right click menu - however, it is as if the right click occurs below the highlighted rows (if it occured a little higher, then the menu would have different options).
Some confusion: I then tried
| Code: | ControlClick, ,Enhanced System Tester,,RIGHT
|
and it did just what I wanted! I did not understand why omitting the SysListView321 parameter caused ControlClick to work - so I added it back and tried this again
| Code: | ControlClick, SysListView321,Enhanced System Tester,,RIGHT
|
and it also worked... Not sure why the inconsistent results with the same code... Can anyone shed some light on this?
Although I said I did not want to use coordinates in case the window changed, ControlClick seems to use relative coordinates to SysListView321 - so am looking into that too.
I also read somewhere that there is an APPS command that does the same thing as a right click - I just am not able to find out where I read that! If anyone knows where I can find info on that APPS command is and whether it might help give me consistent results...
Thanks- |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2421
|
Posted: Sun Feb 20, 2005 1:16 am Post subject: |
|
|
SAbboushi,
If Ctrl - C does not copy for you then it is possible that the app is not using the clipboard (copy/paste) but rather using a custom routine and calling it copy/paste. If this is the case you can try and determine if there is a message that you can send to simulate clicking copy in the right click menu. If that fails... since you have found a way to simulate a right click... does "copy" have a letter underlined in it (indicating a shortcut key you could try to send once the menu is open)? or could you then send arrow key up/down to get to the menu item then enter? |
|
| Back to top |
|
 |
SAbboushi
Joined: 18 Sep 2004 Posts: 60
|
Posted: Sun Feb 20, 2005 1:24 am Post subject: |
|
|
Thanks - Once I right click, menu options appear including "copy to clipboard". I can have AHK send {DOWN}{ENTER} and it will perform the copy to clipboard for me. The area I am having problems with is automating the Right Click.
And yes - I would much rather use a message to do this. I assume you mean sendmessage or postmessage - my earlier posts explain how far I got with that - if anyone knows how to get me further, I would dance a jig right now! |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Sun Feb 20, 2005 1:37 am Post subject: |
|
|
| SAbboushi wrote: | so I added it back and tried this again
| Code: | ControlClick, SysListView321,Enhanced System Tester,,RIGHT
| and it also worked... Not sure why the inconsistent results with the same code... Can anyone shed some light on this? | It might be sensitive to whether or not the control has focus. Using ControlFocus and/or ControlClick on it beforehand might be able to set the focus.
| Quote: | | I also read somewhere that there is an APPS command that does the same thing as a right click | Examples that might help:
Send {AppsKey} ; While window is active and control is focused.
ControlSend, SysListView321, {AppsKey}, Enhanced System Tester
Note: Some apps do not support AppsKey.
| Quote: | | I would much rather use a message to do this. I assume you mean sendmessage or postmessage | If there is a message involved, you should be able to discover it with Rajat's SendMessage Tutorial. |
|
| Back to top |
|
 |
|