Easier access to certain functions

OK, in the list of shortcuts that @mwra provided, as far as I can see, there is none for ‘Add key attributes’, which is what you do by clicking on the ‘+’ button. What I was aiming to get is a faster way to add specific key attributes for the particular note I’m working on at a given time.

I have various user attributes I have created that allow me to introduce metadata in my notes in a very similar way to what I see you do (Eg your link to ‘How to use the Attribute Browser’ ). So, I wanted to create macros that introduced the desired values for specific key attributes without having to use the mouse. Many times I really don’t know what particular key attributes I’m going to use in a note. The need for one or the other emerges as the note acquires its content and I analyze it.

As I’m writing or after I paste content from some source, I decide this note is related to a particular subject matter or it belongs to a particular class of notes in a classification that I have created, or whatever. My metadata for notes can be quite rich and so it is rather cumbersome to have to use the mouse, find the particular type of key attribute I need, introduce the value and then go back to writing on the note at the point where I left it.

The beauty of KM is that all this can be automatized and associated to a single keyboard shortcut. Alas, some things are a lot harder to record or program than others and clicking on this ‘+’ button is proving to be a bit of a challenge for KM.

JM

As I said in the other message it works better with some things than with others. Basically KM has a harder time with anything that involves recording movements with the mouse and clicking on a small button because that requires encoding specific space coordinates relative to the measures of the app window. Since the window size and shape can change and the screens of different computers vary in different ways, this makes these kinds of macros a bit harder to develop and to get to work.

For me it was a pretty laborious process to get it to work in one of my computers but when I tried to adapt the macro for my laptop it fails.

JM

Using UIBrowser v2.7.0, this AppleScript will click the KA ‘+’ button in the (front if several) window if Tinderbox - testing in AppleScript Debugger v.7.0.3 on Tinderbox v7.5.4:

activate application "Tinderbox 7"
tell application "System Events"
   tell process "Tinderbox"
      click button "+"  of group 1 of splitter group 1 of front window 
   end tell
end tell

OK, I’m not very familiar with KM, but did manage to add the above to a KM action and get the same result. Perhaps someone better versed in KM use can add the most suitable KM macro configuration for using the above script via a custom shortcut.

Great! Thanks @mwra! I’m definitely getting there! I used KM to test whether it would work with the script you posted and it does. So, here is what I got:

If you notice, right after executing the script which clicks on the “+” button, KM inserts the name of the particular key attribute I’m interested in and that allows TB to select that particular attribute for which I want to introduce the value.

But here comes the next part of the problem for which now I see there can be a satisfactory solution (I still don’t know which one, though). The next screenshot shows the state of TB after executing the KM macro above. What needs to happen next is that the cursor has to be placed in the field where the specific value of the key attribute has to be written so that KM can introduce it there. The problem is that in order to do that, you need to use the mouse again. Unless, of course, that can be done using a similar script to the one you posted or via a keyboard shortcut.

image

Getting to this stage is already pretty helpful because it saves me quite a few steps. As I said, my goal is, however, to automatize the introduction of a selection of values for different key attributes that I use frequently by building different little macros that that will carry out the whole process automatically and quickly return me to the exact spot in the text of the note where I was working. This would be a huge improvement in productivity for me given my particular use of TB and it saves me from constant distractions. If I’m too busy and pressed for time, I usually tend not to introduce metadata (via key attributes) in my notes because in those particular times the process feels too cumbersome and distracting. Later I regret not having devoted enough time and effort to introduce the necessary tags because it becomes more difficult to locate the notes I’m looking for.

So, now, I would only need to find out how to do via script (or keyboard shortcut) the equivalent of introducing the cursor in the key attribute field and the equivalent of introducing the cursor in the main text field of the note. The rest (typing the specific values in the relevant fields and going back to the specific point in the text of the note where I was) can easily be done by KM.

JM

This seems like an awful lot of work. I don’t understand why you need to manually add the same attribute ($KeyWords) over and over to your notes?

Isn’t it simpler to create a prototype whose sole key attribute is $KeyWords. Or to put $KeyWords at the top of the prototype’s KA list. Then create notes in a container whose OnAdd action is $Prototype='myPrototype'. Finally when you have created a note in that container then option tab (⌥⇥) to switch from the Outline to the Text pane. Option tab (⌥⇥) again to highlight the first attributed in the KA list (which will be $KeyWords because of the prototype that the OnAdd action assigned). Then press return and start typing the values of into $KeyWords.

No criticism intended here, but fiddling with scripts and KM etc., seems to be about creating mouse-avoidance automation to replace what Tinderbox already does.

(I’m using here Tinderbox 7.5.4 which is the most recent public release of the software.)

Good. The KA table is rendered from a Set-type attribute $KeyAttributes. Note: a Set not a List as Sets automatically de-dupe inputs. So we need to iterate the list of attribute names in column 1 of the KA table…

First, whilst the code below does work - sort of, at least for Boolean attributes, it is based on inspection of the Tinderbox UI with external rules. If, for whatever reason, ongoing changes to app mean the KA table is significantly re-coded then don’t be surprised if this approach

set myInput to "Opacity"
set myValue to "50"
set myInput2 to "NeverComposite"
set myValue2 to "0"

activate application "Tinderbox 7"
tell application "System Events"
	tell process "Tinderbox"
		tell table 1 of scroll area 1 of group 1 of splitter group 1 of front window
			set elemList to every row
			repeat with elem in elemList
				--all attribute types except Boolean
				if name of static text 1 of UI element 1 of elem is equal to myInput then
					select static text 1 of UI element 1 of elem
					set value of text field 1 of UI element 2 of elem to myValue
					keystroke return
				end if
				-- Boolean data type
				if name of static text 1 of UI element 1 of elem is equal to myInput2 then
					if value of checkbox 1 of UI element 2 of elem is not equal to myValue2 then
						click checkbox 1 of UI element 2 of elem
					end if
				end if
			end repeat
		end tell
	end tell
end tell

What you’ll find it you run this (with the relevant attributes set as KAs) is the the Boolean setting does stick but the value for string/Number-based attributes resets to the pre-existing value. Go figure…

So a bit more to do. I do rather agree with @PaulWalters. In the time spent banging my head against the innards of AppleScript I found myself also thinking that prototypes would make most of this go away.

Before it’s asked, selecting a KA element so as to show and then access its pre-existing value list is likely an exercise in futility, but I’m happy to be proved wrong.

This is more or less my workflow, too. Especially when I’m creating notes on which I want to do a lot of “tagging”-type activity. (EG, when I’m categorizing research notes, and for an attribute like $Themes I want to add a number of values, like “China” or “Climate” or something.)

The crucial convenience factors, to re-emphasize, are: creating these notes in a container with the right on-add action to set the prototype ( eg $Prototype='myPrototype') and having the relevant Key Attribute up near the top of the list, so you can tab right over to it.

That is, a prototype can do a whole lot of the work of a script or macro, at least for me. (Meanwhile, admiring the scripts that have been offered here.)

1 Like

Hi Paul,

$KeyWords is only one of the user key attributes I use. I just mentioned it as an example of what I need to do. $KeyWords is the equivalent to what I see other people have called $Theme. That is, this is the key attribute I use to tag a note according to many possible subjects.

So, it is a single key attribute but it actually has quite a lot of possible values and what I want is not just to be able to introduce the key attribute in a note but to be able to tag the note with many of the values of a given key attribute as I go along working with the development of the note. I have other user key attributes that I have created and I use some of the other built in key attributes as well. As I say, I want the macro to introduce the values for all those key attributes I use most frequently in a quick way.

The system you suggest is good when you create the note for the first time but this is a different scenario from the one I had in mind. Notes for me are almost never a finished product. I create one note one day and add some information and I might get back to this note some days (or months) later to continue to add information, to modify it, to take some information from that note and put it in a different note, etc. What you suggest might work well if you create the note, work on it for a little while, then finish it and never come back to it other than for consultation. If your notes are continuously evolving then the workflow you propose does not seem to help that much. It is a good suggestion, though, that could be useful for other things and I might implement it as the first step in the creation of a note. As should be clear from what I just said, this is not going to solve the general problem I wanted to solve.

JM

Sorry Mark, I did not realize you were writing your message while I was preparing my answer to Paul.

Unless I’m totally wrong about what prototypes do, from my answer to Paul you can see why using prototypes will not help me do what I was intending to do.

JM

My suggestion used “create a note” as example, but in fact one can maintain all of their key attribute values in all notes in a document by using the arrow keys to navigate notes in the Outline, using the same keys to navigate attributes in the KA list for a given note, and using ⌥⇥ to toggle between Outline, Text, and KA list.

↑, ↓, and ⌥⇥ are just about all you need to manage your “workflow”. (To the extent I understand it, which isn’t much. :frowning_face: I’m afraid.)

Sorry, whenever I see users pulling out AppleScript to make Tinderbox do something my instincts yelp “OMG stop! Look at what exists already”. :wink:

There are plenty of scriptless users who rarely if ever touch the mouse while using Tinderbox.

1 Like

I’m in the camp of the scriptless users who almost never touch the mouse.

To bring this into the realm of specifics, I think my workflow is pretty similar to the one being described by @jfontana. I am constantly tweaking and updating notes.

Here’s a screen-movie of adding a note to that file, in which the only times I touch the mouse (actually, the trackpad) are to move from one Key Attribute field to the next. I do that, and that only, by clicking in the respective fields. (You can see when I’m using the mouse/trackpad, because those are the moments when the cursor becomes visible on the screen.) All the rest is with keystrokes, the tab key, the enter key, the arrow keys. No scripts or macros are involved.

I put this up being aware that every single user (including the OP in this thread) does things with infinitely-variable specific approaches. But this is an illustration of how you can add a lot of tags and details, while using the trackpad/mouse barely at all.

Here is the link to the Dropbox video. (The list of “Test Files” you see higher up in the outline is there just to move some other, real items with more sensitive title lines out of view.)
Dropbox - KeyboardAttributeUse.mov - Simplify your life

Fair enough :grinning:. I actually find your suggestion useful (I had not learned how much the ⌥⇥ can help you do).

Imagine, however, that just typing @sh in your note instantaneously added “Scriptless Hypothesis” as a value to the key attribute $Theme without having to do anything else. Not even multiple ↑, ↓, and ⌥⇥ let alone typing “Scriptless Hypothesis” in the field for key attributes. Just type @sh and watch it disappear in milliseconds as you continue to work seamlessly knowing that a new value is safely added to the metadata of your note.

Things can get even better with some automatization, you know :wink:? Tinderbox is wonderful and useful, but if you add tools like TextExpander, Keyboard Maestro, it can get even better.

JM

Thanks for the video James. All of these tips are actually very useful.

JM

LOL. There are 34 (so far) posts here dedicated to avoiding mice.

(BTW, Typinator can do everything posited for KM, above, in a single command line – with NO scripting :smile:)

Good luck with finding a solution!

Actually, I own Typinator and use it quite extensively. I bought KM because at the time it could do way many more things than Typinator. Now Typinator can do a lot of things (even execute scripts) and the differences between the two apps are not as big.

The one thing that KM could do that I thought would be helpful in my case was to record the movements of the mouse. In the end, the script provided by @mwra does a much better job of introducing the key attribute in a note which doesn’t have one but I’m stumped because I find no way to continue after that. The other script that he added has the problem that it eliminates existing values if they exist. I’ll try to look into that but I must admit I don’t know enough about the particular scripting language that needs to be used here, AppleScript, to solve my problem quickly and efficiently enough.

Scripting is enormously useful, though, and it should not be as intimidating as it is. Having said this, though, I use Automator and Keyboard Maestro quite a bit where other people might use AppleScript directly so a bit intimidated by it I must be :wink:.

Josep M.

So you want to target a list (Set or List type)? Did you try something like this:

set myInput to "Opacity"
set myValue to "50"
set myInput1 to "Tags"
set myValue1 to "small"
set myInput2 to "NeverComposite"
set myValue2 to "0"

activate application "Tinderbox 7"
tell application "System Events"
	tell process "Tinderbox"
		tell table 1 of scroll area 1 of group 1 of splitter group 1 of front window
			set elemList to every row
			repeat with elem in elemList
				--all attribute types except Set, List and Boolean
				if name of static text 1 of UI element 1 of elem is equal to myInput then
					select static text 1 of UI element 1 of elem
					set value of text field 1 of UI element 2 of elem to myValue
					keystroke return
				end if
				--Set and List types
				if name of static text 1 of UI element 1 of elem is equal to myInput1 then
					select static text 1 of UI element 1 of elem
					set oldList to value of text field 1 of UI element 2 of elem as text
					set value of text field 1 of UI element 2 of elem to oldList & ";" & myValue1
					keystroke return
				end if
				-- Boolean data type
				if name of static text 1 of UI element 1 of elem is equal to myInput2 then
					if value of checkbox 1 of UI element 2 of elem is not equal to myValue2 then
						click checkbox 1 of UI element 2 of elem
					end if
				end if
			end repeat
		end tell
	end tell
end tell

That appears to work in terms of everything except the problem that applied values don’t get properly stored by Tinderbox. I’ve no idea why. note - I am not an AppleScripting expert.

Thanks very much for your time, Mark. I really appreciate it and I really appreciate the willingness to help other users I see in this community.

I’m much less of an expert in AppleScript than you are. Yes, the data type was a problem and your modification solves that but now, as you say, the values don’t get stored by TB.

I think it is better to end this thread because now it is turning into something that would be more appropriate in a forum for AppleScript users than in a forum for TB users.

The only thing I would need to solve this problem (with the help of KM) is something that is obviously very basic for anybody who works with AppleScript and that you obviously know about. This is the Accessibility Inspector for AppleScript. The information about the UI that tells you what elements of the UI there are in a given app window and what to call them in AppleScript.

I’ve searched for information about the so-called Accessibility Inspector but the web pages I found only tell you how to get that with previous versions of MacOS. I don’t seem to be able to get that with MacOS High Sierra.

So, in your script I see the following line:

click button “+” of group 1 of splitter group 1 of front window

“group 1 of splitter group 1 of front window” describes the area in the UI where the “+” is located. I’ve tried to find out what the IU location is for the field that is created after you introduce a key attribute but I’ve been unable to do it. I need to be able to simulate a click on that field because I get stuck after the key attribute is created. As I say, all the results of my searches seem to point to this Accessibility Inspector that I’m not able to find.

Anyway, if you can point me to some resource that might help me find information on those IU elements, I will really appreciate it. Otherwise, as I said, I think I should end this thread because I don’t want to make you guys waste more of your time.

Thanks to the help I have obtained from you, Paul and James I can already see how I can generate Typinator or KM macros that can create certain prototypes or can combine keyboard shortcuts to do many of the things I need to do much faster and much more conveniently than before.

The only sticking point for me are still for those things where one needs to click something with the mouse. Thanks to your initial script, I can do that with the “+”. Now I only need to find out how to simulate the click on the input field that takes me from the creation of the key attribute to the point where I can insert the value in the input field without having to use the mouse.

JM

AppleScript in High Sierra is virtually unchanged from prior macOS or OS X releases. The features Mark described go back a decade or more. The language is dying, of course, and likely not to last much beyond Mojave.

KM has a Click at Found Image action that will click on a region of the screen based on an image of the control or button at that location. KM’s internal documentation and its wiki will explain.

Obviously, most of this thread belongs in the KM forum, of course.

2 Likes

Wrong approach, I think. You’re just making life hard. The code I supplied for opening the ‘add KA’ pop-up does that and the pop-up opens with the top input box selected. You then just type [sic] the name of the desired KA and hit Return. That attribute - if it exists - is added to the KA table straight away. Hitting Escape closes the pop-up allowing you to then edit the value(s) of the attribute(s) you just added to the table.

It seems you’re assuming that you want or need to go add attribute - edit value - add attribute, etc… In fact you can do that - add one KA close the pop-up, edit the new KA’s value, re-open the pop-up add another KA etc…

The issue with an AppleScript edit of a KA value not persisting is something I’ll maybe address in a different thread. Having put this much time into the problem I’m minded to solve it. Regardless I think the script approach to setting/editing values is far harder than just using the various keyboard shortcuts @PaulWalters kindly described in a previous reply.

It is the case that the secondary pop-up, called if you define a KA for which there is no existing attribute, doesn’t support keyboard-only input. But, it’s not a high trafficked. Anyway, a quick spelunk with UIBrowser gets me this:

-- click the checkbox in row 1 of the undefined attribute list
click checkbox "Create"  of UI element 1 of row 1 of table 1 of scroll area 1 of pop over 1 of button "+"  of group 1 of splitter group 1 of front window 
-- select the data type pop-up in row 1 of the undefined attribute list
select pop up button 1 of UI element 1 of row 1 of table 1 of scroll area 1 of pop over 1 of button "+"  of group 1 of splitter group 1 of front window

Frankly making a new attribute in this fashion is an infrequent and considered think so it’s going to break workflow briefly so I don’t feel a touch of the mouse or trackpad here is really a big deal.

I meant to add this is now a developer tool built-into Xcode. I don’t believe it is available as a stand-alone tool, as once it was.

A pay-for alternate to Accessibility Inspector is UIBrowser ($$) - Home - ID-Soft PFdle. Separately, AppleScript Debugger (https://latenightsw.com) is much more handy than the Apple offering and has a free version/mode (see here).

All fine, but a bit of a spend if getting only to do a task like above.