Chrome alternative for commands 'CLICK' and 'imacros://run/'

Discussions and Tech Support related to the iMacros Google Chrome extension.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Chrome alternative for commands 'CLICK' and 'imacros://run/'

by adp1 on Sat Nov 05, 2016 2:26 pm

Linux Mint 17.2
Chrome 54.0.2840.90 (64-bit)
iMacros VERSION BUILD=844 RECORDER=CR

I started a thread a couple of days ago in the Firefox section of this site asking for help with some macros I was working on.

The purpose of these macros was to check a site for a specific keyword and this check for the keyword will keep looping until the keyword has been found. A button would be pressed each time the loop occurs to refresh the dynamic content on the page. When the keyword is found on the page a link on the page is clicked on. This link (link 1) contains different text each time. After 'link1' has been clicked on, an audio file is played and a new webpage opens up in a new tab, where any links matching the wildcards will be opened automatically. At this point, the macro function ends.

I was also using another extension in Firefox which monitored the keyword, and when the word in that position changed to the keyword the Firefox extension would bring this tab into focus. This was very handy because even if I was working on a different program or browser, when the keyword was found, the Firefox tab would be immediately made the active window, and be brought into focus. This wasn't possible using a macro alone.

Unfortunately, I have been having various problems while opening Google sheets in Firefox, with sheets either lagging or script errors appearing. I have tried various configurations and versions of Firefox on Linux Mint. When I open the same sheets in Chrome they run completely smooth and without any script errors, so I have decided to install the iMacros extension on Chrome instead.

I am aware of a couple of ways where the Firefox iMacro code will not function in Chrome. One is the 'CLICK X=199 Y=10' command this CLICK command does not exist, but I have been reading about the 'EVENTS TYPE=CLICK' command which seems to have been introduced for Chrome recently and I have been trying to get this command to work with some X and Y coordinates, similar to how to 'CLICK X=199 Y=10' command that I was using previously in Firefox.

The one function that doesn't work is the 'imacros://run/' command to load a macro from within a macro as it seems that macros are stored differently when using iMacros for Chrome. In the iMacros panel I have right clicked on the macro containing this command and have selected 'Convert', so the macro is now listed in my Chrome bookmarks. What I don't know how to do is to load a Chrome bookmark from within a macro. The 'imacros://run/' command worked well in Firefox to load another macro, but I am not sure how to do this in Chrome.

The macros work well in Chrome apart from these two functions.

Here is the Firefox code (thanks to iimfun for the help with this in the Firefox thread). These two macros were stored in a folder called 'Searching'.
1_search_keyword.iim (working correctly with Firefox 49.0.2, iMacros VERSION BUILD=9030808 RECORDER=FX)
Code: Select all
SET !EXTRACT_TEST_POPUP NO
SET !LOOP -99999999999

SET searchKw "Invited"
SET nextMacro imacros://run/?m=Searching/2_open_link_wildcard.iim

' (refresh_dynamic_content)
TAB T=1
TAG POS=1 TYPE=BUTTON ATTR=TXT:
WAIT SECONDS=5

' (search_keyword)
SET !ERRORIGNORE YES
TAG POS=1 TYPE=* ATTR=TXT:*{{searchKw}}* EXTRACT=TXT
SET !ERRORIGNORE NO

SET nextMacro EVAL("'{{!EXTRACT}}'.match(/{{searchKw}}/) ? '{{nextMacro}}' : 'javascript: void(0);';")
URL GOTO={{nextMacro}}
WAIT SECONDS=10

2_open_links.iim (working correctly with Firefox 49.0.2, iMacros VERSION BUILD=9030808 RECORDER=FX)
Code: Select all
' (click_link_left)
TAB T=1
CLICK X=451 Y=104

' (open_link_wildcard)
TAG POS=1 TYPE=A ATTR=TXT:*docs.google.com*

In the '2_open_wildcard_links' macro, I tried the code 'EVENTS TYPE=CLICK CLICK="(199,10)" to try to make macro click on 'link1' when the keyword 'Invited' is found on the page, but this didn't work correctly. The macro opens a new tab from a link in the middle of the webpage, but 'link1' is not clicked on. As mentioned above also, I am not sure how to open a macro from within a macro in Chrome. The macro has been converted as a bookmark.

I would appreciate any help with getting these two macros fixed so they work correctly in Chrome. I would also appreciate if anyone knows how a macro could bring a Chrome tab into focus when the keyword has been found. This would be helpful if I was working in a different Chrome tab and didn't see/hear that the keyword had been found.
Last edited by adp1 on Sat May 20, 2017 5:30 pm, edited 4 times in total.
adp1
 
Posts: 9
Joined: Thu Nov 03, 2016 4:41 pm

Re: Chrome alternative for commands 'CLICK' and 'imacros://r

by iimfun on Mon Nov 07, 2016 12:50 am

adp1 wrote:I am not sure how to open a macro from within a macro in Chrome.

Below is my idea for that. The code is in one macro now.
Code: Select all
' 2_open_links.iim
SET R "\\n"
' (open_link1)
SET M2 "TAB OPEN {{R}}"
ADD M2 "TAB T=2 {{R}}"
' notification
ADD M2 "SET N EVAL(\"alert(\'KEYWORD FOUND\');\") {{R}}"
'ADD M2 "URL GOTO=file:///home/adp/Downloads/16864380.mp3 {{R}}"
ADD M2 "TAB T=1 {{R}}"
'ADD M2 "CLICK X=199 Y=10 {{R}}"

' (open_wildcard_links)
ADD M2 "SET !ERRORIGNORE YES {{R}}"
ADD M2 "SET !TIMEOUT_STEP 1 {{R}}"
ADD M2 "FRAME F=2 {{R}}"
ADD M2 "TAB T=1 {{R}}"
ADD M2 "TAG POS=1 TYPE=A ATTR=TXT:*spreadsheets* {{R}}"
ADD M2 "TAB T=1 {{R}}"
ADD M2 "TAG POS=2 TYPE=A ATTR=TXT:*goo.gl* {{R}}"

SET M2 EVAL("btoa(encodeURIComponent('{{M2}}'));")
SET nextMacro "javascript:(function() {try{var e_m64 = "
ADD nextMacro  "\"{{M2}}\""
ADD nextMacro  ", n64 = \"Ml9vcGVuX2xpbmtzLmlpbQ==\"; if(!/^(?:chrome|https?|file)/.test(location)){alert('iMacros: Open webpage to run a macro.');return;}var macro = {}; macro.source = decodeURIComponent(atob(e_m64));macro.name = decodeURIComponent(atob(n64));var evt = document.createEvent(\"CustomEvent\");evt.initCustomEvent(\"iMacrosRunMacro\", true, true, macro);window.dispatchEvent(evt);}catch(e){alert('iMacros Bookmarklet error: '+e.toString());}}) ();"


' 1_search_keyword.iim
SET !EXTRACT_TEST_POPUP NO
SET !LOOP -99999999999
SET searchKw "Invited"

' (refresh_dynamic_content)
TAB T=1
TAG POS=1 TYPE=BUTTON ATTR=TXT:
WAIT SECONDS=2

' (search_keyword)
SET !ERRORIGNORE YES
TAG POS=1 TYPE=* ATTR=TXT:{{searchKw}} EXTRACT=TXT
SET !ERRORIGNORE NO

SET !TIMEOUT_PAGE 1
SET nextMacro EVAL("'{{!EXTRACT}}'.match(/{{searchKw}}/) ? '{{nextMacro}}' : 'javascript: void(0);';")
URL GOTO={{nextMacro}}
WAIT SECONDS=7

As to clicking on the 'link1', it's impossible to give some good advices not seeing the html code of your web page.
Although you can try relative positioning like this
Code: Select all
TAG POS=1 TYPE=* ATTR=TXT:{{searchKw}} EXTRACT=TXT
TAG POS=R-1 TYPE=A ATTR=*
iimfun
 
Posts: 225
Joined: Tue Jul 19, 2016 6:06 am

Re: Chrome alternative for commands 'CLICK' and 'imacros://r

by adp1 on Mon Nov 07, 2016 9:21 am

Thanks for the code.

Everything is now working well. I got the clicking of 'link1' working using relative positioning.
Last edited by adp1 on Sun Nov 27, 2016 5:50 pm, edited 1 time in total.
adp1
 
Posts: 9
Joined: Thu Nov 03, 2016 4:41 pm

Re: Chrome alternative for commands 'CLICK' and 'imacros://r

by adp1 on Tue Nov 08, 2016 6:15 pm

@iimfun

I have come across a problem and I wonder if you would be able to help.

Whenever the code ''ADD M2 "FRAME F=2 {{R}}" loads, there is always a delay of about 5-6 seconds while the macro stays on the FRAME command before it checks the page for all the keywords in links (spreadsheets, goo.gl and bit.ly). However, after this delay period, the macro does check for all keywords at the same time and then open the pages.

I have tried using the macro without using the 'FRAME' command, and tried using the 'ADD M2 "SET !ERRORIGNORE YES {{R}}" before each search for a link with a keyword, but when I do this, the macro simply skips the first keyword search after this command and moves onto the next search (even though the keyword is present on the page)

In the code below, even though the keyword 'spreadsheets' exists in a link on the page, the macro just skips this search

Code: Select all
ADD M2 "SET !ERRORIGNORE YES {{R}}"
ADD M2 "TAB T=1 {{R}}"
ADD M2 "TAG POS=1 TYPE=A ATTR=TXT:*spreadsheets* {{R}}"

Is there any way the macro can search for all three keywords, without there being a 5-6 second delay waiting for the 'FRAME' command to load?. Sometimes there are also *multiple* links on the webpage with the same keyword, i.e. 2 x goo.gl links.

Because of the purpose of this macro, ideally I need the macro search for all three keywords to take place instantly (and at the same time) so that the macro can open the links quickly and I can enter my details onto any spreadsheets (there are limited spaces available for testers on the spreadsheet, and so every second counts). I have tried experimenting with !TIMEOUT and !TIMEOUT_STEP to try and reduce this frame loading time but that isn't working.

Thanks
Last edited by adp1 on Sun Nov 27, 2016 6:09 pm, edited 2 times in total.
adp1
 
Posts: 9
Joined: Thu Nov 03, 2016 4:41 pm

Re: Chrome alternative for commands 'CLICK' and 'imacros://r

by iimfun on Wed Nov 09, 2016 1:41 am

adp1 wrote:Is there any way the macro can search for all three keywords (spreadsheets, goo.gl and bit.ly) without there being a 5-6 second delay waiting for the 'FRAME' command to load?

I really don't know why you use the 'FRAME F=2' command. It seems to do nothing. However you can minimize the delay like so
Code: Select all
SET !TIMEOUT_STEP 1
FRAME F=2

adp1 wrote:Sometimes there are also *multiple* links on the webpage with the same keyword, i.e. 2 x goo.gl links.

So try the following code
Code: Select all
SET !ERRORIGNORE YES
TAB T=1
TAG POS=1 TYPE=A ATTR=TXT:*spreadsheets*
TAB T=1
TAG POS=2 TYPE=A ATTR=TXT:*spreadsheets*
' etc.
TAB T=1
TAG POS=1 TYPE=A ATTR=TXT:*goo.gl*
TAB T=1
TAG POS=2 TYPE=A ATTR=TXT:*goo.gl*
' etc.
TAB T=1
TAG POS=1 TYPE=A ATTR=TXT:*bit.ly*
TAB T=2
TAG POS=1 TYPE=A ATTR=TXT:*bit.ly*
etc.

Of course you have to add the structure: "ADD M2 ... {{R}}".
Besides I often can try and suggest more original solutions, but have very limited time for free helping.
iimfun
 
Posts: 225
Joined: Tue Jul 19, 2016 6:06 am

Re: Chrome alternative for commands 'CLICK' and 'imacros://r

by adp1 on Wed Nov 09, 2016 4:07 am

Thank you for your help and for giving of your time. I appreciate that you must be busy.

I figured it out in the end and I don't know why I hadn't seen it before.. tiredness? :-)

I discovered the problem this morning. Maybe looking at code with fresh eyes helps. The dynamic content hadn't loaded completely by the time the keyword search was taking place, hence finding no results. I added in a 'WAIT SECONDS' command and that solved the problem.

Yeh, you're right about the FRAME command. I wasn't using it originally, and I must have seen it online and thought about giving it a try. It seemed to be only way the macro would check all three keywords (I hadn't realised that the 'actual' problem was with the dynamic content not having loaded, so all the FRAME command was really doing was giving time for the content to load). It is removed now and everything works fine.
Last edited by adp1 on Sun Nov 27, 2016 5:51 pm, edited 1 time in total.
adp1
 
Posts: 9
Joined: Thu Nov 03, 2016 4:41 pm

Re: Chrome alternative for commands 'CLICK' and 'imacros://r

by iimfun on Thu Nov 10, 2016 12:45 am

@adp1,

I just read your reply attentively. Yes, the problem is likely to be specific to iMacros for Chrome only and arises from these two lines
Code: Select all
' ...
SET !ERRORIGNORE YES
' ...
TAG POS=R-1 TYPE=A ATTR=*
' ...

So I would advise a macro without the 'WAIT' command but if it works fine, I won't do.
iimfun
 
Posts: 225
Joined: Tue Jul 19, 2016 6:06 am


Return to iMacros for Chrome

Who is online

Users browsing this forum: No registered users and 3 guests

-->