BitByte Posted June 10, 2009 Posted June 10, 2009 I need help on this. I'm creating a simple bot for myself on the game Celestial Destroyer (http://zx.cubizone.com/eng/). I'm having trouble using ControlSend to the game (Send works.) *** The game don't have ControlID This work Send({1}) This don't work $hwnd = WinGetHandle("[CLASS:ZElementClient Window]") ControlSend($hwnd, "", "", "{1}") Pls help and advice Thank you
bo8ster Posted June 10, 2009 Posted June 10, 2009 And i'm not surprised. The syntax of WinGetHandle does not look correct - check the help file. Have a look at the return value of WinGetHandle with ControlWrite($hwnd) then check it against the AutoIt Info Tool. ControlSend works with a control not a window. The ControlID is not required to send a control text, look at ControlGetHandle. Get the Window or Control first then try sending text. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
BitByte Posted June 10, 2009 Author Posted June 10, 2009 Sry, I'm new to AutoIt and I'm still learning. This is what I've tried but all fail me: $hwnd = WinGetHandle("classname=ZElementClient Window") ControlSend($hwnd, "", "", "{1}") $hwnd = WinGetHandle("classname=Element Client") ControlSend($hwnd, "", "", "{1}") $hwnd = ControlGetHandle("[CLASS:ZElementClient Window]", "", "") ControlSend($hwnd, "", "", "{1}") ControlSend("Element Client", "", "", "{1}") Can you give me an example of the script? Thanks AutoIt Info Window: >>>> Window <<<< Title: Element Client Class: ZElementClient Window Position: 108, 67 Size: 808, 634 Style: 0x94CE0000 ExStyle: 0x00000100 Handle: 0x00410554 >>>> Control <<<< Class: Instance: ClassnameNN: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 328, 146 Cursor ID: 15 Color: 0x465C2C >>>> StatusBar <<<< >>>> Visible Text <<<< >>>> Hidden Text <<<<
bo8ster Posted June 10, 2009 Posted June 10, 2009 Thats ok Try WinGetHandle("Element Client"). I would have expected ControlGetHandle("[CLASS:ZElementClient Window]", "", "") to have worked, did you look at the return and @error values? If there is no control info then you can do something like WinActivate($hwnd) Send("{1}") Opt("WinTitleMatchMode", 3) $hwnd = WinGetHandle("Element Client") ConsoleWrite("Window handle is " & $hwnd & @CRLF) WinActivate($hwnd) Send("{1}") You need control info to send keys to a control via ControlSend. If you can get something for ClassnameNN then you can use it. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
BitByte Posted June 10, 2009 Author Posted June 10, 2009 Thanks for the fast reply and help By the way, if I use WinActivate then it means the game window can't be minimized while my bot is running.
SuneC Posted June 10, 2009 Posted June 10, 2009 ControlSend() works on windows. For example, I can use it to send keypresses to Guild Wars if I wanted to by simply doing: ControlSend("Guild Wars", "", "", "Testing") So that method should work, if not, then maybe your game has some kind of protection against it.
BitByte Posted June 10, 2009 Author Posted June 10, 2009 Nope, it don't work with ControlSend("Guild Wars", "", "", "Testing") and this game don't have any protection
bo8ster Posted June 11, 2009 Posted June 11, 2009 Thanks for the fast reply and help By the way, if I use WinActivate then it means the game window can't be minimized while my bot is running.Yes and No. You can minimize your Window however Send sends to the active window so it must be active, not minimized. I have asked MVPs and Devs on the forum so I feel confident saying, there is no way known to send (using Send()) keystrokes to a inactive window. Without control info your options are limited. Yes it is possible to use ControlSend for a Window but AutoIt needs to get a handle to the window. What did the ConsoleWrite produce?Using WinGetHandle is not required however ControlSend will use a similar technique under the hood, doing something like a DLL call to the function FindWindow to get the window information. If you can't get a handle using WinGetHandle you have little chance of getting ControlSend to work using the same params. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]
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