Reply to topic

Using Gizmo Script
Del
Guest

Reply with quote
I am trying to evaluate the Gizmo Script tool to automate some processes, however I find the documentation to be incomplete and I find documented features that do not exist. Is this a problem with the trial period. Basically what I am trying to do is open an application, then open a window within the application and issue a command within that window. What I can't figure out how to do is to set focus on the child window. Can you shed so light on this.
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
I will be happy to help you here. Use Execute() in the Shell class. For example, to launch Windows Notepad, call:

Shell.Execute("C:\Windows\Notepad.exe");

Setting focus to the child window is as simple as calling SetFocus() or ForceToTop() after a Window has been defined with Window class. In other words, the Window class will need an actual window associated to it, before most of the functions in that class can be used. The following code searches for any windows with the title "Unique Window Name" and forces it to the top, with focus.

Window MyChildWindow = Window.FindByName("Unique Window Name");
MyChildWindow.ForceToTop();

You can use FindByClass() instead, if you know that the child Window has a unique Window class. (Some Windows have the same title as another Window, so in that case, using its unique Window class is better, if it has one) FindByPos() also achieves the same thing, using screen coordinates. This only works if you know the screen coordinates upfront, and they are persistant, never change)

Please don't hesitate to post any other questions here in this Message Forum. (Other people will surely benefit from your questions in the meantime)

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Using Gizmo Script :: Keycodes
Eric Jones


Joined: 20 Jun 2007
Posts: 5
Reply with quote
Is there a reference for valid Keystrokes? There seems to be only a few basic ones identified in the help for Keyboard.Send. I'm interested in finding the string necessary to send arrow keys for instance.

Is there a reference for valid virtual key codes? The Keyboard.IsKeyPressed example only lists the control key code.

Maybe these are found in the OS shell documentation?
View user's profileSend private message
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
They were documented in the older version (ironically the less documented one) but it looks like they got lost in the shuffle. Sad I will have them added back.

In a nutshell, each of these should be enclosed in curly braces. If you wish to press multiple keys at once, enclose them all in the same curly brace and separate them with hyphens, e.g. {Ctrl-Alt-Del} or {Alt-Tab} or {Ctrl-5} For the letters and numbers, no curly braces are required. Simply pass them to Keyboard.Send () as is, e.g. Keyboard.Send ("{Tab}My Name{Tab}mypasword1234"); Here they are. They are not case sensitive.

Code:

ctrl
alt
ins
tab
del
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
enter
return (same as 'enter')
esc
back
bkspc (same as 'back')
shift
caps
space
pgup
pgdown
home
end
left
right
up
down
snap  (a.k.a. 'Print Screen', as in snapshot, or VK_SNAPSHOT)
scroll (a.k.a. 'Scroll Lock)
lshift
rshift
lctrl
rctrl
lalt
ralt
pause
cancel

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Eric Jones


Joined: 20 Jun 2007
Posts: 5
Reply with quote
Thanks Logan.

Do you have a virtual key code listing? (i.e. 17 = ctrl)
View user's profileSend private message
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
Hi Eric,

MSDN has a Virtual Key code listing at this address, and includes numbers associated with them:
http://msdn2.microsoft.com/en-us/library/ms645540.aspx

Unfortunately, this list won't be much use in Gizmo Script since Keyboard.Send() only recognizes the codes posted above. Support for the Virtual Key codes could be added for flexibility though. I originally wanted to do key codes, but felt the curly brace sequences would simplify things for some users. What is your take on that?

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Eric Jones


Joined: 20 Jun 2007
Posts: 5
Reply with quote
I'm a bit confused. Are the codes listed on the MSDN site applicable to the codes intended to be used with Keyboard.IsKeyPressed()?

Your example lists 17 as the control key. And the sample works. This contridicts the MSDN listing; VK_CONTROL (11) CTRL key.

Are we talking apples to apples?

The curly bracket implementation seems fine for Keyboard.Send().
View user's profileSend private message
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
Ah, the numbers on MSDN are hexadecimal. Hex 11 is in fact decimal 17. That's a pain, but Windows Calculator can convert those pretty easily in Scientific mode.

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Eric Jones


Joined: 20 Jun 2007
Posts: 5
Reply with quote
Ah crap! You are right. Sorry.
View user's profileSend private message
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
I'll be sure to have the Virtual Key code listing added back in the documentation. (In decimal)

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Logan Mueller
Support

Joined: 16 Nov 2003
Posts: 565
Reply with quote
The Virtual Key codes and Keyboard Sequences are now documented back into the latest release. It is possible to pass VK constants instead of decimal numbers for the virtual key codes, in the latest version. In other words, it's OK to pass VK_CONTROL instead of 17 to IsKeyPressed()

There is a new function, Keyboard.SendKey() which accepts Virtual Key Codes instead of Keyboard Sequences. This was added for people who'd rather work with Virtual Key Codes directly.

_________________
Support is provided as a convenience to our users. We make no guarantees in the timeliness and accuracy in our responses. We reserve the right to refuse service to anyone.
View user's profileSend private messageVisit poster's website
Using Gizmo Script
All times are GMT - 8 Hours  
Page 1 of 1  

  
  

 Reply to topic