1 / 15

Week3

Week3. Functions and HotKeys. Finish Old Code from Before. Your Turn. Make a program that clicks on the start menu Clicks on “All Programs” if it is there Scrolls upwards all the way to the top Clicks on a web browser Sends the tag http://www.google.com/finance?q=ntdoy

telyn
Download Presentation

Week3

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. Week3 Functions and HotKeys

  2. Finish Old Code from Before

  3. Your Turn • Make a program that clicks on the start menu • Clicks on “All Programs” if it is there • Scrolls upwards all the way to the top • Clicks on a web browser • Sends the tag http://www.google.com/finance?q=ntdoy • Drags over and copies the stock price • Displays the data in a Msgbox

  4. Hints http://www.autoitscript.com/autoit3/docs/functions.htm • MouseClick • MouseClickDrag • MouseMove • MouseWheel • ClipGet/ClipPut • Send • Sleep • Msgbox

  5. Functions • A function is like y(t) = 5*t • In AutoIt we used the word “Func”

  6. Example Code $x = 1 $y = 2 $z1 = $x + $y $z2 = Add($x,$y) Msgbox(0,$z1, $z2) FuncAdd($a,$b) return $a + $b EndFunc

  7. Why do you think this is useful?

  8. HotKeys, Grab By Function Name HotKeySet("{ESC}", “Quit") for $i = 0 to 1000 TrayTip("", $i, 1) sleep(100) Next Func Quit() Exit EndFunc

  9. Let’s Delay a Program from running • Take your main code an put it in a function • Don’t let that code run until a Key is Pressed

  10. HotKeySet("{ESC}", "Quit") HotKeySet("{SPACE}", "MoveMouse") for $i = 0 to 1000 TrayTip("", $i, 1) sleep(100) Next FuncMoveMouse() $end = 500 For $x = 0 to $end/2 step 100 $y = $end - $x MouseMove($x,$x, 2) MouseMove($y, $x, 2) MouseMove($y, $y, 2) MouseMove($x,$y, 2) Next EndFunc Func Quit() Exit EndFunc

  11. Primary Method for Logic • Operators: Think of it like Math Logic • http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm • Primary Methods: • If Statements • While Loops

  12. While Loops –Less Than Func Start() $count = 1 while $count < 3 Msgbox(0,"", $count) $count+=1 WEnd EndFunc

  13. While Loops –Less Than or Equal Func Start() $count = 1 while $count <= 3 Msgbox(0,"", $count) $count+=1 WEnd EndFunc

  14. While Loop – Equals Statement Func Start() $count = 1 while $count < 4 while $count == 2 Msgbox(0,"", $count) WEnd $count+=1 WEnd EndFunc

  15. If Statement • Like a While –Loop, but occurs only once. Meaning, no loop. Func Start() $count = 1 while $count < 4 If $count == 1 Then Msgbox(0,"", "a") ElseIf $count == 2 Then MsgBox(0,"", "b") Else Msgbox(0,"", "nothing") endif $count+=1 WEnd EndFunc

More Related