Jump to content

Cannot target window


Recommended Posts

I'm just a beginner for autoit. I found this program very useful so I begin to learn. My problem is I use controlsend command to target a window but it dont work when I minimize or click another window. Hero is my simple script. Pls advice and guide...thanks

WinExists("Water Margin Online")

While 1

ControlSend("Water Margin Online", "", "", "{F9}")

Sleep (4000)

ControlSend("Water Margin Online", "", "", "{F3}")

Sleep (1500)

ControlSend("Water Margin Online", "", "", "{F1}")

Sleep (30000)

ControlSend("Water Margin Online", "", "", "{F3}")

Sleep (1500)

WEnd

My simple noob bot, hehe!

Link to comment
Share on other sites

But the game don't have a ControlID

Press CTRL-ALT-F to freeze the display.

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: Water Margin Online

Class: Darkstar Window Class

Size: X: 611 Y: 83 W: 646 H: 512

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 779 Y: 103

Cursor ID: 2

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x0164F9 Dec: 91385

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size:

Control ID:

ClassNameNN:

Text:

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

I know the command Send but I want to send commands to the game (minimized) while I'm browsing with my IE. My friend used autoit (older version) to created an exe like macro and it work well also when then window is minimized but he refuse to tell me the source :D I hope that some one could guide me here ... Thanks in advance :P

Link to comment
Share on other sites

Not sure if this would give you anything but have you tried WinGetHandle to give you the control ID of the game window?

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

Can you teach me how can WinGetHandle to give me the control ID of the game window and ControlSend command to the window because all the help file show is this:

; Identify the Notepad window that contains the text "this one" and get a handle to it

; Change into the WinTitleMatchMode that supports classnames and handles

AutoItSetOption("WinTitleMatchMode", 4)

; Get the handle of a notepad window that contains "this one"

$handle = WinGetHandle("classname=Notepad", "this one")

If @error Then

MsgBox(4096, "Error", "Could not find the correct window")

Else

; Send some text directly to this window's edit control

ControlSend($handle, "", "Edit1", "AbCdE")

EndIf

Thanks...

Link to comment
Share on other sites

I have to say I haven't ever used autoit in a game so I might be missing something but this code below works as far as getting a window's handle and using it in controlsend...

Run("notepad.exe")
WinWaitActive("Untitled - Notepad", "")
$handle = WinGetHandle("Untitled - Notepad", "")
If @error Then
MsgBox(4096, "Error", "Could not find the correct window")
Else
ControlSend("Untitled - Notepad", "", $handle, "Sending text to control ID of notepad")
EndIf

Hopefully that helps you out!

Andrew

Edited by someone
While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
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...