Jump to content
Macro Express Forums

Copying Stock Ticker Between Windows


Recommended Posts

I would like to know if I can use Macro Express to solve a problem. I use two different trading platforms. When I type a stock ticker (a string of no more than 4 characters) into a window in one of the platforms (the sending platform) I would like that same string to be entered into a window of the other platform (the receiving platform). Is there any way to do this using Macro Express?

 

The sending platform has an external linking feature, but it does not work with the receiving platform I'm using.

Link to comment
Share on other sites

Here's a possibility:

1. Type the string into the first window, but DON'T hit ENTER or click on a button or whatever needs to be done next.

2. Hit a hot key to start a macro.

3. Macro types Shift-down / Left-arrow(s) / Shift-up sequence to highlight the string you just typed, and copies highlighted string to clipboard. Macro then types ENTER or clicks the mouse or whatever the window (sending platform) expects you to do.

4. Macro activates the second window (receiving platform), tabs or mouse clicks or whatever to the target field, types or pastes from the clipboard.

 

Sounds feasible, maybe very easy, maybe less easy. As Cory said, difficulty depends on just what applications you are dealing with.

Link to comment
Share on other sites

Both platforms are windows apps.

 

Thanks for your input rberq, but that sounds like it will take too long. I need this process to be fast and automatic. I need the program to detect that the ticker has been changed in one window and automatically change it in the other window.

 

Any other thoughts on how I can solve this problem?

Link to comment
Share on other sites

It's possible, but the project could turn into a major scripting job. Automatically detecting a screen update might be trivially simple, horrifically complex, or impossible. You won't know which until you try. I can almost guarantee it's going to take significant amount of trial and error experimentation.

 

A simpler approach might be to semi-automate the task. Instead of automatically detecting a screen event, start the process manually by pressing and releasing a hotkey, typing one or two characters, or clicking the mouse on part of the UI.

 

Sounds like a fun project for someone who derives pleasure from writing macros (which is almost everybody on this forum!)

Link to comment
Share on other sites

No more than 1 second. Do you think that the macro would work that fast?

Perhaps. Computers are pretty fast. For example, using Alt-Tab to switch from one Windows application to another is practically instantaneous -- a macro can type that key combination in a millisecond where it would take you way longer just to position your fingers. Clicking on a data entry field whose location is known, or even tabbing to it, can be extremely fast when a macro is doing it.

 

Just need to try it on the actual PC and applications. Could you maybe post screen shots of the two applications, indicating the fields to be typed into?

 

Do you by chance have a dual monitor setup, where both applications can be visible at the same time, one on each monitor?

Link to comment
Share on other sites

Yes, I have a multi-monitor setup. However, for this particular solution both applications will be on the same monitor and visible.

 

I would be happy to post screenshots, but I can't even log in to one of the platforms right now because the trading servers are offline over the weekend. I'll post screenshots early next week.

 

I think the solution posted by rberq would work. I'm going to try creating a script using his steps, but this would be my first Macro Express script so any help would be greatly appreciated.

Link to comment
Share on other sites

I don't have a lot of time but it sounds like you're typing the same thing in two places. In that case I'd prompt for the string then have the macro enter the values into the text box controls in each window. Using the controls commands in MEP means one doesn't even have to activate the windows. In fact they could be visible. There's a tutorial on using control commands using Notepad made available by ISS. It's either in the samples with the install or on the support website. As far as speed, once the user enters the string, it would be effectively instant.

Link to comment
Share on other sites

I was also thinking that an elegant and reliable solution might be possible using controls. Learning to deal with Windows controls is not particularly easy; I have been using Macro Express since 1999 (perhaps earlier), and I am still figuring out how to automate tasks via controls.

 

The tutorial that Cory referred to you is a good introduction.

 

I have found that when capturing a control that appears in a window that has a changing title, choose the option to "save the control using its coordinates."

 

 

post-4013-0-88330600-1484497379_thumb.png

Link to comment
Share on other sites

OK, I've run into my first problem. At this point I'm just trying to create a macro to activate the window and type some text to change the ticker (e.g. GOOG). I was able to get this to work with Notepad, but it doesn't work with the trading platform I'm using, TradeStation.

 

If I manually activate the window, type the text "GOOG" and press enter it changes the chart symbol to GOOG. However, the macro does not change the chart symbol. I can see it activate the window but the text never goes through.

 

I've attached a screenshot of the simple script.

 

 

post-20104-0-20177500-1484537466_thumb.png

Link to comment
Share on other sites

When you hover over the controls are they being detected? Try using another WinForm application to see what I mean.

 

I'm not sure if your program is using MDI or what. There was no mention of child windows before. But app windows are usually easy enough to do as long as they don't have the same window title.

 

Be aware that new "Modern", or "Metro" Windows apps are a problem for MEP. They're UWP. Make sure this is not the case.

 

I don't agree that the Windows Control are more difficult. I think they'er really simple and they make the macros much more reliable and simpler.

Link to comment
Share on other sites

I have the full macro working, except it is not consistent. There seem to be 2 problems.

 

Problem 1:

The first command is Text Type: <SHIFTD><HOME><SHIFTU> to highlight the ticker that I just typed and then I do a clipboard copy. This works the first time and maybe the second and third time I run the macro, but after a few runs it seems to stop working. I put in a delay of 2 seconds so I can see what is happening. When it stops working the text is not highlighted but the cursor goes to the start. So the <HOME> command still runs, but it is like the SHIFT key is not being pressed. What could cause the macro to start behaving differently?

 

Problem 2:

The TradeStation behavior is also inconsistent. I'm calling Window Activate, then Type Clipboard Text, then Text Type: <ENTER> and then Wait for Text Playback. In some cases this works and at other times it seems the platform was activated but the text did not go through. I'm wondering if this might be a timing issue and I need to delay just a little bit after activating the window.

Link to comment
Share on other sites

Is it possible to check the coordinates of a Control that I've captured?

 

Once I've captured the Focused Control. I would like to have the macro behave differently if the control is in a different position. (e.g. I may have multiple Lightspeed windows open and I want to link each of those windows to there own TradeStation window).

Link to comment
Share on other sites

Congratulations. Your script looks good! And it doesn't seem to need delays to make it run reliably. (Although in the fullness of time, you may discover the script will benefit from time "shims" to maximize reliability.)

 

I can almost guarantee it's going to take significant amount of trial and error experimentation.

 

 

:rolleyes: Told you so!

Link to comment
Share on other sites

If you decide on inserting delays consider making them a variable (technically a constant). This way you can change them all at once.

 

There's no time being used with controls like there is in TextType. Also using the clipboard takes time. In my experience switching to control commands usually eliminate timing issues.

 

I don't like your control command to capture at a coordinate. It's likely to cause you troubles in the future. I'd change that to a Get Control ASAP.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...