Keyboard Maestro to emulate ++, etc.

I just installed Keyboard Maestro and set up some macros to let me type things like ++, +=, etc., and have it substitute Xojo code.

For example, if I type:

value++

it immediately replaces it with:

value = value + 1

Similarly, typing:

value+=

will get me:

value = value + 

with the cursor positioned correctly.

I know some people miss these functions, and I don’t want to start a debate (again) about whether they should be added to the language (they shouldn’t, IMO), but if anyone wants my macros, I’m happy to share.

Cool!
Just to add, this can also be done with Dash if someone uses that :slight_smile:
Don’t know if it’s as good as I’ve not tried Maestro…

[quote=185065:@Albin Kiland]Just to add, this can also be done with Dash if someone uses that :slight_smile:
[/quote]

Albin, I use Dash. Do you have a snippet that does this? I’d like this snippet in Dash but don’t see a way to implement it.

Snippets can be expanded in Dash using their Abbreviation.
If you have a snippet named hello’ and write hello’ in any text editor your snippet is pasted.
You can also have placeholders in your snippets! Try that :wink:

I guess Keyboard Maestro can be used for more things than these snippets in Dash though.
Sorry Kem, back to Maestro :slight_smile:

[quote=185130:@Albin Kiland]Snippets can be expanded in Dash using their Abbreviation.
If you have a snippet named hello’ and write hello’ in any text editor your snippet is pasted.
You can also have placeholders in your snippets! Try that :wink:

https://kapeli.com/dash_guide#snippets[/quote]

I use snippets there, but in this case Keyboard Maestro is doing quite a bit of work. You can type:

myClass.myVariable++
abc++
someVariable.someProperty.somethingElse++

and when typing ++ keyboard maestro will do work and replace all of that with:

myClass.myVariable = myClass.myVariable + 1
abc = abc + 1
someVariable.someProperty.somethingElse = someVariable.someProperty.somethingElse + 1

So it’s not simple expansion, i.e. it looks at content ahead of the ++, copies it, changes the line, adds stuff, etc… Can Dash do that or am I missing it?

I don’t know if this is exactly that but hey, I like screen recordings :wink:

https://youtu.be/Yuqk8nagfDI

Nice! I like them too!

Here is one of what Keyboard Maestro is doing:

https://youtu.be/-auvtagzOFo

Notice how it’s doing a bit more work. i.e. in dash:

a++

// expands to

a + 1

while in Keyboard Maestro

a++

// expands to

a = a + 1

Aah, that’s really nice! No, don’t think dash can do that.
I might give this Maestro guy a chance :wink:

Ps. People should start doing more screen recordings!

I just improved the macros on Jeremy’s suggestion. You can now type something like:

this.that( someclass.arrProp( 2 ) )++

And have it automatically replace it with:

this.that( someclass.arrProp( 2 ) ) = this.that( someclass.arrProp( 2 ) ) + 1

It’s not perfect. If you do something like “arr( i + 1 )++”, it won’t work, for example.

Never mind, it will now work no matter what. It takes everything before the token (++, —, etc.) to the beginning of the line and processes that. And I added some intelligence for single-line if/then and if/then/else statements.

I use a home built text expander and the one I use most often is “fi”, expanding to

[code]for i As integer = 0 to .Ubound

next[/code]
and the selection is around “.Ubound”. So if it’s an array just press left and type the arrays name, otherwise type to replace it.

The other handy feature is Command-/ plays out mouse clicks which toggle the lower pain.

Good tips.

For that, I created a Xojo Script, it is simply:

DoCommand "Find"

I then bind a shortcut to it, ^W for me for “Where Is”. Anyway, if I press it while there is no find panel, it appears and switches to it. If I press it when there is a find panel, the find panel disappears.

Will, that was a good tip, but I went the other way. I now have a keystroke (cmd-/) that will close the lower pane only.

The macro pressed cmd-F (forcing Find mode), then looks for the magnifying glass and clicks it. Finally, it restores my mouse position. Pretty nifty.

Even better (thanks @Jeremy Cowgar !), it now looks for the highlighted icon at the bottom and, if it finds it, it clicks it.

And now, when I press cmd-R, it will close the lower pane first. :slight_smile:

And now I have one that will go to the Filter and highlight its contents.

(As I said, for anyone with Keyboard Maestro, I’m happy to share.)