I have this macro I use in Safari:
search history.kmmacros (25.6 KB)
It works well. But I wish I could make a switch case there. If
Show All History menu item exists, then activate it and do
cmd + F search. If not, then do
Hide History and don't do
cmd + F search after.
Can I do this?
Unless I'm missing something it doesn't appear that Switch/Case has any way to determine a given menu item's state, so it looks like you'd need to rely on If Then Else instead:
search history.kmmacros (4.0 KB)
Thank you @gglick
Although strangely, my original macro works better than yours. The if cases break and do nothing sometimes.
Does it? That's strange; your original version is faster, but reliability-wise it appears to work fine me. The only issue I noticed was that sometimes the Find field wouldn't always be selected by the ⌘F action, and adding a Pause Until action seems to fix it as long as you're not rapidly flipping back and forth between the two views:search history.kmmacros (5.7 KB)
I settled to use my original macro. I actually works without any defects. The if cases are indeed noticeably slow.
Luckily cmd + f nearly never triggers when going from history mode back to web page so it works.
You can speed up testing for menu items greatly by specifying the complete path to the item.