1 / 14

Debugging, Console Writing, PixelSearching

Debugging, Console Writing, PixelSearching. Week 5. Debugging Code. We’ve become familiar with Msgbox and TrayTip When would you want to use Msgbox ? When would you want to use TrayTip ?. ConsoleWrite – Look at SciTE.

aaron
Download Presentation

Debugging, Console Writing, PixelSearching

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Debugging, Console Writing, PixelSearching Week 5

  2. Debugging Code • We’ve become familiar with Msgbox and TrayTip • When would you want to use Msgbox? • When would you want to use TrayTip?

  3. ConsoleWrite – Look at SciTE ;All future code should include this template http://cl1p.net/123456789 HotKeySet("{ESC}", "Quit") HotKeySet("{SPACE}", "Start") HotKeySet("{F1}","CloseWindow") While 1 Sleep(100) Wend Func Start() ConsoleWrite("data") EndFunc Func Quit() Exit EndFunc

  4. Why would we want ConsoleWrite? What do you think?

  5. ConsoleWrite • Modify Our Browser Program to ConsoleWrite when Notepad or FireFox Opens • Also, make each output separated by a carriage return. Look online how to find this (Hint: Use a domain search of autoitscript.com) • I’ve attached last weeks old code

  6. ;All future code should include this template http://cl1p.net/123456789 HotKeySet("{ESC}", "Quit") HotKeySet("{SPACE}", "Start") HotKeySet("{F1}","CloseWindow") While 1 Sleep(100) Wend Func Start() $val = inputbox("","Type in your Program") If $val == "notepad" Then run("notepad.exe") WinWaitActive("[Class:Notepad]") Send("Hello") ElseIf $val == "firefox" Then run("C:\Program Files\Mozilla Firefox\firefox.exe") WinWaitActive("[Class:MozillaUIWindowClass]") ControlClick("[Class:MozillaUIWindowClass]","","[CLASS:MozillaWindowClass; INSTANCE:1]","left",1,384, 35) sleep(10) ControlSend("[CLASS:MozillaUIWindowClass]", "","[CLASS:MozillaWindowClass; INSTANCE:1]" , "http://www.google.com{ENTER}") WinWaitActive("Google") Else Traytip("Wrong Input", $val, 10) Start() EndIf EndFunc Func Quit() Exit EndFunc FuncCloseWindow() If WinActive("[Class:Notepad]") Then WinClose("[Class:Notepad]") ElseIfWinActive("[Class:MozillaUIWindowClass]") Then WinClose("[Class:MozillaUIWindowClass]") EndIf EndFunc

  7. Create your own Executable Program • Go to U:\MURT 102\install\Aut2Exe • Choose Your Source File .au3 • Choose a new name for your program • Double click it and run it. • Notice how the ConsoleWrite doesn’t appear

  8. PixelSearching ; Find a pure red pixel in the range 0,0-20,300 $coord = PixelSearch( 0, 0, 230, 300, 0x0019B8 ) If Not @error Then MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) EndIf ; Find a pure red pixel or a red pixel within 10 shades variations of pure red $coord = PixelSearch( 0, 0, 20, 300, 0x0019B8, 10 ) If Not @error Then MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) EndIf

  9. PixelSearch • Can you modify this so the coordinates are displayed with ConsoleWrite • Can you modify this so it moves the mouse to the PixelSearch Coordinate?

  10. Food for Thought • Look Up Other Pixel Functions • How Might we use a pixel function to find text super fast?

  11. Pixel Search Game • Make a program that plays Wacky Wack a Mole http://james.site90.net/upload/2011February17th129800505337flash.html

  12. PixelSearch Game • Make it Search for a Brown Pixel (it is the same color as the Clickhere Banner) • Forget ControlClick, it is a bit buggy. Instead use it to create an offset. We’ll do the same effect • We don’t need to use a for-loop in PixelSearch • I’m Providing Skeleton Code • No Solution Until Next Week

  13. Skeleton Code ;All future code should include this template http://cl1p.net/123456789 HotKeySet("{ESC}", "Quit") HotKeySet("{SPACE}", "Start") While 1 Sleep(100) Wend Func Start() WinActivate("[Class:IEFrame]") $controlXOffset = 22 ;%Your Window Position Here $controlYOffset = 146 ;Your Window Position Here ConsoleWrite("X:= " & $controlXOffset & " Y:= " & $controlYOffset) ;ControlClick("[Class:IEFrame]","","[CLASS:MacromediaFlashPlayerActiveX; INSTANCE:1]","left",1,201, 173) ;Get through the Start Menu MouseClick("left", 201 + $controlXOffset, 173 + $controlYOffset, 1) Sleep(100) MouseClick("left", 232 + $controlXOffset, 254 + $controlYOffset, 1) Sleep(100) MouseClick("left", 225 + $controlXOffset, 230 + $controlYOffset, 1) for $i = 1 to 300 $coord = PixelSearch(…) If Not @error Then ConsoleWrite("X:= " & $coord[0] & " Y:= " & $coord[1] & @CRLF) EndIf next EndFunc ;==>Start Func Quit() Exit EndFunc ;==>Quit

  14. Solution ;All future code should include this template http://cl1p.net/123456789 HotKeySet("{ESC}", "Quit") HotKeySet("{SPACE}", "Start") While 1 Sleep(100) Wend Func Start() WinActivate("[Class:IEFrame]") $controlXOffset = 22 ;%Your Window Position Here $controlYOffset = 146 ;Your Window Position Here ConsoleWrite("X:= " & $controlXOffset & " Y:= " & $controlYOffset) ;ControlClick("[Class:IEFrame]","","[CLASS:MacromediaFlashPlayerActiveX; INSTANCE:1]","left",1,201, 173) ;Get through the Start Menu MouseClick("left", 201 + $controlXOffset, 173 + $controlYOffset, 1) Sleep(100) MouseClick("left", 232 + $controlXOffset, 254 + $controlYOffset, 1) Sleep(100) MouseClick("left", 225 + $controlXOffset, 230 + $controlYOffset, 1) for $i = 1 to 300 $coord = PixelSearch(9+$controlXOffset, 133 + $controlYOffset, 491+$controlXOffset, 336+$controlYOffset, 0x8D5801, 10, 20) If Not @error Then ConsoleWrite("X:= " & $coord[0] & " Y:= " & $coord[1] & @CRLF) MouseClick("left", $coord[0], $coord[1]) EndIf next ;0xFF0000 ;0x770000 EndFunc ;==>Start Func Quit() Exit EndFunc ;==>Quit

More Related