koden Posted December 13, 2022 Report Share Posted December 13, 2022 My macro copies a 10 digit number from a list of many different numbers and insert number into a field on a web site. If number is known macro open a new window and thats fine. If number is not known the field will not take it and keeps empty. But macro keeps running and does some wrong things. How do I get the macro to stop if the field is empty after ctrl+v into field has left field empty? Quote Link to comment Share on other sites More sharing options...
koden Posted December 13, 2022 Author Report Share Posted December 13, 2022 I maybe have an idea myself...but not sure how to do it. the website name is always this on the site where my number is pasted into field.. https://test.com/#= If number is not accepted and field therefore empty, website keeps on https://test.com/#= If numer pasted is accepted by website it changes to new window with name https://test.com/#=X where X is a number between 1 and infinite So I assume there must be a function that can read if website name is with or without number and stop macro if no number is located after #= Quote Link to comment Share on other sites More sharing options...
rberq Posted December 13, 2022 Report Share Posted December 13, 2022 Type Alt-d to highlight the URL at the top of the browser window. Then Ctrl-c to copy the highlighted URL text into the clipboard, and check to see if it has changed to the expected value. Quote Link to comment Share on other sites More sharing options...
koden Posted December 14, 2022 Author Report Share Posted December 14, 2022 Yes that was my idea to do. But not sure what controls to do it with and had hoped there was a more simple solution like "if nothing pasted macro stop" 🙂 But that intelligent I don't think it is 🙂 I will look in some of my old macros to find the right way to get the URL checked. Think I used this function years ago. Quote Link to comment Share on other sites More sharing options...
koden Posted December 15, 2022 Author Report Share Posted December 15, 2022 hmm.. can't find out what control to use. I think the easy way must be to check if https://test.com/#= has changed to https://test.com/#=X Where X is any number. If https://test.com/#= has not changed then number is not accepted and macro has to stop. But which variable or command is used for this? Quote Link to comment Share on other sites More sharing options...
rberq Posted December 15, 2022 Report Share Posted December 15, 2022 I don't think you can use controls on a web page. There are no "standard" or "pre-set" variable names -- you make up your own. The following sequence of macro commands are approximately what should work. You may need some Delay commands as the web page changes, to keep the macro from outrunning the screen. Variable Set String %expected_URL% to 'xxxxxx' -- this is the number you expect (hope) to see in the new URL Text Type Alt-d to highlight the actual URL at the top of the browser page Text Type Ctrl-c to copy the highlighted URL text into clipboard Variable Set String [set value from clipboard] -- you can make up any variable name you want, for example %URL_Name% If Variable %URL_Name% Contains %expected_URL% . . . . . . . . Quote Link to comment Share on other sites More sharing options...
koden Posted December 18, 2022 Author Report Share Posted December 18, 2022 Thanks.. If I understand you right, you want me to check on the number after #= The problem is that I don't know the number X after #= It can be any number. can I check on the place after #= ? If location after #= is used or not? OR is it possible to do it as described underneed? paste number to field and if number not known filed will not change. Copy URL and do a check if URL have changed from #= to #=X If not changed from #= to #=X then macro stop. Quote Link to comment Share on other sites More sharing options...
koden Posted December 18, 2022 Author Report Share Posted December 18, 2022 like this? T1 is the number I paste T3 is set at start as #= It's not working and I think I know why. But cant find out how to do it 🙂 Quote Link to comment Share on other sites More sharing options...
koden Posted December 18, 2022 Author Report Share Posted December 18, 2022 hmmmm... maybe to confusing. but can't see how to fix it.... Quote Link to comment Share on other sites More sharing options...
rberq Posted December 18, 2022 Report Share Posted December 18, 2022 Quote Link to comment Share on other sites More sharing options...
koden Posted December 20, 2022 Author Report Share Posted December 20, 2022 thanks... but was not the problem. Still not working alt+d and control c works fine When I try run it with a number that will fail it does not work My check with T3 and T4 is prob. not working. T3 has this set from start: #=_ When number is not known alt+d > ctrl+c > variable set string T4 from clipboard will set T4 with: #=_ If variable T3 and T4 is equal, as it is in this example with wrong namber, macro should stop. It does not. maybe I can't compare text this way as I do? Maybe I should use another metode or variabel function? I remember there was a function that could check content in a variable. maybe check for integer? My URL is: http://test.com/#=_ And when wrong number is used it's stil http://test.com/#=_ When correct number is pasted my url changes to http://test.com/#=X X could be any number and notice that _ changes to X So... something like.. if URL contains a integer keep running. If URL does not contain a integer macro stop I can see you have been involved in several threads about checking variables... just need to find the right solution for me, so that it's not being to complicated. Quote Link to comment Share on other sites More sharing options...
koden Posted December 20, 2022 Author Report Share Posted December 20, 2022 I have search and search... but mot found the right solution or maybe I just did not understand the one I found 🙂 1. Is it possible to look for integer in a string, when there is 30 characters and only one is integer? 2. My URL is always 30 characters and the last character is either underscore or a number Underscore when my pasted number is wrong and a number if my pasted number is correct. My url can be more than 30 characters. It happens if number is 2 or sometimes 3 digits Quote Link to comment Share on other sites More sharing options...
rberq Posted December 20, 2022 Report Share Posted December 20, 2022 I don't understand how it can work if you type <ALT>d< On my PC, typing <ALT>d highlights the URL, then typing the < character causes the entire highlighted URL to be replaced by < and the single character < is loaded into the clipboard. Should have the Sound Beep command before the Macro Stop. Other than that, I can't see where the problem is. For testing, try a Text Box Display just before the compare of T3 with T4. Put some kind of brackets around the displayed variables so you can tell if there are invisible blanks or nulls at beginning or end of the variables. That could make them appear unequal. For example, in the Text Box, display ***%T3%*** ***%T4%*** Quote Link to comment Share on other sites More sharing options...
koden Posted December 21, 2022 Author Report Share Posted December 21, 2022 Ahh... sorry.. I should have wrote: "it did not help removing <". 🙂 Ok if you think this should work I will try again and test as you describe. Quote Link to comment Share on other sites More sharing options...
koden Posted December 21, 2022 Author Report Share Posted December 21, 2022 so testet now timing was the issue.. But I was so focused on when number was not accepted. So I forgot what to do when number is correct. If number is correct it will now just keep on from the blue arrow and thats wrong. If number is right the URL has changed to http://test.com/#=X And it should keep on from the red arrow So it's set up wrong. I nned to check URL at blue arrow and if URL is http://test.com/#=_ Then macro stop If URL is http://test.com/#=X Then go on from RED arrow. But can't find out how to set that together in the macro 🙂 Quote Link to comment Share on other sites More sharing options...
rberq Posted December 21, 2022 Report Share Posted December 21, 2022 The macro logic looks correct to me. Whether it stops or continues depends on the values of T3 and T4 when the "IF" command. That's why I suggested inserting a Text Box Display before the "IF", to determine exactly what the variables contain at that point. How soon does the screen change after the macro types T1 and ENTER? Maybe you need a delay longer than 1000ms at that point, to make sure the application has had enough time to change the URL when the number is correct. Quote Link to comment Share on other sites More sharing options...
koden Posted December 21, 2022 Author Report Share Posted December 21, 2022 I have used text to see what happens. So just before "if variable T4 = T3" I have a text document where I paste T3 and T4 The result was T3: /#h=_ T4: /#h=1 So it's working now... problem WAS when it returns to webpage the URL is still highlighted and macro is in wrong place. But that is solved with another TAB command. At same time I minimized some delays, so that macro is faster than before. So thanks for all your help... much appreciated 🙂 Quote Link to comment Share on other sites More sharing options...
rberq Posted December 21, 2022 Report Share Posted December 21, 2022 A learning experience. Glad it is working now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.