|
Post by [John on May 12, 2018 9:59:36 GMT
How do I have a web page button recognised.
On a web page there is a button which becomes active when a text box field is open.
Text is entered into the box.
The button needs to be clicked to send the text.
The issue is if the button is not activate then the button should not be clicked and the.
Can you pleas assist with the script:
Summary:
1. Click - location XY
2. Click - location XY
3. Text box open
3.1. Text auto type.
3.2. SEND button active and clicked.
3.3. Macro Stop.
4. If text box and text not typed go to line 1.
|
|
|
Post by Steve on May 13, 2018 5:52:19 GMT
Hi John, I think I understand. This can be done a couple of ways. The best way to work with webpages using MMM is by directing input via TABs. For your particular situation this might not work. To write the macro exactly how you need it I would need to know a lot more about exactly what you are doing and how the webpage works. So I am going to make some assumptions. One assumption is that the the SEND button is 1 tab stop from the text box. For this example I have used a Google.com which is running in the firefox web browser. 1 | RUN ACTION | | | | DEFINE STRING VARIABLE | %STRING%::Mini Mouse Macro Test 2 | IF | PROCESS NAME | firefox | EXIST | SELECT WINDOW BY NAME | Google - Mozilla Firefox | ELSE | 8 | RUN ACTION | | | | STOP 3 | X | X | 1000 | Keypress %STRING% 4 | X | X | 1000 | Keypress TAB 5 | X | X | 1000 | Keypress ENTER
Line 1 defines the text string you want to send. This example is 'Mini Mouse Macro Test'. Line 2 finds the firefox process and then selects the tab which has www.google.com open. If the firefox browser is not running, or Google.com is not open in the current tab, this will fail Line 3 types the string into the text box Line 4 uses the TAB key to move to the 'Send' button Line 5 presses ENTER on the 'Send' button. You said "4. If text box and text not typed go to line 1."This is slightly more complicated. To determine if the 'SEND' worked you will need some MMM conditions that can detect the change from the webpage. This all depends on what the webpage gives us in reply to a successful 'SEND'. First lets assume it redirects to a different webpage. Going off the previous example, lets assume the new tab name after the 'SEND' is successful is 'Mini Mouse Macro Test - Google Search - Mozilla Firefox'. We add lines 6 and 7 to the macro: 6 | RUN ACTION | | | | WAIT SECONDS | 5 7 | IF NOT | WINDOW TITLE | Mini Mouse Macro Test - Google Search - Mozilla Firefox | EXIST | GOTO MACRO LINE | 1
Line 6 waits 5 seconds for the webpage to load correctly Line 7 performs the check we need for the new webpage name. If the tab title in the browser does not exist then GOTO line 1 and loop the macro Now this solution works ok if we can detect the webpage tab names. If your webpage does not change tab names then this is not going to work. Lets assume that instead something on the webpage changes color after a successful send. We can use MMM to detect the color change and act on that. In this example I use the color of the days Google Doodle; the color of the primary google graphic.
6 | RUN ACTION | | | | WAIT SECONDS | 5 7 | IF | PIXEL COLOR | Color [R=33, G=181, B=24]::At Location [X:858 Y:285] | IS THE SAME | GOTO MACRO LINE | 1 | ELSE | 8 | IF | PIXEL COLOR | Color [R=33, G=181, B=24]::At Location [X:858 Y:285] | IS NOT THE SAME | STOP
Line 6 waits 5 seconds for the webpage to load correctly Line 7 looks looks to match a pixel color [R=33, G=181, B=24] (a green color) for a graphic on the page at mouse X position 858 and mouse Y position 285. If the color is the same, then we can assume that the page did not change, so GOTO line 1 and loop. Or ELSE if the pixel color did change then STOP the macro. Another option all together is to use mouse clicks as a hard action for the webpage instead of TABs. I hope this helps. Regards, Steve.
|
|