Dart Posted July 21, 2009 Posted July 21, 2009 Hi, i'm trying to send a "r" key to a minimized application. I've tried several different approaches i found in the help file and the forums, but can't get any to work. When i use AutoItv3WindowInfo, i cannot find the control id number either (I did enable the Options -> Highlighting controls), so i've tried different work-arounds there too. 1) No 3rd parameter. $app = "Application" controlSend($app, "", "", "{r}") 2) Using PID for 3rd param. $app = "Application" $pid = WinGetProcess($app) controlSend($app, "", $pid, "{r}") 3) Using zero for 3rd param. $app = "Application" controlSend($app, "", 0, "{r}") None are sending the "r" to the application. Can anyone offer me some help please? Thank you.
Dart Posted July 21, 2009 Author Posted July 21, 2009 Also tried: 4) To find the ControlID: $app = "Application" $cid = ControlGetFocus($app) MsgBox(1,$app, $cid) This is returning an empty box, just like the au3Info tool. 5) To run using "null" $cid... $app = "Application" $cid = ControlGetFocus($app) controlFocus($app, "",$cid) controlSend($app, "", $cid, "{r}") Doesn't work either.
Authenticity Posted July 21, 2009 Posted July 21, 2009 Can you post the summary of AutoIt Window Info tool? Try to use the finder tool to capture the control (the tool that turn your mouse cursor to a target cursor and drop it on the control then post the summary tab content.
Dart Posted July 21, 2009 Author Posted July 21, 2009 I used the drop tool and dropped it directly into the application, here is the summary tab: >>>> Window <<<< Title: Application Class: SFMainWindow Position: 0, 0 Size: 1158, 890 Style: 0x14CA0000 ExStyle: 0x00000100 Handle: 0x0037044E >>>> Control <<<< Class: Instance: ClassnameNN: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: 0x000100FE >>>> Mouse <<<< Position: 617, 284 Cursor ID: 0 Color: 0x2C1E10 >>>> StatusBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<<
Authenticity Posted July 21, 2009 Posted July 21, 2009 Seems like there is no control there or that it's not possible to retrieve information about the control because it's a custom made control, try this: ControlSend('[CLASS:SFMainWindow]', '', '', 'r')
Dart Posted July 21, 2009 Author Posted July 21, 2009 (edited) Nope, that's not working either. I tried 1) ControlSend('[CLASS:SFMainWindow]', '', '', 'r') 2) ControlSend("[CLASS:SFMainWindow]", "", "", "{r}") 3) ControlSend("[CLASS:SFMainWindow]", "", 0, "{r}") No luck for any. Edited July 21, 2009 by Dart
trung0407 Posted July 21, 2009 Posted July 21, 2009 It's not a problem of control lol. It's actually a 'r' instead of a '{r}'
Authenticity Posted July 21, 2009 Posted July 21, 2009 (edited) Problematic, you need to find a way to reference a control to successfully send it a keystrokes. Maybe you can use WinList() or the _WinAPI_GetWindow() functions to get a reference and use this handle either in the first or the third parameter of the ControlSend() function. Otherwise, you'll need the window to be the focused window to send keystrokes successfully.Example:#include <Constants.au3> #include <WinAPI.au3> Run('notepad.exe') WinWaitActive('[CLASS:Notepad]') $hWnd = WinGetHandle('[CLASS:Notepad]') $hChild = _WinAPI_GetWindow($hWnd, $GW_CHILD) WinSetState($hWnd, '', @SW_MINIMIZE) WinWaitNotActive($hWnd) ControlSend($hWnd, '', $hChild, 'r') ; ControlSend($hChild, '', '', 'r') WinSetState($hWnd, '', @SW_RESTORE)Notepad is not a good example but just to demonstrate the procedure...Edit: {r} has no special meaning so it's not the problem although you're right the it's syntactically not correct. Edited July 21, 2009 by Authenticity
Dart Posted July 21, 2009 Author Posted July 21, 2009 No, this isn't working either. I thought it was, but it's just emulating a regular "send" command. So here is something i've noticed. The window-handle and the control-handle are different. The window-handle is unique to the application i'm trying to automate (lets call it X). The control-handle is being passed on from X to the next application i try to run (say SciTE or Iexplorer; call it Y). The r button is in a loop. So if i switch from program X to Y, then the r is just repeated into Y. This totally negates the objective of using controlSend in the first place. I am guessing here, but could it be that X is somehow protected against automation? If it is, there must be something (control values) showing up somewhere? Perhaps they are just invisible to the Au3Info. How do i get to the data? I'm not trying to do any hacking here, so if i'm approaching something borderline non-legit, please just make me aware. I'm just trying to automate some repetitive tasks. I also find this a very useful/interesting learning problem toward learning to script with AutoIT. I am a relatively new at using programming languages other than my Civil Engineering C++ core curriculum requirement.
Dart Posted July 22, 2009 Author Posted July 22, 2009 Could anyone else offer some advice on this topic please?
MDCT Posted July 22, 2009 Posted July 22, 2009 I think you could find something useful from using AHK Window Info. It can show all controls of a window. But, it may use CPU quite high at times. Never had any issue with ControlSend, so I'm not sure if it can help. Good luck.
BrettF Posted July 22, 2009 Posted July 22, 2009 I think you could find something useful from using AHK Window Info.It can show all controls of a window. But, it may use CPU quite high at times.Never had any issue with ControlSend, so I'm not sure if it can help.Good luck.You've really mentioned something very touchy. Great job. Maybe you should look up on the history!@OP- try winspy++. Have you done what Authenticity suggested with _WinAPI_GetWindow()?? What is the application you are trying to automate? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Dart Posted July 22, 2009 Author Posted July 22, 2009 Brett, The program i'm trying to automate is Darkfall Online (DF). Ya,i'm trying to make a game bot, but that's what i find fun and interesting. Applying scripting/programming to games allows me to learn. It's not like my bot is going to play the entire game for me, just automate some functions. I hope that at some point the time i've invested into learning to script will offer me a base from which to program in a more professional setting; maybe automating some tasks related to traffic pattern designs. Back to the issue, The post below Authenticity suggesting _WinAPI_GetWindow() is my response to having tried that technique. It was unsuccessful in that in order for they keystrokes to work, DF had to have focus. Ok, i'm getting set to try winspy++. If that doesn't work i will try MDCT's suggestion. First though, i'm going to see what Brett is talking about relating to history of MDCT's topic. I guess a forum/google search should get it done. I'll update when done.
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