Jump to content

Brand new to AutoIt... quick request


Recommended Posts

Unfortunately VBScript SendKeys command cannot handle what I need to do. I was hoping someone would be very kind to get me started in AutoIt as my first working example that does the following:

I need to send the key combination <CTRL><NUMADD> to the target Windows Explorer window that has the Logs directory open using AutoIt. In VBScript dont have the ability to send a keycombination to a target Window; so, I just changed the focus to it instead.

This is the code in VBScript that "should" work, but unfortunately cant handle the keycombo I need since it can't tell the difference between the standard PLUS character and the one in the numeric keypad (which is what I need)

Dim WshellObj
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Logs"
WshShell.SendKeys "^{ADD}"
Link to comment
Share on other sites

You'd use Send("^{NUMPADADD}") in AutoIt

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Thanks for the quick replies. I'm actually interested in not just sending the keycombo. I need it to send the keycombo to a target window called "Logs". To try 3 seconds to look for the window before giving up. If it finds the window, to immediate send the keycombiation described.

I have an example below based on searching. But, it still needs a little refinement to do exactly what I want. I would truely be grateful for a full working example.

WinActivate("Logs")
WinWaitActive("Logs")
For $i = 1 to 10 Step 1
; your code here
Send("Iteration no: " & $i & "{ENTER}")
Next
Send("^{NUMPADADD}")
Link to comment
Share on other sites

What is it you need exactly? Tell me if I have this right:

  • Wait for the window "Logs" to exist (maximum 3 seconds?)
  • Activate the window
  • Send the keys.
If so then you'll need something like:

If WinWait("Logs", "", 3000) Then
    ; The window was found within time limit
    WinActivate("Logs")

    Send("^{NUMPADADD}")
Else
    MsgBox(0, "Error", "Waited for 3 seconds, but couldn't find the window")
EndIF

(haven't tested that)

Link to comment
Share on other sites

From the help file for WinWaitActive:

WinWaitActive ( "title" [, "text" [, timeout]] )

So you could do it like this.

WinActivate("Logs")
If Not WinWaitActive("Logs", "", 3) Then Exit
Send("^{NUMPADADD}")
Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...