I am developing a system to use KBM to facilitate gmail workflow in chrome, and against all odds, the results are quite good. I will be posting my gmail project on this site as soon as I iron out a few problems.
In lieu of multiple inboxes or google dictated categories (updates, promotions, etc), I create my own categories using gmail search syntax.
In Gmail/Chrome I can access the search field using / and then type my search string, then Enter the result being equivalent to a custom category.
For example, let's take the 3 search strings below:
1- from:(NYTimes OR WSJ OR Sigma OR ScientificAmerican) in:inbox
2- from:(NCBI OR NIH or Anderson) in:inbox
3- from:(Tony OR Robert OR George) in:inbox
I can easily write a macro to type / (which puts the cursor in the search box) → paste a search string → Enter to trigger the corresponding search in the inbox, and just as easily write 3 macros: one for each search string.
What I would like to achieve is some way to create an endless loop (using the Repeat or For Each actions ?) whereby I would type a hotkey like Shift-Cmd-8 which would trigger search 1, then search 2, then 3, then back to 1 , 2, 3 etc (I would click the hotkey each time)
I think this should do the trick. Remember the Switch/Case action we recently covered in a different thread? Here's another way you can use it that lets you do everything you describe in a single macro:
As you can see, the switch checks a variable to know which search string to use, and the subsequent action after inputting the string changes the variable each time it's run, looping from 1 to 2 to 3 to 1 again. It should be clear how it works in practice.
You'll also notice I used the "Set Chrome Field to to Text" action instead of typing / and pasting, as it's both quicker and more reliable. You may need to change the action to use Chrome instead of Brave Browser if you don't use the latter, and you may also need to adjust the path for the field used in case this one doesn't work. Fortunately, the former is easily done by clicking here:
Thanks very much Gabe for the macro and the explanations.
I reviewed our previous discussion on the same topic. It takes me a while to digest !
1- I used the Chrome Set Field. Everything works except that the set field action only places the text in the search field but does not trigger the search. I tried to add an Enter keystroke action after the set field action to no avail because the cursor is not located in the set field action.
In the meantime, I replaced the set field action with a rather primitive approach which does the following in sequence:
a- type / which puts the cursor in the gmail search box
b- insert by pasting the search string and puts the cursor at the end of the line
c- type Enter
My solution works, but I would prefer yours which is more elegant if I can find a solution to the Enter (trigger search) issue. I try to emulate the habits of the greats of this forum.
2-thank you for the explanations about set browser field. Be it fields or radio buttons, do you have any way to determine which field or radio button as per ScreenCapture below (2) corresponds to what on the screen, or is it via trial and error ?
By using fields, would you be able for example to click the checkbox as per (3). I am asking for didactic purposes, not because I actually want to write a macro to check that box (which can be accessed with a simple shortcut: * → a
I sometimes use forms with a gazillion fields and have a lot of difficulty identifying the proper radio buttons to press..
3- I have a question about macro groups and palettes. Normally a group or palette is available in some or all applications. Is it conceivable to configure a palette to only be available in a specific Chrome (or Safari) tab like Gmail, Google Calendar ?
This can be very easy, or very hard, depending on the actual web page.
To analyze, I would need the URL of the web page of interest.
Having said that, taking a quicklook at my gmail page, I found this works for me:
var searchElem = document.querySelector('input[aria-label="Search mail"]');
searchElem.value = 'subject:(update primary email address)';
var searchBtn = document.querySelector('button[aria-label="Search Mail"]');
You can change the "update primary email address" in this line: searchElem.value = 'subject:(update primary email address)'
to be whatever Subject text you would like to search for.
Yes, it is. The best way I've found requires making a new macro group, and it depends on unique text being present in any page on the site, but assuming the latter exits, it's really quite easy. To make one for Gmail, for example, you would just need to set up the group like this:
thank you very much @gglick and @JMichaelTX . I notice a bizarre behaviour. You use Brave, I use Chrome which is fine.
I found the solution. It seems that you can't just change to Chrome with the gear. Safari remains unchanged. So I inserted a new Chrome Field to Text and all is fine.
Perhaps a bug ?
thanks very much
I'm guessing it has something to do with the fact that, when you don't have a "custom" browser installed on your Mac, and you import a macro or macro action that references one, KM defaults to Safari for these actions. The easiest thing to do may just be the solution you found, i.e. insert a new action, but it does seem strange that the action looked like it had Chrome properly selected and still insisted on defaulting to Safari; maybe it is a bug in that case.
At any rate, did our posts answer your latest questions sufficiently? Does the new version of my macro work? Have you been able to create a macro group whose macros only work on certain sites?
the answer is that the macro works perfectly and I have learned a lot with your explanation about chrome fields. I have already written a few macros today thanks to you explanation. It's now crystal clear.
thanks VERY much !
It has made me realize that it is necessary to use 2 browsers because I found multiple web pages for which it was impossible to identify the clickable link with Chrome but straightforward with Safari. In addition, Safari has more clickable buttons like print, and other advantages, like a better reading mode.
So the question is how to use a KBM macro so Cmd-Click on a Link opens in Chrome and Cmd-Opt Click opens it in Safari, with perhaps the option that if I press the shift key the link is opened in the background.
I have a feeling this might have been better suited for its own topic, but that aside, I'm glad to hear your proficiency has advanced.
To answer your latest question, the current version of KM has no way of using Cmd-Click for a trigger with Apple input devices, i.e. the Magic Mouse or Magic Trackpad, but if you use a third-party peripheral, you can do so with the USB Device Key trigger. If you do use an Apple input device, and have access to BetterTouchTool, then you can use a BetterTouchTool "normal mouse" trigger that runs a KM macro, like so:
So I'll leave that as an exercise for you to figure out how to make that work. If you use a third-party peripheral, you could try adding new cases to the Switch/Case action in this macro that choose different actions depending on whether Shift is present in the %TriggerValue% token or not, or, if you use BTT with Apple peripherals, you could duplicate this macro to make a new one to use with a BTT Shift-Cmd-Click trigger.
I'm unable to locate LeftClick in the list of BTT triggers (I have a magic trackpad, so I do have a device)
I want to create another version of the macro whereby if I am in Mail, Cmd-Click will open the link in Chrome and Cmd-Opt-Click will open it in Safari. Is this realistic (just replace application contains with Mail?). Before going ahead, I just want to make sure that this makes sense.
Incidentally, just a thought, but assuming you have Chrome set to your default browser, do you really need two macros, since regular clicking on a link in Mail will open it in Chrome by default? If Chrome is your default, then I would just make a Cmd-Click one for opening the link in Safari.
I think that there is a misunderstanding. When I changed by default browser to safari, links in mail now open in the background, which did not happen when chrome was the default.
I spent the last hour trying to understand why there is no 'Open With ...' in my mail context menu. I checked the services menu, forums on the Internet, etc