SendKey ! - Forum

Forum Navigation
You need to log in to create posts and topics.

SendKey !

Why can I not use the SendKey action with an exclamation point? SendKey will not send a !

!
[#33]

Nothing I tried will send this character. Or any of these  ~ {

And I can't get this ^ to show in a button caption.

Suggestions?

@pauljonestindall

Why can I not use the SendKey action with an exclamation point? SendKey will not send a !

This is because the ! character acts like an 'escape character in unix/linux systems'; it tells VisualNEOWin to use the remaining characters (within the parameter value) AS IS (i.e. do NOT perform any math on the remaining value e.g.

2+3 will result in a number 5
!2+3 will result in a string of three characters viz. 2+3

The way to have VisualNEOWin to accept the ! is to supply two of them ...

SendKeys "" "!!"

... the first one tells VisualNEOWin to accept the second and subsequent characters AS IS.

Of course any of these will also work as intended ...

SendKeys "" "!!a"
SendKeys "" "!abcd!e"
SendKeys "" "!abcde!"

 

 

@pauljonestindall

Or any of these ~ {

This depends on the type of keyboard you are using.

On my keyboard, ~ is above the key with ` (angled single quote; not the straight up one like ') ... so this works ...

SendKeys "" "{ShiftDn}````{ShiftUp}"

As for {, I am stumped ... on my keyboard, this is above the [ ... unfortunately, VisualNEOWin's command interpreter will not allow unmatched square brackets ... in any command ... so I do not know how to get around this defect/deficiency.

And I can't get this ^ to show in a button caption.

Stumped again ... within caption strings, the hat character ^ is used to indicate the shortcut letter ... it shows up as the line under the next character in the button label/text.

@gaev

Thanks for the tips. I'll give it a go with the ! but as for the other characters... it'll make my OSK a bit less effective but it's not the end of the world.

Thanks again.

@pauljonestindall

but as for the other characters... it'll make my OSK a bit less effective but it's not the end of the world.

If your enquiry was in the context of an on-screen keyboard (OSK), where you have a bunch of buttons, and the click action of each button is to do a SendKeys command, then, for these two key characters, you could just update the variable associated with the currently focused object ... [FocusedObject]).

Points to consider would be ...

1) what is the variable associated with the [FocusedObject] ... you could make sure that all TextEntry object named TextEntryABC had [TextEntryABC] as their associated variable

2) where is the current 'insertion point' (that blinking vertical bar) ... a little more complex workaround ...

- using SendKeys command send some unusual string of characters (e.g. zxcvb) which will be inserted at the current insertion point
- use the StrReplace command to replace this weird string set with {

 

And I can't get this ^ to show in a button caption.

If this is going to be the only character as the label for one of your OSF buttons, you might be able to fake it by using /\ (perhaps in a smaller sized font so the gap is not very legible) ... or use an image of the 'hat character'.

 

@pauljonestindall

Found a way to send the { character via SendKeys command.

VisualNEOWin commands do NOT allow unpaired square brackets (e.g. abcd...[...xyz) within paramter specifications of any command, but you can specify abcd...[#91]...xyz.

So, if you want to send the { character (which would normally be {ShiftDn}[{ShiftUp}, you can do this instead ...

SendKeys "" "{ShiftDn}[#91]{ShiftUp}"

 

luishp has reacted to this post.
luishp

@gaev

Thanks again for the tips. It seems everything's working now.

The only thing I see at this point is when I use StrReplace for the "{" character, if the insertion point is not at the end of the string, the cursor ends up at the end of the string. Which I'll say, for the moment, I can live with that.

For now, my need is for typing a persons name. I expect I'll be wanting to use this in the future as well as a somewhat "full fledged" OSK.

@pauljonestindall

The only thing I see at this point is when I use StrReplace for the "{" character, if the insertion point is not at the end of the string, the cursor ends up at the end of the string. Which I'll say, for the moment, I can live with that.

Oops, I did not account for this.

For now, my need is for typing a persons name. I expect I'll be wanting to use this in the future as well as a somewhat "full fledged" OSK.

Where there is a road block, there is a corresponding detour !

In order to reposition the insertion point at its previous location ...

a) SendKeys {zxcvb}

b)  SearchStr zxcvb ... to get/save its start position

c) StrReplace as before

d) using the previously saved start position ..
- SendKeys {Home} ... to position the insertion point at the start of the TextEntry Box
- generate a series of {Right} keys as required ... this can be accomplished via a Loop/Endloop or by extracting a SubStr of a hard coded variable containing a very long series of {Right}{Right}{Right} ... {Right}

I can develop/publish this code if required.