Jump to content
Macro Express Forums

Program "wait" And Text Recog


cyberchief

Recommended Posts

Hey all! Brand new here... and just installed ME. I have gone through most of the tutorial and have read many of the topics here. I have a couple questions... I am trying to figure this fangdangle thing out :D

 

We use programs that sometimes "hang" while waiting for information from the server and databases. After reading through here... it seems the only way to "pause" a macro is to put in a time delay. My problem is that most of the time, the application does not hang... but once in a while, it will be "not ready" while waiting for the database or server to respond. This creates quite a variable in time length for the delay. Most of the time, it is within a second. Sometimes, it can hang for 30 seconds. The macro program installed with the program "waits for screen" causing it to wait until the information or window has posted. Is there any type of function in ME to do this? It seems not, but I thought I would ask.

 

Second, In a similar database program, I am trying to create a macro to change a customer's address. There are lines in the program with specific identifiers signifying what data each line should contain. See below for example:

 

____ BN1__ CUSTOMER NAME_________________

 

____ BN2__ ATTENTION LINE__________________

 

____ BA1__ CUSTOMER ADDRESS______________

 

____ PO___ CITY, STATE, ZIP_________________

 

There is an entire page of data and most of the time, different quantity of lines between the home starting point and the address information. I would like for the macro to find "BN1", set focus to that spot, and tab over to overtype the text in the data feild. Also, in certain cases, I need to change that BN1 to IBN1, or in other cases, if no BN2 exists, insert a line and include a BN2. Are these things even possible? or am I day dreaming?

 

And please remember... I am knew... and vulnerable :huh: Please.... be gentle.

Link to comment
Share on other sites

hi and Welcome!

 

i doubt if you're dreaming, and some of the experts here may well be able to help!

 

Iam not sure if I can. ....

 

Q1 - Yes, if there is a new "screen" which presents with the new data, "Wait for Window Title" would do it. - - If a new file presents, "if File exists" or "wait File exists" will help - just a matter of identifying it.

 

Q2. - I am not sure if you are trying to do this from database program, running, with input screen, or from a database file of some sort -directly? Either are probably possible..., but very different starting points. (eg use "Get Windows control text" on the one hand, or "text file process" on the other.

 

Best, Randall

Link to comment
Share on other sites

Thanks for the info... it does provide me with a glimmer of hope.

 

First, the window does not "re-title" itself... it retains the same title even after the new information posts. This may just show my ignorance with ME... but doesn't the program look for the variation of the window title to continue processing commands (i.e. the title of a web page changes as you navigate).

 

Also, the pogram is not really a database... it is more of a portal to a back end database. I put in the account number, and it searches and displays on the screen in a specific format ( but for the order application, not always in the same position). The order application displays all parts of a new order with fields that are typable. Each field has a beginning identifier (BN1 as before)... I need for the focus to be set specifically to the BN1 field wherever it is on the screen.

 

Thanks much for all your help... I look forward to more replies! Everything is helpful!!!

Link to comment
Share on other sites

hi again,

 

Q2. If you are doing it with a Web browser, I'm definitely not experienced in it and I doubt you could use Windows controls; you could check if they have any (run "Get Control" and drag the Bull's eye/ crosshairs on to the data box)

 

Q1 "Wait for Window" Will wait for "partial" titles, so if there is a change in the Window title, it will wait for the new text; or you can run a loop (repeat) to keep checking the Window title for a change.

 

Best, Randall - (away from computer now - good luck)

Link to comment
Share on other sites

Hello cyberchief!

So, as far as anybody knows, there is no way for ME to find specific text in a text field?
There are a couple ways of doing this. Kevin's suggestion that you look into using Window Controls is perhaps the easiest way to capture text in a field. You had mentioned that your work is done by not using a browser, so you must be running a local executable of some sort that accesses the database. This gives you a fair shot, but it depends on how the program you are running is written.

 

Another way is to capture and paste the data in the window to the clipboard and use the Macro Express string commands to find what you need.

Link to comment
Share on other sites

Yes cyberchief,

 

I think you mis-understand if you are concerned already!

 

Finding the text in the text field is easy once you have found the field; it is just hard to say how to find the field without knowing what terminal you are using (Does your program have a name?), and whether "Get Control" works! Did you try it?

 

Otherwise, you may need to set your cursor somewhere (there will be one control or other available to "Set Focus to control"), and repeatedly tab through all the fields, copy text to the clipboard, check if it contains the text you are looking for? -You will still need some identifier that the data has chnged from the last check; is there something you can check for or change yourself in a particular field (or even in any field) that would identify it as "the old screen"?

 

Kevin's comment is in the hope you wouldn't have to even start doing this till you knew something had changed on the screen in a certain spot (but that may not be the case)

 

Best, Randall

 

Try this in "My Control" screen on this Web - Page;

If you find the field you want accepts focus, set that field and you don't need to tab

You will have to give this macro a hotkey (eg CTRL_SHFT_X), and hover the mouse over the explorer address field to run

 

// If you find the field you want accepts focus, set that field and you don't need to tab

// You will have to give this macro a hotkey (eg CTRL_SHFT_X), and hover the mouse over the explorer address field to run

Capture Control to %C1%

Repeat Until %N1% <> %N1%

  Clipboard Empty

  Set Focus to %C1%

  Wait for Control %C1% to gain focus

  Text Type: <TAB>

  Delay 100 Milliseconds

  Repeat Start (Repeat 8 times)

    Text Type: <SHIFT><TAB>

    Delay 100 Milliseconds

  Repeat End

  Text Type: <CONTROL><SHIFT><HOME>

  Clipboard Copy

  Variable Set String %T1% from Clipboard

  Delay 200 Milliseconds

  If Clipboard Contains "snippets"

    Repeat Exit

  End If

Repeat End

Text Box Display: Text I have changed

(Write in the "Quote" or copy in the "Code" to Scripting editor)

<REM2:If you find the field you want accepts focus, set that field and you don't need to tab><REM2:You will have to give this macro a hotkey (eg CTRL_SHFT_X), and hover the mouse over the explorer address field to run><CAPCONTROL:F:1:1:><REP3:08:000002:000002:0001:1:01:N1><CLIPE><SETFOCUS:01><WAITCONTROL:000010:000000:01:01><TEXTTYPE:<TAB>><IMSD:100><REP3:01:000001:000001:00008:0:01:><TEXTTYPE:<SHIFT><TAB>><IMSD:100><ENDREP><TEXTTYPE:<CONTROL><SHIFT><HOME>><CLIPC><TVAR2:01:03:><IMSD:200><IFOTH2:08:1:snippets><EXITREP><ENDIF><ENDREP><TBOX4:T:1:CenterCenter000278000200:000:Text I have changed...IS changed (if you change "snippets" to what you likee, then check for it)

=======
%T1%>

 

It's messy using the mouse hover (replace it with "Get Control" or Capture with mouse coordinates if they are stable) ; it may not work if you are using a different browser anyway, or if you have different numbers of tabs due to extra toolbars etc), and you may have to abort yourself -But just to give you an idea of "looking for text in fields" as you say) - Yu may want to adjust it to copy every tab to the clipboard and examine it to see where you are;?

Link to comment
Share on other sites

I don't think the Window Controls will work because with each account pulled, the BN1 feild can change relative to anywhere on the screen.

 

Again, i apologize because I am a newb. I think if "copying text to clipboard and running a function if said copied text matches BN1, then do such and such, else, tab on" works... I might be in business. I have much to read in the help files... it is a little discouraging because there is so much and I am not finding much... but you all have put me on the right path. It is MUCH appreciated!!! Thank you all for your help. Now, I can figure out how to copy to a clipboard... but, I need to figure out how to extend the field. The program we are using was build specifically for the company... so it is not softward available anywhere else. common functions like ctrl-f for find do not work. I need to be able to hold the shift key and arrow over 3 times to cover all 3 spaces to copy to the clipboard. I am trying text type... but it only will highlight the first character. <Shift><End> will not work for my purposes. Anyone know how to do this? <Shift><Arrow Right><Arrow Right><Arrow Right> doesn't work... it only picks up the first arrow right and only highlights the first character. Thanks all for putting up with my newbie ignorance. I will continue reading and trying to help myself!

Link to comment
Share on other sites

Hi,

 

Good Luck!

 

I am just saying that may may wish to start your search loop at a constant spot; and even just grabbing the control of your frame may help;

 

eg in the above example (did you try to go to the "My Control" page from the link at the top of this page?), even using

 

Get Control %C1% (Welcome to your control panel - Microsoft Internet Explorer: )

Text Type: <TAB>

Repeat Start (Repeat 8 times)

  Text Type: <SHIFT><TAB>

Repeat End

(quote comes from selecting lines in editor, "Edit", "Copy Command Text")

(Codecomes from selecting lines in editor, "Edit", "Copy")!

<GETCONTROL2:01:IEXPLORE.EXE:IEFrameWelcome to your control panel - Microsoft Internet Explorer000:><TEXTTYPE:<TAB>><REP3:01:000001:000001:00008:0:01:><TEXTTYPE:<SHIFT><TAB>><ENDREP>

 

may help.

 

Do you understand you can paste this Code (But not the Quote!) into your editor in a new macro and you can read it?

 

You are right; once you are in a field, you may need <CONTROL><<END><CONTROL><SHIFT><HOME> or similar to grab text?

 

Copy to clipboard for comparing;

Then easier to copy to a variable if you are going to manipulate and change text; save back the changes later

 

Once you get to string manipulation, there are all sorts of "Edit Replace" options etc within string variables

 

Best, Randall

Link to comment
Share on other sites

The program I am using is archaic... pretty old... so a lot of the functions available will not work. But, I was able to put together a pretty brutal attempt that does work... though, it takes forever. I have set it up to copy 3 text spaces from each field. I have it copying to the clipboard and comparing it to the specifications requested. If it does not find it, it moves on... and repeats until it does find it. And then, goes on to the next field searching. I am still working on a better way. But Window Controls does not work as far as I can tell. I have tried, but nothing works as of yet.

 

Activate Window: "SOPAD_CO_WY - USWest Connect"
Repeat Until %T1% = "BN1"
 Text Type: <TAB>
 Text Type: <SHIFTD><ARROW RIGHT><ARROW RIGHT><ARROW RIGHT><SHIFTU>
 Clipboard Copy
 If Clipboard Text Equals "BN1"
   Text Type: <TAB>
   Text Type: Customer Name
 End If
 Variable Set String %T1% from Clipboard
Repeat End
Clear Text Variables: All
Repeat Until %T1% = "BN2"
 Text Type: <TAB>
 Text Type: <SHIFTD><ARROW RIGHT><ARROW RIGHT><ARROW RIGHT><SHIFTU>
 Clipboard Copy
 If Clipboard Text Equals "BN2"
   Text Type: <TAB>
   Text Type: Customer Address
 End If
 Variable Set String %T1% from Clipboard
Repeat End
Clear Text Variables: All

 

<SPKEY:0000><ACTIVATE2:SOPAD_CO_WY - USWest Connect><REP3:08:000001:000001:0001:0:01:BN1><TEXTTYPE:<TAB>><TEXTTYPE:<SHIFTD><ARROW RIGHT><ARROW RIGHT><ARROW RIGHT><SHIFTU>><CLIPC><IFOTH2:07:1:BN1><TEXTTYPE:<TAB>><TEXTTYPE:Customer Name><ENDIF><TVAR2:01:03:><ENDREP><CLEARVAR1:T:ALL><REP3:08:000001:000001:0001:0:01:BN2><TEXTTYPE:<TAB>><TEXTTYPE:<SHIFTD><ARROW RIGHT><ARROW RIGHT><ARROW RIGHT><SHIFTU>><CLIPC><IFOTH2:07:1:BN2><TEXTTYPE:<TAB>><TEXTTYPE:Customer Address><ENDIF><TVAR2:01:03:><ENDREP><CLEARVAR1:T:ALL>

Link to comment
Share on other sites

  • 2 weeks later...

Hi there,

It sounds like that you are using a terminal emulation (Windows program) to access a mainframe application. I had a similar situation. It is a little challenging because of the different response times and the fact that you don't have access to any of the controls. So this is what I did:

Step 1:

Usually the mainframe pages (screens) have a title code somewhere on the screen. I use the "Move mouse" function to locate and then copy the title to the clipboard.

<TVAR2:11:01:><MMS2:877,167><LDN><MMS2:942,168><LUP><TEXTTYPE:<CONTROL><INSERT>><TVAR2:11:03:>

Then I loop (repeat) with a delay until the title at that location changes to what I expected to be.

 

Step 2:

Once the right screen is up, you can use the tab key to move the cursor accross the fields. On each fields you can retrieve the leading "label" (the field label) if you want to verify what field you are on. At the point you are ready to populate the field with the correct information.

 

I hope that I understood your problem correctly and I also hope that this will guide you towards the right solution.

 

Take care, FD2000

Link to comment
Share on other sites

Welcome to the forum fd2000 -

 

I do believe that cyberchief got his "waiting" problem resolved. In his situation, the visible window title never changed no matter which internal window was running. In other words, five different windows all with the same exact title.

 

The problem he was having with Window Controls was the server would append an "invisible" string of coded text to the visible window title within the Window Control itself. And it was a different string each time the window was accessed. This meant that the Window Control could never find the correct window.

 

It was solved by using Capture Control, which is the runtime version of Get Control. The Window Control would be "generated" after the next window was rendered. Worked like a charm!

Link to comment
Share on other sites

Welcome to the forum fd2000 -

 

I do believe that cyberchief got his "waiting" problem resolved. In his situation, the visible window title never changed no matter which internal window was running. In other words, five different windows all with the same exact title.

 

The problem he was having with Window Controls was the server would append an "invisible" string of coded text to the visible window title within the Window Control itself. And it was a different string each time the window was accessed. This meant that the Window Control could never find the correct window.

 

It was solved by using Capture Control, which is the runtime version of Get Control. The Window Control would be "generated" after the next window was rendered. Worked like a charm!

Floyd,

 

Yes it did! Worked like a charm indeed! Thanks to all of your input... and especially thanks to Joe! Working it out with him... I didn't realize that the control title had invisible characters change with each screen. I used the capture control function after hitting the screen key (to change screens). Set it in a loop and now it works great! See code:

 

  Text Type: <F1>
 Capture Control to %C1%
 Repeat Until %T30% Contains "Logged in"
   Variable Get Control Text: %C1% to %T30%
   If Variable %T30% contains "Logged in"
     Break
   End If
 Repeat End

 

<TEXTTYPE:<F1>><CAPCONTROL:T:3:1:000061,000703><REP3:08:000007:000001:0030:0:01:Logged in><VARGETCONT:1:30><IFVAR2:1:30:7:Logged in><BREAK><ENDIF><ENDREP>

 

 

Floyd, I am still having trouble with finding text within the control on the screen (the entire order screen is the control). I have another thread started anew on this (now that I have a better idea of what is going on). I need to find 3 characters somewhere on the screen... for order input. Currently, I have it set to copy the first 3 characters of the text field to a clipboard... and if it matches the variable set (BN1), then process the data... else.. tab to the next field and repeat. Problem is... there are about 100 fields... and I need to do this for about 15 3 digit characters. Randall introduced me to your sorting macro and such... but I haven't been able to pull anything useful out of that for my situation. If you have any other hints.... I would be much obliged.

Link to comment
Share on other sites

(the entire order screen is the control).

my goodness; does this mean you really can do "replace" within the control variable (T30?) and Set the text of the control back to the modified string? - Seems unlikely, but would save counting tabs!

I presume you were tabbing the fields originally to get this to work?

Randall

Replace "BCN" with "BC1" in %T30%

Replace "BCO" with "BC2" in %T30%

Replace "BCP" with "BC3" in %T30%

Replace "BCQ" with "BC4" in %T30%

Replace "BCR" with "BC5" in %T30%

// etc

Variable Set Control Text %C1% to "%T30%"

Link to comment
Share on other sites

my goodness; does this mean you really can do "replace" within the control variable (T30?) and Set the text of the control back to the modified string?

I do not think so. Not in this case. But if each field were a Window Control that accepted text as input, you would use the Text Type command with the Send Text to Control checkbox checked to change the text within the actual control. On the other hand, the Variable Set Control Text only changes the Window Control's variable, not the control itself. There are some of examples of these in the Window Controls chapter.

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