4ggr35510n Posted August 31, 2010 Share Posted August 31, 2010 (edited) On this YT movie (presenting MS Minesweeper bot, I hope this doesn't qualifies to forbidden game-bots topics ;D): We can clearly see, that the script modifies Minesweeper window, adding buttons "Exit" and "Defuse". How come? How it is possible? How can I do same thing? Thank for your answers! BR,4gr@Edit: Okay, I've found source code of this program.Apparently, those buttons are just a small GUI window, bounded (and even not in smart way) to Minesweeper window.But still... Is there any way to actual modify windows of other programs? Or rather not? Source code of this minesweeper bot (added three lines [selecting name/lang ver, since I've not-eng windows] by myself, whole credit is QBall) for curious. Kinda nice anyway. Doesn't work with win7, since it's using "hack/bug" present only in older MS OS's. expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #NoTrayIcon If WinExists('Defuse') Then Exit ; Ur language version of game name $WindowName = 'Minesweeper' ;minesweeper in ENG $aq = 0 While 1 If WinExists($WindowName) Then Else GUICreate('Defuse', 150, 45) GUICtrlCreateLabel('Start Saper to begin!', 10, 0, 135, 15) GUICtrlCreateLabel('Created by: Sean Buckley', 10, 15, 135, 15) GUICtrlCreateLabel('Email: Q-BALL@mail.com', 10, 30, 135, 15) GUISetState() EndIf Do $m = GUIGetMsg() If $m = -3 Then Exit Until WinExists($WindowName) GUIDelete() GUICreate('Defuse', 77, 17, -100, -100, $WS_POPUP, $WS_EX_TOPMOST) $exit = GUICtrlCreateButton('Exit', -1, -1, 30, 19) $gob = GUICtrlCreateButton('Defuse', 38, -1, 40, 19) GUISetState() WinActivate($WindowName) While WinExists($WindowName) $m = GUIGetMsg() If $m = -3 Or $m = $exit Then Exit If $m = $gob Then first() If WinActive($WindowName) Or WinActive('Defuse') Then $i = WinGetPos($WindowName) If IsArray($i) Then WinMove('Defuse', '', $i[0] + 80, $i[1] + 30) Else WinMove('Defuse', '', -100, -100) EndIf $dimention = WinGetClientSize($WindowName) If IsArray($dimention) Then If $dimention[0] = 500 Then $hibox = 16 $widebox = 30 EndIf If $dimention[0] = 276 Then $hibox = 16 $widebox = 16 EndIf If $dimention[0] = 164 Then $hibox = 9 $widebox = 9 EndIf EndIf WEnd GUIDelete() WEnd Func first() $qw = 0 WinActivate($WindowName) $dimention = WinGetClientSize($WindowName) If $dimention[1] = 319 Then If $dimention[0] = 500 Then $qw = 1 If $dimention[0] = 276 Then $qw = 1 EndIf If $dimention[1] = 207 Then If $dimention[0] = 164 Then $qw = 1 EndIf If $qw = 1 Then second() Else MsgBox(0, 'Error', 'Unrecognized window.' & @CRLF & 'Defuse works only with the three standard levels.' & @CRLF & 'This error can also be caused by a title bar width other than 25.') EndIf EndFunc ;==>first Func second() BlockInput(1) $dimention = WinGetClientSize($WindowName) WinActivate($WindowName) Send('xyzzy') Send('+{enter}') $qqpos = WinGetPos($WindowName) MouseMove($qqpos[0] + 20, $qqpos[1] + 110, 0) $pos = MouseGetPos() MouseMove($pos[0] - 16, $pos[1], 0) $hi = 0 $ii = 0 Do $wide = 0 $hi = $hi + 1 Do $wide = $wide + 1 d() If WinActive($WindowName) Then Else $ii = 1 EndIf Until $wide = $widebox Or $ii $pos = MouseGetPos() MouseMove($pos[0] - 16 * $widebox, $pos[1] + 16, 0) Until $hi = $hibox Or $ii WinActivate($WindowName) Send('xyzzy') Send('+{enter}') SplashTextOn('', '', 1, 1, 0, 0, 1) SplashOff() BlockInput(0) EndFunc ;==>second Func d() $pos = MouseGetPos() MouseMove($pos[0] + 16, $pos[1], 0) Sleep(1) main() EndFunc ;==>d Func main() $color = PixelSearch(0, 0, 1, 1, 0xFFFFFF) If $color = 1 Then Else MouseClick('main') EndIf EndFunc ;==>main Func done() Exit EndFunc ;==>done Edited August 31, 2010 by 4ggr35510n Link to comment Share on other sites More sharing options...
kaotkbliss Posted August 31, 2010 Share Posted August 31, 2010 While I can see the extreme usefulness of being able to do this, I can also see the extreme harm someone with little knowledge could cause if code were to start being put up. I would think that to do what you suggest would involve creating a program that could modify an existing program, much like a -censored- does. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 31, 2010 Share Posted August 31, 2010 If your controls were placed into the window of another program, that program would receive the window messages associated with the controls and not yours. You'd have a huge mess trying to get the controls there and reading the messages will be just as complicated. 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