Jump to content
Macro Express Forums

Control doesn't exist


ehercun
 Share

Recommended Posts

I'm trying to "Get Control" of a window within a window (I think they're called child windows) and then send text to that window and press "Enter". But whenever I try to run the script, it gives me "Debug Error: Control doesn't exist".

 

A way to think about what I'm trying to accomplish is to picture a bunch of open notepad files (none of the windows are overlapping) and I need to click on the first notepad window in the sequence, type something, press enter, then click on the following notepad window in the sequence (the one beside or below it, the order is not important here), type something, press enter, and repeat.

 

I'm using the following code.

 

<GET CONTROL Flags="1" Program_Name="ORCHART.EXE" Class="ORPLAT.EXE TRADESTATION" Title="TradeStation 8.7 - DayTrader - DayTrader2" Control="\"MDIClient\",\"16\",\"ORContainerMDIChildFrame:8455\",\"1\",\"ORContainerView\",\"1\",\"ORInPlaceFrame\",\"1\",\"AfxFrameOrView42\",\"1\"" Variable="%Test1%" Caption="TradeStation 8.7 - DayTrader - DayTrader2" Partial="FALSE" Wildcards="FALSE"/>
<GET CONTROL Flags="1" Program_Name="ORCHART.EXE" Class="ORPLAT.EXE TRADESTATION" Title="TradeStation 8.7 - DayTrader - DayTrader2" Control="\"MDIClient\",\"16\",\"ORContainerMDIChildFrame:8455\",\"101\",\"ORContainerView\",\"1\",\"ORInPlaceFrame\",\"1\",\"AfxFrameOrView42\",\"1\"" Variable="%Test2%" Caption="TradeStation 8.7 - DayTrader - DayTrader2" Partial="FALSE" Wildcards="FALSE"/>
<TEXT TYPE Action="2" Control="%Test1%" Text="jnk<ENTER>"/>
<TEXT TYPE Action="2" Control="%Test2%" Text="qqqq<ENTER>"/>

 

Rather than using controls, I tried playing around with the mouse move, then mouse click, then simulate keystrokes and I achieved the desired result. So either I'm doing something wrong with controls, or the program I'm trying to interact with wasn't programmed to be interacted in such a way.

 

Ideally, I would like to be able to use controls since it seems that everything would be a lot more stable.

 

Thanks and happy holidays!

Link to comment
Share on other sites

Oh and I just wanted to add that when I chose notepad as the actual control rather than the child window in "TradeStation 8.7" and ran the script, it wrote the text with the <ENTER> to the open notepad file without any problems. This leads me to believe that there is probably something wrong with how controls are defined or programmed in TradeStation.

Link to comment
Share on other sites

I'm kind of shooting in the dark here, because I haven't had a lot of success with controls except in one application.

 

I wonder if your TradeStation application creates its child windows anew each time it runs, so that the identifying control information is different each time? Then, since your macro points to the controls as they existed when you coded the Get Control commands, the macro will not find the "new" controls.

 

There is a Capture Control command, apparently intended to retrieve the identifiers for each control at macro run time, as opposed to Get Control that retrieves the identifiers at macro coding time. One option of Capture Control is to work with the control under the mouse. So, if TradeStation puts its child windows at predictable locations on the screen, perhaps you could have a one-time routine to Capture (once a day, say, after you start TradeStation) -- and use that information for the rest of the day rather than using Get Control on each pass through your macro.

 

Like I said, my experience with controls is minimal, so all the above may be based on ignorance rather than reality. Let me know if it helps....

Link to comment
Share on other sites

Hey Bob,

 

Thanks for your reply.

 

Unfortunately, I haven't even got as far as having to restart TradeStation yet. I was merely writing and testing one part of my macro to see if I'm able to control the destination application (in this case TradeStation) the way I intended. I've tried several combinations with Caputre Control, and Get Control, along with Set/Get Focus, activate window, etc. It seemed that I got SOME results when I used Capture Control with specific coordinates.

 

I realize that I do not have to activate or get focus of the window when using controls, since I was writing to the notepad file while it was minimized,

 

Oh and I just wanted to add that when I chose notepad as the actual control rather than the child window in "TradeStation 8.7" and ran the script, it wrote the text with the <ENTER> to the open notepad file without any problems. This leads me to believe that there is probably something wrong with how controls are defined or programmed in TradeStation.

 

And just to be clear, I did not restart the application after I defined (is that the right word?) the control. So basically, I opened the script editor, double clicked on 'Get Control', launched the utility, dragged the cross hairs to my target destination, click ok, Test Run the macro, and I get the error that "Control doesn't exist".

 

But thanks for the idea anyway Bob.

Link to comment
Share on other sites

In the 'Capture Control' dialog there is an option that you can choose titled 'Capture using text'. Have you tried capturing the control with that option?

 

Could you post a sample of your macro that fails? (Please use 'Code' tags ... see the 'Wrap in code tags' icon above.)

Edited by kevin
Link to comment
Share on other sites

<GET CONTROL Flags="1" Program_Name="ORCHART.EXE" Class="ORPLAT.EXE TRADESTATION" Title="TradeStation 8.7 - DayTrader - DayTrader2" Control="\"MDIClient\",\"1\",\"ORContainerMDIChildFrame:8455\",\"170\",\"ORContainerView\",\"1\",\"ORInPlaceFrame\",\"1\",\"AfxFrameOrView42\",\"1\"" Variable="%Test1%" Caption="TradeStation 8.7 - DayTrader - DayTrader2" Partial="FALSE" Wildcards="FALSE"/>
<TEXT TYPE Action="2" Control="%Test1%" Text="qqqq<ENTER>"/>

 

I've tried both ways I get the same error "Control doesn't exist".

Link to comment
Share on other sites

I'm sorry, I missed that you had posted a sample macro in your initial post. Thank you for posting another sample.

 

We will look into the problem to try to find out what is going wrong but we need some additional information. Would you please contact Insight Software Solution's support at the email address on our contact page? Once you contact us directly we will be able to ask questions directly.

 

Your sample macro was created with Macro Express Pro but this topic was posted in the Macro Express 3 forum. To avoid confusion and to help you get more accurate answers, please post Macro Express Pro questions in the Macro Express Pro forum.

Link to comment
Share on other sites

I have already sent the email to you guys (probably around 1:20pm pacific).

Our support people have been looking for your email but say they have not received it. Please try again. The email address is "info at wintools dot com". Please include a brief description of the issue so they will know who you are.

 

What version of Macro Express Pro are you using? There was a change in Macro Express Pro v 4.1.1.1 that affected the controls. Using the latest version of Macro Express Pro may help.

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...
 Share

×
×
  • Create New...