MKANET Posted April 11, 2012 Share Posted April 11, 2012 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 More sharing options...
BrewManNH Posted April 11, 2012 Share Posted April 11, 2012 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 GudeHow 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 More sharing options...
JohnQSmith Posted April 11, 2012 Share Posted April 11, 2012 I need to send the key combination <CTRL><NUMADD> to the target Windows Explorer window Use Send("^{NUMPADADD}") Look here for the full list of keys that Send can use. Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
MKANET Posted April 11, 2012 Author Share Posted April 11, 2012 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 More sharing options...
Mat Posted April 11, 2012 Share Posted April 11, 2012 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 windowSend 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) AutoIt Project Listing Link to comment Share on other sites More sharing options...
BrewManNH Posted April 11, 2012 Share Posted April 11, 2012 (edited) 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 April 11, 2012 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 GudeHow 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 More sharing options...
MKANET Posted April 11, 2012 Author Share Posted April 11, 2012 I wanted to let you guys know I think you're great people. I really appreciate you helping me get started. I just needed a little bit encouragement. AutoIt is so easy to adapt to!! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now