Qousio Posted April 21, 2009 Share Posted April 21, 2009 (edited) Hello. Soo, I have made this script today. I need some help simplifying some parts and I would also like to have these questions answered: #1 Lets say I have a 1280x1024 monitor, and im pixelsearching the coordinates (100,200). This won't work on my friends PC, because his resolution is higher. Is there some way to fix this? The ony thing I thought of is making every coordinate a variable like $x=@desktopwidth / some amount. Like, If I would nee to search the X coordinate 128 I would make a variable $x=@Desktopwidth/10. Which is equal to 128, and would scale with any resolution that has the same aspect ratio as my monitor. Obviously it wouldnt work on a widescreen one.... #2 The script works perfectly fine, BUT sometimes the delay between keystrokes is ALLOT longer. For example, I used this script 10 times in a row. 5 out of 10 times it worked perfectly fine, 4 times it was too slow and 1 time it glitched and didnt work at all. What could be the reason? If I opt SendKeyDelay/SendKeyDownDelay to 0, then its too fast and won't work. Heres the script: expandcollapse popup #include <Misc.au3> Global $DaggerArray Opt( "SendKeyDelay", 1 ) Opt( "SendKeyDownDelay", 1 ) Opt( "MouseClickDelay", 1 ) Opt( "MouseClickDownDelay", 1 ) opt( "MouseCoordMode", 1 ) $dll = DllOpen("user32.dll") WinActivate( "Warcraft III" ) WinWaitActive( "Warcraft III" ) Global $x = 33 Global $y = 61 Checker() Func Checker() Sleep ( 50 ) $DaggerArray = PixelSearch( 834, 668, 834, 668, 0x7126A7 ) If Not IsArray($DaggerArray) Then NoDagger() EndIf If IsArray( $DaggerArray ) Then Dagger() EndIf EndFunc Func Dagger() While 1 Sleep(50) $Meepo2 = PixelSearch(35, 122, 35, 122, 0x0801EC) $Meepo3 = PixelSearch(35, 190, 35, 190, 0x0801EA) $Meepo4 = PixelSearch(33, 260, 33, 260, 0x0701F1) If _IsPressed("14", $dll) And IsArray($Meepo4) Then $Pos = MouseGetPos() ControlSend( "Warcraft III", "", "", "1" ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) MouseMove( $Pos[0], $Pos[1], 0 ) ControlSend( "Warcraft III", "", "", "{NUMPAD7}" ) MouseClick( "left" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) EndIf If _IsPressed("14", $dll) And IsArray($Meepo3) Then $Pos = MouseGetPos() ControlSend( "Warcraft III", "", "", "1" ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) MouseMove( $Pos[0], $Pos[1], 0 ) ControlSend( "Warcraft III", "", "", "{NUMPAD7}" ) MouseClick( "left" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) EndIf If _IsPressed("14", $dll) And IsArray($Meepo2) Then $Pos = MouseGetPos() ControlSend( "Warcraft III", "", "", "1" ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) MouseMove( $Pos[0], $Pos[1], 0 ) ControlSend( "Warcraft III", "", "", "{NUMPAD7}" ) MouseClick( "left" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) EndIf WEnd EndFunc Func NoDagger() While Not IsArray($DaggerArray) $Meepo2 = PixelSearch(35, 122, 35, 122, 0x0801EC) $Meepo3 = PixelSearch(35, 190, 35, 190, 0x0801EA) $Meepo4 = PixelSearch(33, 260, 33, 260, 0x0701F1) $DaggerArray = PixelSearch( 834, 668, 834, 668, 0x7126A7 ) Sleep(15) ;MsgBox( 0, "Woohoo!", $Meepo4[0] & $Meepo4[1] ) ;MsgBox( 0, "Woohoo!", "This function is working ^_^" ) If _IsPressed("14", $dll) And IsArray($Meepo4) Then ControlSend( "Warcraft III", "", "", "1" ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) EndIf If _IsPressed("14", $dll) And IsArray($Meepo3) Then ControlSend( "Warcraft III", "", "", "1" ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) EndIf If _IsPressed("14", $dll) And IsArray($Meepo2) Then ControlSend( "Warcraft III", "", "", "1" ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) ControlSend( "Warcraft III", "", "", "{TAB}" ) ControlSend( "Warcraft III", "", "", "f" ) MouseClick( "left", $x, $y, 1, 0 ) EndIf WEnd EndFunc Checker()oÝ÷ Û÷b¼2¢çÇjV«êZ®Ú¶¡×«z¶È±é_vè¶îËb¢{"²Ø^æ§Ë²¶"b+aÀ,y)ඡ׬©ez±Ò7ökkÊ)à¶kk§zYb¦Ç°ØF¥ºÚ®'¬nëwõh§ëGjwe{p¢{kzÚâ½æ§Ê§vW¬Ùmjëh×6#include <GuiConstantsEx.au3> #include <GDIPlus.au3> AutoItSetOption("WinTitleMatchMode", 4) _Main() Func _Main() Local $hWnd, $hGraphic $hWnd = WinGetHandle("F:\2.au3 * SciTE4AutoIt3 [2 of 2]") If @error Then MsgBox(4096, "Error", "Could not find the correct window") EndIf _GDIPlus_Startup () $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hWnd) While 1 sleep(50) _GDIPlus_GraphicsDrawEllipse ($hWnd, 130, 100, 200, 200) WEnd EndFunc It always shows up an error saying theres no correct window. I have tried multiple windows (even notepad) but It still won't work Edited April 22, 2009 by Qousio Link to comment Share on other sites More sharing options...
Qousio Posted April 22, 2009 Author Share Posted April 22, 2009 Bump. Wonder why I don't get any answers ;( 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