Re: [Clip] Using Menu and Keyboard
Yes, that works. Thanks. My question is really a more general one and is
probably the result of misunderstanding ^!Keyboard.
My ^!MENU File/Template/Open command opens a dialog window that has
focus, so I expected ^!Keyboard data to populate the dialog at the
cursor. Instead, the text is entered into the Notetab document that was
active when I double clicked the Clip name.
Is there a way to do what I want (in general terms) using NTB to
interact with dialogs and forms?
Regards, John M
----- Original message -----
From: "loro" <loro-spam01-@...>
Date: Wed, 05 Jan 2005 07:38:33 +0100
Subject: Re: [Clip] Using Menu and Keyboard
John Mitchell wrote:
>Some recent discussions on this board have spurred my interest in theseI haven't followed this and I can't say I've used these commands much
>two commands. Naively, I expected...
>^!Keyboard #html.tpl# Enter
>To open a new document using the HTML template. Unfotunately, only the
>MENU piece appears to work. No text is entered at the cursor and no
>ENTER is simulated. I tried the same thing with a keyboard delay before
>the #html.tpl# but it made no difference. What am I doing wrong?
*think* you want this:
^!Keyboard CTRL+O #^$GetTemplatePath$html.tpl# ENTER
Yahoo! Groups Links
- G'day John,
If you are using NoteTab to control other applications, which is mainly
what ^!Keyboard is intended for, you need to ensure that the target
application has the focus before you issue the ^!Keyboard command.
This is done using ^!FocusApp.
In the example below, which is a real live example in my situation,
^!FocusApp is used to focus on the SQL Query Analyzer application window
(the * is a wildcard to ensure that the command will still work if the
application's window title bar contains something like SQL_Query
Analyzer - [pw1.DMS.Admin - C:\Projects\Scripts\Core.sql]).
The first pair of ^!Keyboard commands opens a login dialog and enters a
user id and password; then the second pair opens a file dialog and
enters the name of a script file - exactly the kind of thing you are
trying to do.
^!FocusApp SQL Query Analyzer*
^!Keyboard &200 CTRL+O
^!Keyboard &600 SHIFT+TAB #^%SQLUser%# TAB #^%SQLPassword%# TAB TAB TAB
TAB #^%SQLServer%# ENTER
^!Keyboard &800 ALT+F &200 #o#
^!Keyboard &400 #^%SQLScript%.sql# ENTER
You may have to experiment, as I did, with keyboard delays (the &200,
&600, etc., values in the above piece of code), depending on how long
the target application takes to respond to a function key activated by
Also, if you use any other NoteTab clip command in the middle of a set
of ^!Keyboard commands, you may need to repeat the ^!FocusApp command,
as NoteTab may have reclaimed the focus. You can transfer the focus
back to NoteTab explicitly using the ^!ActivateApp and/or ^!FocusDoc
commands as appropriate.
On the other hand, if you are trying to control NoteTab itself from
within a clip, you are usually better off trying to avoid the use of
^!Keyboard, instead using the appropriate clip commands.
^!Keyboard #html.tpl# Enter
try the normal ^!Open command:-
As the first line of the file will contain the template header
definition, NoteTab will recognise it as a template, and act
accordingly. Of course, you won't get the Open Template dialog, but
given that your templates will most likely be in NoteTab's Template
directory, that shouldn't be too much of a problem. If you want to be
able to select a template file, it wouldn't be too hard to get a list of
the .tpl files in the Template directory and present them in a wizard,
then substitute the name of the selected template file in the ^!Open
> -----Original Message-----
> From: John Mitchell [mailto:notetab@...]
> Sent: Wednesday, 5 January 2005 17:25
> To: ntb-Clips List
> Subject: Re: [Clip] Using Menu and Keyboard
> Yes, that works. Thanks. My question is really a more general
> one and is
> probably the result of misunderstanding ^!Keyboard.
> My ^!MENU File/Template/Open command opens a dialog window that has
> focus, so I expected ^!Keyboard data to populate the dialog at the
> cursor. Instead, the text is entered into the Notetab
> document that was
> active when I double clicked the Clip name.
> Is there a way to do what I want (in general terms) using NTB to
> interact with dialogs and forms?
> Regards, John M
- Hi Pete,
I hope I did not make this too confusing. It might be easier to
just skip to the code and study it than to read what I wrote. It
seems like I wrote a lot to explain a little. ;)
There is a more accurate method of doing some of the things you
are doing by looking for the Titlebar caption/title name. It does
not always work, but most of the time it does and it takes the
guesswork out for the amount of delay to be adding and depending
on your machine at the particular time you run the Clip with the
long delays can vary a lot. There's two examples below, although
It's the ^!IfSame lines. Normally, the way I do it is to go about
it manually first and see what the Titlebar is called.
^$GetAppTitle$ looks at the focused Titlebar and returns what it
reads. So, you loop until the window is in focus known by the
caption/title comparing (^!IfSame) it. Sometimes you can put the
^!IfSame in an ^!Info box so you can get a better look at it. I
put something like the following where I expect the window to
open. I can copy from the ^!Info box to prevent typos.
^!Info IfSame "^$GetAppTitle$" "NetCaptor User Center - Login - NetCaptor"
When the ^!IfSame is the same you continue on with the Clip. The
first ^!IfSame below looks for the full title. The second is
looking at a part of the title, the last 17 characters to be
I find it easier to use StrCopyRight a lot of times in certain
apps because the right side of the string is what is constant for
the application name reading right to left. I just go back as
many characters as need be to get the document name (in a lot of
cases - the <title> tag in some browsers).
It is easy in NoteTab to just select the characters and look at
the Statusbar for the selection size - amount of characters and
simply plug that figure in. StrCopy and StrCopyLeft require
figuring out the index position, etc.
^!IfSame "^$GetAppTitle$" "NetCaptor User Center - Login - NetCaptor" Next else Skip_-1
^!Keyboard Shift+Tab Tab Tab Tab
^!Keyboard Ctrl+V Tab
^!Keyboard Ctrl+V Tab Tab Enter
^!IfSame "^$StrCopyRight("^$GetAppTitle$";17)$" "Index - Netcaptor" Next else Skip_-1
>^!FocusApp SQL Query Analyzer*For instance, in your code, you are probably waiting for a
>^!Keyboard &200 CTRL+O
certain dialog to open below from the Ctrl+O above. Instead of
the &600 delay, you would use the ^!IfSame and ^$GetAppTitle$ in
a loop like either of the following...
^!IfSame "^$GetAppTitle$" "The Full Titlebar Caption" Next else Skip_-1
; reading from right to left
^!IfSame "^$StrCopyRight("^$GetAppTitle$";18)$" "Your Titlebar Name" Next else Skip_-1
>^!Keyboard &600 SHIFT+TAB #^%SQLUser%# TAB #^%SQLPassword%# TAB TAB TAB TAB #^%SQLServer%# ENTERHappy Clip'n!
>^!Keyboard &800 ALT+F &200 #o#
>^!Keyboard &400 #^%SQLScript%.sql# ENTER
>You may have to experiment, as I did, with keyboard delays (the
>&200, &600, etc., values in the above piece of code), depending
>on how long the target application takes to respond to a function
>key activated by ^!Keyboard.
All Lists: http://www.fookes.us/maillist.htm
- Hi Jody,
> I hope I did not make this too confusing. It might be easier toNo, there's no confusion here.
> just skip to the code and study it than to read what I wrote. It
> seems like I wrote a lot to explain a little. ;)
That piece of code was written two or three years ago when I was a real
green NoteTab newbie, but I've never had the time to revisit it (plus,
it falls into the category of "if it ain't broke, don't fix it!!"). I
don't think I'd found $^GetAppTitle$ at the time.
> Normally, the way I do it is to go about it manually firstYes, that's how I did it (and still do, for that matter).
> and see what the Titlebar is called.
Usually ^!FocusApp is enough for me because most of the interactions I
do are fairly simple.
> For instance, in your code, you are probably waiting for aYes, that's the case.
> certain dialog to open below from the Ctrl+O above.
> Instead of the &600 delay, you would use the ^!IfSame andSkip_-1
> ^$GetAppTitle$ in a loop like either of the following...
> ^!Delay 3
> ^!IfSame "^$GetAppTitle$" "The Full Titlebar Caption" Next else
As a programmer, the neatness of that appeals to me greatly. I might
decide my code is "broke", after all :)
One thing I've just learnt: I never knew you could use a negative
number to Skip backwards (and looking just now, it doesn't seem to be
mentioned in the help). I'll certainly be putting that to good use.
- Hi Pete,
>(plus, it falls into the category of "if it ain't broke, don't"If it works, don't fix it!" Murphy's Law #nnn. :) I have a
Library called SureWord that has 150 of Murph's laws along with
Bible scripture popups. See below...
>Usually ^!FocusApp is enough for me because most of the interactions IVery true, but machines change and then there's public domain Clip... ;)
>do are fairly simple.
>> ^!Delay 3I didn't know you were a programmer. I wouldn't be talking to you
>> ^!IfSame "^$GetAppTitle$" "The Full Titlebar Caption" Next else Skip_-1
>As a programmer, the neatness of that appeals to me greatly. I
>might decide my code is "broke", after all :)
had I known. !_haha_!
>One thing I've just learnt:Now, *that _is_* incredible! A programmer that can still learn! :-)
>I never knew you could use a negative number to Skip backwardsI love the Skip_[+|-]n, Skip_-n, Skip_+n, Skip_-1, Skip_+1
>(and looking just now, it doesn't seem to be mentioned in the
>help). I'll certainly be putting that to good use.
To me, they are the best thing since slice peach pie! :) Here's
some tips and cautions for the benefit of all of us...
Be sure to *know exactly* what the commands/functions *do*
before/after the Skip_-n. For instance, ^!Skip can trip you up.
:) From my ClipTut 5LA Lesson 5 above half way through there's a
sentence referring to the "Yes" in the ^!Skip dialog: "A Yes
answer *always* skips the next line unless it is a comment line.
[;Comment lines are not considered a line.] [However,] blank
lines are considered a line." So, you'll be counting your lines
and count the ;this line that is a comment a line and it will
set you Skip_-n off by one line.
Be careful to pay attention to what line(s) code you insert or
remove (especially at a later time), because it will shift the
lines making the Skip_[-|+]n change. Study the code above and
below a half dozen or so for at least a quick scan for Skip_-n.
I think it is best to keep the number of lines skipped minimal
because of the reasons above. It is much easier to see what is
going on in your Clip with a few lines skipped (or un-skipped 8D)
than with many. Personally, I don't go over 4 and then a lot of
time leave a blank line. For those that don't mind using ALL CAPS
in places SKIP_-N would be a good place. ;)
Also, remember that it might be a very long time past by when you
last used/edited the Clip. The ^!Goto command and Label may be
used and can be more descriptive helping you to remember what the
Clip does and is used for in the future.
NoteTabbers Assistant Snatch-A-Clip Page
NoteTabbers Assistant Library Page
I have 150 of "Murphy's Laws" in my SureWord Library. All the
popups can be brought up sequentially or randomly and at
specialized intervals. It was originally made for a scripture
memorization tool and broadened to topical like the rapture
(catching away of the saints) and can be used for other things
now. The following is the format that opens in an ^!Info box.
Murphy's Law # 1:
If rats are experimented on, they will develop cancer.
Murphy's Law # 5:
If there is an opinion, facts will be found to support it.
Murphy's Law # 8:
Law of Window Cleaning... It's on the other side.
Murphy's Law # 9:
Anything that happens enough times to irritate you, will happen
at least once more.
Murphy's Law # 10:
Nothing in the known universe travels faster than a bad check.
Murphy's Law # 22:
Nothing ever gets built on schedule or within budget.
Murphy's Law # 23:
While byrographic systems are typically encountered in substrata
of earthy or mineral matter in concreted state, discrete
substrata elements occasionally display a roughly spherical
configuration which, in presence of suitable gravitational and
other effects, lends itself to combined translatory and rotary
motion. One notices in such cases an absence of the otherwise
typical accretion of byrophyta; we can therefore conclude that A
rolling stone gathers no moss.
Murphy's Law # 65:
Interchangeable parts won't.
Murphy's Law # 64:
If a project requires n components, there will be n-1 components available.
Murphy's Law # 63:
Information necessitating a change in design will be conveyed to
the designer, after the plans are complete.
Murphy's Law # 66:
Components that must not and can not be assembled improperly will be.
Murphy's Law # 67:
The most delicate component will be dropped.
Murphy's Law # 68:
The construction and operation manual will be discarded with the
packing material. The garbage truck will have it picked up five
minutes before the mad dash to the rubbish can.
Murphy's Law # 69:
A component selected at random from a group having a 99%
reliability, will be a member of the 1% group.
Murphy's Law # 70:
After an instrument has been assembled, extra components will be
found on the bench.
All Lists: http://www.fookes.us/maillist.htm