Jump to content
Macro Express Forums

UAMike

Members
  • Posts

    57
  • Joined

  • Last visited

Posts posted by UAMike

  1. I use macros to remove lines of text from a larger block of text. I am using the Variable Modify String command to replace unwanted text with a blank. The problem of course is that I then end up with blank lines when I wanted was to remove the text and carriage return. Here is an example:

     

    The list contains:

     

    -A

    -B

    -C

    -D

    -E

     

    End of list.

     

    What I will end up with after using Variable Modify String is something like this:

     

    The list contains:

     

     

    -B

    -C

     

    -E

     

    End of list.

     

    What I wanted was it to be formatted like this:

     

     

    The list contains:

     

    -B

    -C

    -E

     

    End of list.

     

    How can I accomplish this? I tried using Trim CR/LF, but then I am removing all the carriage returns.

  2. On 3/20/2019 at 8:10 AM, rberq said:

    Are you sure the web page is completely (or sufficiently) loaded before the search?  You could try Wait for Web Page before searching for text. 

    That might explain why you can't reproduce the problem manually -- it takes you a lot longer to type in the search than it takes the macro, so by the time you finish typing the browser is ready for you. 

     

    I believe the Wait for Web Page only works in IE, whereas I am using Chrome. In any case, it's not always the first thing that I search for on a page that the macro gets tripped up on... sometimes it's the 2nd, 3rd, etc, by which time the page has definitely loaded completely. 

  3. On 3/16/2019 at 8:33 PM, acantor said:

    It sounds like a timing issue. What happens if you add extra long pauses between each step, say, 1000 milliseconds?

    It shouldn't make a difference, but maybe try F3 instead of Ctrl+f.

     

    If you can't find a solution, consider rewriting your script for Firefox. I use the same technique regularly with Firefox, and I can almost always make MEP scripts work.

     

    I've tried slowing down the macro and still get the same results, only slower lol. Unfortunately I don't have the option to use Firefox (this is my work machine and they only want us using Chrome). It's always frustrating when something used to work just fine and all of the sudden doesn't 😤

     

    I will try using Ctrl+F instead of Ctrl+f. Will also try F3 and report back.

  4. I have been incorporating the Ctrl+F function in a Chrome browser to allow my macros to interact with various parts of a page (or series of pages).

    A given macro will TextType Ctrl+F to search for a specific phrase that I know will only appear once on a given page. In Chrome, the text found gets highlighted in orange, then when you hit esc, it will turn blue. I use the blue highlighted text to tab to a specific text box, to click buttons, to gather information that then gets stored into variables, etc.

    This has worked perfectly until very recently. Now, after a string is found and highlighted orange, it doesn't always highlight blue when I hit esc. Sometimes it will, sometimes it won't. As a temporary fix, I have the macro perform the same search twice... and on the second attempt the text will undoubtedly highlight orange, then blue when I hit esc. I thought perhaps there was a window focus issue or a timing issue, but that hasn't led me anywhere. I can't even reproduce this behavior if I manually search for something in my browser. 

    Any ideas? What other steps can I take to debug this issue? Since I rely on the Ctrl+F function so much, it really slows down my workflow to have the macro repeat the search a second time.

  5. On 12/22/2017 at 9:01 AM, Cory said:

    Well it doesn't appear that anyone is interested anyway. It's discouraging. I thought for sure UAMike would have loved this and yet I got absolutely no response. Pfft. That's what I get for doing something nice. 

    There's nothing wrong with it. It's working perfectly. When I run the macro I get this. I edit it to add some text like this. Then I click the 'clip and close' button and I get this. I've tried it multiple times and it always works. It's too simple not to. Maybe you can show me what you mean with some screenshots.

     

    On 12/23/2017 at 4:05 AM, terrypin said:

    OK, Cory, here's a couple of screenshots. (I assume you were replying to me?) And as you may have noticed, I too had no response from the OP in the six weeks since offering my macro. But see also my 26th November post here

     

    TextBoxEditor-1.jpg

    TextBoxEditor-2.jpg

    My apologies! It was around this time in November that I was dealing with various family issues. It is only this week that I have returned back to work and so I actually forgot that I posed this question to begin with. I do sincerely appreciate the effort that you put forth in helping members of this community. Terry, your script is very similar to what I ended up doing with Notepad. Corey, this app looks great! I will give it a try tomorrow :)

  6. I've started to incorporate the ASCII functions more frequently when building my macros. I'm wondering whether it is possible to utilize this (or related) function to work with larger blocks of formatted text.

    For example, my work periodically sends out excel spreadsheets with standardized texts that they expect us to copy and paste from. What I have always done is pre-program macros with variable set string to contain the corresponding text that I otherwise would have had to copy and paste from the spreadsheet. I am wondering if there is a way for me to have my macros reference a corresponding cell in the spreadsheet and copy the contents of the cell to either the clipboard or a string variable. This way, I would save myself time whenever a new version of the spreadsheet becomes available (which usually have simple changes like paragraph formatting, grammar, etc). 

  7. I am trying to figure out a way to modify a long string variable (a paragraph or two of text) while the macro is running and then use the updated variable downstream in the macro. I want to be able to delete phrases, words, adjust spacing, etc, so any of the 'Variable Modify String' functions will not do the trick. 

    I think I can get this done by having the macro paste the string into a notepad document, then I would do my manual edits, then copy the text to the clipboard and set the variable to the clipboard contents.

    Ideally I wouldn't have to fiddle around with this clipboard/notepad method, but I am not sure if there is an easier/better way. Any suggestions?

  8. 2 hours ago, acantor said:

    Can you navigate to these "buttons" by tabbing to them? Is it clear the buttons have focus?

    Sort of... What it is is a "box" (looks like two columns in a spreadsheet)  with several phrases from which you can pick one or more options. When you click on one of these phrases, it has a downstream effect on what else gets displayed on the page. I'm not sure if that constitutes a button, but is certainly an element of the page that I can interact with as opposed to a plain string of text. From what I can tell, the box itself can have focus, but not the individual phrases within the box.

    Here is a short sample of the source code, which is about 90% foreign to me.

    id='sidebar-region-one' class='screen-layout-region screen-layout-region-main screen-layout-region-main-sidebar1 screen-layout-region-resize' aria-label='Left Panel' role='complementary'><div class='screen-layout-region-content'><div  class='sectionDivStyle' id='RULE_KEY' node_type='MAIN_RULE' node_name='PrismPortalNav' data-node-id='PrismPortalNav' version='1' objclass='Rule-HTML-Section'  pyclassname='Data-Portal' readonly='false'  NAME='BASE_REF' BASE_REF=''  expandRL='' uniqueID='SID1510616504615' ><span class='inspector-span' ><div class='layout layout-noheader layout-noheader-section_divider'><div section_index='1' class='layout-body clearfix' ><div  class='sectionDivStyle' id='RULE_KEY' node_type='MAIN_RULE' node_name='PrismActionItemLinks' data-node-id='PrismActionItemLinks' version='1' objclass='Rule-HTML-Section'  pyclassname='Data-Portal' readonly='false'  NAME='BASE_REF' BASE_REF=''  expandRL='' uniqueID='SID1510616504616' ><div   class='layout layout-outline layout-outline' id='EXPAND-OUTERFRAME' PARAM_NAME="EXPANDEDSubSectionPrismActionItemLinksB"><div class='collapsible Expanded ' id='EXPAND-PLUSMINUS' name='' aria-live='polite' ><div class='header header-bar clearfix' tabindex=0 role='heading' aria-expanded='true' aria-label='Hide Action' id='RULE_KEY' node_type='HEADER'   onkeydown='expandHeader(this,event,null,true);' onclick="setUserStart(id);expandHeader(this,event);"><div class='header-left' title='Hide Action'><i class='icon icon-openclose'></i></div><div class='header-content'><h2  class='header-title' aria-level='2' id=''>Action</h2><nobr></nobr><span class='header-element header-title-table'><table cellspacing='0' cellpadding='0'><tr><td nowrap='nowrap' class='tdRightStyle'><table cellpadding='0' cellspacing='0' align='right'><tr><span style="display:none;"> <input type=hidden id=SpellChecker value= "Spell Checker" /> <input type=hidden id=More value= "More" /> <input type=hidden id=Edit value= "Edit" /> <input type=hidden id=Revert value="Revert  " /> <input type=hidden id=RevertTo value= "Revert to" /> <input type=hidden id=IgnoreAll value= "Ignore all" /> <input type=hidden id=AddToDictionary value= "Add to Dictionary" /> <input type=hidden id=ChangeAll value= "Change All" /> <input type=hidden id=SpellChecking value= "Spell Checking" /> <input type=hidden id=NoSpellChecker value= "No SpellChecker Available" /> <input type=hidden id=NoSuggestions value= "No Suggestions" /> </span>     <script language="javascript"> var haveActionChoices = false; function initActionChoices () { gStrSpellChecker = document.getElementById("SpellChecker").value; gStrMore = document.getElementById("More").value; gStrEdit = document.getElementById("Edit").value; gStrRevert = document.getElementById("Revert").value; gStrRevertTo = document.getElementById("RevertTo").value; gStrIgnoreAll = document.getElementById("IgnoreAll").value; gStrAddToDictionary = document.getElementById("AddToDictionary").value; gStrChangeAll = document.getElementById("ChangeAll").value; gStrSpellChecking = document.getElementById("SpellChecking").value; gStrNoSpellChecker = document.getElementById("NoSpellChecker").value; gStrNoSuggestions = document.getElementById("NoSuggestions").value; } var gStrSpellChecker = null; var gStrMore = null; var gStrEdit = null; var gStrRevert = null; var gStrRevertTo = null; var gStrIgnoreAll = null; var gStrAddToDictionary = null; var gStrChangeAll = null; var gStrSpellChecking = null; var gStrNoSpellChecker = null; var gStrNoSuggestions = null; </script> <td id='HeaderButtonIconsTDId'><script>try {var gHeaderButtonHTML=document.getElementById("HEADER_BUTTON_HTML");if(!pega.u.d.bModalDialogOpen){document.getElementById('HeaderButtonIconsTDId').innerHTML = gHeaderButtonHTML.innerHTML;}} catch(e) {}</script></td><td><input type="hidden" id="HeaderButtonSectionIndicator" value="SubSectionPrismActionItemLinksB" /></td></tr></table></td></tr></table></span></div><div class='header-right'></div></div></div><div section_index='1' id='EXPAND-INNERDIV' class='layout-body clearfix'  ><div bSimpleLayout='true'   class='content   layout-content-simple_list content-simple_list  ' ><div  style=''  class='content-item content-field item-1   ' STRING_TYPE='field' RESERVE_SPACE='false'><div class='content-inner '><div class='field-item dataValueWrite'><script type="text/javascript">/**/</script><div id='div-menu-1510616504617' style='display:none;'></div><script

  9. On 11/12/2017 at 9:37 AM, acantor said:

    I have learned a lot of your posts over the years, so I am glad to be able to reciprocate! :)

    The technique is not 100% reliable, but considering the range of macro scripting techniques that involve interacting with the user interface, it's pretty good. Inserting short delays may make the technique less apt to fail when web traffic, downloads, and low resources slow down a system.

    Indeed Chrome does work in the same fashion as Firefox and your notes proved to be very helpful for navigating a web page. 

    Following your instructions will allow me to search for a button and then press on it using the Enter or Space key. There are a few instances where I haven't gotten this to work... if there is an element on the screen that is clickable, but not really a button per se, then pressing Enter or Space will not do the trick. I cannot figure this one out. Am I missing something really obvious?

  10. On 6/29/2017 at 8:01 PM, acantor said:

    If you sink enough time and effort into the problem, you may come up with a solution that almost always works. But you gotta love experimenting and tweaking, or you will likely find the experience a miserable drudge!

    I use a combination of techniques, including:

    - Clicking on a "neutral" part of the screen that resets the tab order. Then send tabs/shift tabs to the control.

    - Searching for a pixel colour on a control, or to something near the target, and then tabbing and/or clicking.

    - Searching for text on the screen. Then give the word or phrase focus, and then tab to the target.

    - Searching for text on the screen and then selecting it. Then search for the pixel colour of the selection,and click.

    Some of my Macro Express scripts perform thousands of actions to zero in on a target on a web app, and are almost 100% reliable. But they were labours of love. I was willing to put in the time to get them to work. And some of them are a bit brittle.

    I'm trying to revisit some of the ideas from this post so that I can make my macros run with greater reliability. This post mentions "searching for text on the screen" followed by a way to get to that text using tabs or pixel colors. I like this idea, but I cannot figure out how to implement it. My macros primarily run in Chrome and I could perform a search for specific text using Ctrl+F, but how would I then get to that word? The only method I can think of is to have the mouse move a few pixels at a time until it finds the right color, but I can see this being a pain because of 1) false positives and 2) potentially having to look all over the screen for the right color. To address the former problem, I imagine that there's some extension available to change the highlighted text from orange/yellow (default in chrome) to a more unique color.

     

    Any advice is appreciated.

  11. Thank you for the feedback. I was recently reminiscing about playing games on my old Tandy 2000 and how you would have to calibrate the joystick every time you use it. I used this idea to set specific anchor points from which my mouse will move relative to that point. My thought is that when the elements deviate slightly from where they used to be, I will just have a script (haven't go that this part yet) to quickly change the coordinates of 4-5 anchor points.

    I would have liked to incorporate more tabbing into my macros, but it was not working as I had hoped and this new solution seems fine for the moment.

    I appreciate all the input. 

  12. I use MEP to automate tasks at work. One of the primary apps that my macros run in is a Java program in IE. For some reason, whoever is in charge of maintaining this application periodically makes slight, seemingly useless modifications to the layout of the program and as a result, all of my macros that require a click will be off by a few pixels. Sometimes this makes no difference, but other times it's the difference between clicking on a button or not clicking on a button. Needless to say, it is infuriating because it renders most of macros useless. 

    I've tried to use the 'Get Control' function, but the utility is not able to recognize any buttons in the application that I am using. In addition, sometimes I am not wanting to click on a button at all. 

    Is there anything that you might suggest I think about when addressing this problem?

  13. 20 hours ago, Cory said:

    You might want to create a CSV list of your keyword matches in one column and macro name in another and and repeat with it each time using ASCII File Process. 

    This method worked perfectly! It took me a while to get the hang of using it and truth be told, I am not even that well versed in using arrays either, but I was amazed at how a few lines of code combined with a tab delimited document made this whole thing really easy. I was also worried about the ASCII file process taking too long to and slowing down the macro, but that wasn't an issue either.

    Thanks Cory and others for valuable suggestions. I can see myself using this method for other applications as well.

  14. I am trying to build some logic into my macro that would select a string of text, copy it to the clipboard, and then run a specific macro based on what is stored in the clipboard (or a variable that was set to the clipboard content).

     

    So far, I have created a bunch of code like this:

    If Clipboard contains "brown"

    Variable Set String %macroname% to "brown"

    End If

    Macro Run: %macroname%

     

    This definitely works, but as I have a few thousand macros that could potentially be run, I am hesitant to continue doing it this way. Any ideas on an alternate approach to accomplish the same thing?

  15. One thing that I think is weird is that the background application predictably takes focus or brings itself to the front. For example, when a certain box pops up to prompt the user to enter a value, I will input the value and press enter, but the background window will predictably bring itself to the front, forcing me to alt+tab and the press enter on the pop up box in order to continue the macro process.

     

    While I initially thought that this issue was caused by the background Java app randomly (random to me anyway) wanting focus, now I am thinking that there is something else at the root of the issue... still not sure what that would be, but I feel as though it is fixable somehow.

  16. I read through these posts and am not sure if it helps with my situation... my work recently switched from using a stand-alone application to a similar one that runs as a Java application in IE. I hate it. My macros require a lot of text box displays and user prompts to enter variable values, and even though I have the "always on top" and "keep focus" focus checked, it's like the Java app DEMANDS attention and retakes focus. I should note that the prompt does stay on top, it's just that it loses focus. Very annoying... any ideas on how to change this behavior?

  17.  

    Here is a sample macro that may get you started. (Download this macro by clicking on the filename below.)

    // -----------------------------------
    //   Make choices
    // -----------------------------------
    Multiple Choice Menu: Symptoms
    Clear Variables // Clear the variable array, just in case the Symptoms variable is reused
    Split String "%Symptoms%" on ", " into %SymptomArray%, starting at 1 // Split each choice into a separate element of an array variable
     
    // Loop through each element of the array variable and assemble the output into the Symptoms2 variable
    Repeat Start (Repeat 50 times)
      Variable Set Integer %IdxPlus1% to %Idx%
      Variable Modify Integer %IdxPlus1%: Increment
       
      If Variable %SymptomArray[%Idx%]% Does not Equal "" // If this element of the array is not empty
       
        If Variable %Symptoms2% Equals "" // Is Symptoms2 empty?
          Variable Set String %Symptoms2% to "%SymptomArray[%Idx%]%"
        Else
         
          If Variable %SymptomArray[%IdxPlus1%]% Equals "" // If the next element is blank we know the current element is the last one
          // Handle the last item
            Variable Set String %Symptoms2% to "%Symptoms2% and %SymptomArray[%Idx%]%"
            Repeat Exit // Last item processed, exit the repeat loop
          Else
          // Add this item to the list
            Variable Set String %Symptoms2% to "%Symptoms2%, %SymptomArray[%Idx%]%"
          End If
        End If
      End If
    End Repeat
     
    // -----------------------------------
    //   Display result
    // -----------------------------------
    Text Box Display: Result
    
    

    thank you!

  18. I think I would build the string backward. Assuming you have all these in an array I would first get the upper limit. If there are less than two just join them with a comma. If there are more than combine them backward and on the first iteration combine with comma and "and".

     

     

    I figured left to right might be easier to visualize. But you're correct, right to left is a little simpler.

    Thank you both! very helpful

  19. I am trying to use a multiple choice menu where multiple answers can be selected. I would then like to use these answers to output a phrase that has correct grammar.

     

    For example, if the multiple choice options are A, B, C, X, Y, Z... the output could be something like:

    "The answer is A, B, and C"

    "The answer is Z"

    "The answer is B, X, Y, and Z"

     

    I can't seem to wrap my head around this problem. Any guidance is much appreciated.

  20. The most important thing to know about dates is that they're internally stored as decimal values. 1 = 1/1/1990. And each date is a unit value of one. Time within a day is a decimal amount. EG. 0.5 = noon. So really all you'e wanting to do is set a date value and modify it to remove 90 days. Then compare that date to your date to determine if it's less than it. So create a variable called DateThreshold or something like that. Subtract 90 days from it. Now compare that to the suspect date..

    I am encountering difficulty using my clipboard contents to set a date value. It will not allow me to do this because my clipboard value is recognized as text.

  21. I do not have much experience using dates with MEP. I was a bit confused when looking over the documentation today.

     

    I am trying to create a macro that alerts me if a certain date is within the last 90 days. To accomplish this, I need to highlight some text inside a program (ex: 12/01/2015) and compare it to today's date. I'm not exactly sure what combination of date function(s), variables, clipboard functions I need to get this to work.

     

    Any advice?

     

    Thanks in advance.

  22. Variable Modify String [Option 2 tab] / Save to Clipboard is where that function is "hidden" in ME3.

    Test carefully -- I have sometimes had bad results in pasting via the clipboard. I don't know but what it is a timing issue, like Copy to Clipboard which takes an unpredictable amount of time to complete???

    You can try setting the keyboard delay time which might make text typing more reliable. Generally I have found 30ms to be more than enough.

     

     

     

    There are macro commands to copy to and from the clipboard. Try something like this:

    Variable Set String %Temp% to "This is a test."
    Variable Modify String: Save %Temp% to the clipboard
    

    The Text Type command has an option to "Use Clipboard and Paste Text". By default this is set to "Simulate Keystrokes". Using this option you don't even need to use the Variable Modify String command.

     

    Sometimes I want to keep the text on the clipboard so I have my macro save and restore it, like this:

    Variable Set String %ClipboardSave% from the clipboard contents // Save the content of the clipboard
     
    Variable Set String %Temp% to "This is a test."
    Variable Modify String: Save %Temp% to the clipboard
     
    Variable Modify String: Save %ClipboardSave% to the clipboard // Restore the content of the clipboard
    
    

    Thank you both!

×
×
  • Create New...