In one of my macros, I need that KM selects an item in a list in a preference panel of OSX. I have found an action for clicking on a button, or another for selecting a menu item but nothing for selecting a list item that has not been created by KM, and that lives in a window.
I use click on a image action but it is far from reliable (for reasons that I do not really understand).
I could not find any tips by searching in these forums, sor probably I am missing something trivial.
What am I missing?
Hi Murat. Clicking at found image has a fuzziness slider. Sometimes you have to move that slider to the left to ensure a unique match. Or try selecting one of the other options other than Unique. Also, sometimes purposefully selecting not just the menu you need but some of the adjacent text and blank areas will help you get a better hit. Then you'll need to change the "Relative to" and the X and Y values for where to click. I can be more specific if you let me know which combo list box are you referring to and what value do you want to select?
Hello Richard and thank you!
Yes, I have already tried a bit with the fuzziness slider but I have observed does not seem to solve my problem.
The problem is strange because when I execute the macro alone, it finds and clicks the image but when I execute it from an IFELSE block, it cannot find it. I have other actions based on other images corresponding to other combo elements, and they seem to work fine. There must be something else I think. I will continue to try to locate the problem.
By the way, I am writing these macros because I have not been able to find an action for rotating the external screen, so I am trying to replace many clicks that are necessary to go through in the Settings app by a macro set.
In fact, KM already clicks on the item 270° when it is the active one and opens the combo box, then looks for the other option "Standard" in order to switch the orientation of the screen to Normal. Since I have checked the Display option, I can see it to recognize the 270°, click on it, pause two seconds for the combo to open, and not be able to find the Standard option that appears as the top item in the combo box, and click on it as I am trying to do. So, the focus should already be placed on the combo box and the window that contains it at that stage normally. I have tried other options anyway like main screen and internal screen.
It just stops when it needs to click on the Standard image
Sorry, I do not really understand what you suggest. When I switch back to KM for executing this macro step, the combo box gets closed I think because when I switch back to the Settings screen, it is closed. The previous clicks on the macro are the ones that bring Settings screen on the front, and open the combo box, so it stays open for a second click.
If you have enough screen space you could have both KM and the settings pane open at same time (like side by side with settings in the foreground) and this way you would be able to see KM’s feedback while you’re clicking on the drop down menu.
I have also had better success using the Best option instead of Unique when working with found images.
If you were able to post your macro we might be able to take a closer look at it and offer some more tips too!
Thank you very much Richard!
Very strange really, after having clicked on 270°, KM aborts the macro instead of typing S, while, after it has aborted, Standard is indeed selected as you have suggested by typing S. I have also tried with UP+UP+UP but no chance either. I have tried to reactivate the window, bring the front window to the front (strange idea but why not ), no chance either. It seems that after having clicked on 270° and opened the combo box, KM lose the focus on the combo box, but I do not understand why.
I think this is the problem, not the ability to find the image because I look for Standard in the alternative branch (if the current option is not 270°), and it works for switching from Standard to 270°.
It tells in the Logs (I cannot copy the notification box): Mouse no unique image found. Macro “Switch orientation Dell” cancelled (while executing Move and Click at (0,0) from the Center of the Found Image).
Which was strange now that I have replaced a click action by typing the S key, but when I check "Select last aborted action" from the view menu, it brings me to a click image action that is in the false part of the test (Is there an image of 270° on the main screen? and There is one, I can see it!).
Some something more strange is going on during the execution of that macro... It does the job for switching from 270° to Standard because in this case my condition is indeed false, while when switching from 270° to standard, it should not be false because 270° is the selected option in the combo and visible on the screen.
I am at lost at that stage....
Here's your macro back, with a couple of slight adjustments to the first few actions only (everything I adjusted is indicated with red notes).
Anytime you need to click on a found image, it's good to add a pause until said image is found action before the click action instead of an arbitrary number. This is because sometimes it can take longer than others for the image to appear (for a variety of reasons) and your click action may fail. So here are the adjustments I made:
I adjusted the first few actions to add a pause until the image is found.
I adjusted the fuzziness just a hair.
I also selected best in the click action instead of unique.
I also disabled your variable that sets screen count because the switch action can read that token directly without the need of a variable.
Replicate those things with the rest of the image actions and see if it improves any.
PS. This is likely doable with just AppleScript. It looks like you are at least somewhat familiar with it since I see a script at the beginning of the macro. If you're interested, I'll share an AppleScript I wrote to toggle Siri on/off so you can see a little more about how to use it to interface with the systems preferences panes.
I am probably missing something here because I can only see the Screens options in the View menu (respectively Moniteurs and Présentation in French), and not the sub items and panels of that I need to change the screen orientation.
Thank you Chris. Unfortunately, I have already tried all the part of my macro that you have modified was already working without any problem. As I have explained, the hiccups start at the test on 270° or not as the selected and visible option in the combo.
I would have liked to understand what is happening here because I could meet this problem in other contexts but I think I will stop wasting your time and mine, and continue the aborted macro by clicking myself on the Standard item. The other case is already handled by the macro it seems, because it does not seem to see the 270° item when it is the initially active one, and never enters this part of the IFELSE block... But, strangely enough, it can find it in the ELSE branch without any problem....
After some more experiments, I see that the Fuziness slider has a hair-triggering effect, I either get false positives or false negatives depending if I put it slightly lower or higher.
Probably when 270° is the active item, the image does not contain enough information to be located by KM in a useful way. I think I can stop now.
I will check if I can set the external screen orientation directly with AppleScript, I do not know much about the dictionary of the Settings app.