Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
; Set our co-ordinates relative to the active window AutoItSetOption("MouseCoordMode", 0) $registered = false Dim $keys[10][2] While 1 If WinActive("Plants vs. Zombies") Then RegisterKeys() Else UnregisterKeys() EndIf Sleep(100) WEnd ; This function selects the plant associated with the hotkey and moves ; the mouse back into the existing position. Func SelectPlant() If WinActive("Plants vs. Zombies") Then $slot = @HotKeyPressed $slot -= 1; If $slot == -1 Then $slot = 9 EndIf $currentPosition = MouseGetPos() MouseClick("primary", $keys[$slot][0], $keys[$slot][1], 1, 0) MouseMove($currentPosition[0], $currentPosition[1], 0) EndIf EndFunc Func RegisterKeys() If NOT $registered Then $i = 0 $x = 114 $y = 70 While $i < 10 ; Add the plant position to the array $keys[$i][0] = $x $keys[$i][1] = $y ; Register the hotkey for this number HotKeySet($i, "SelectPlant") ; Increase the X value to be the next button $x += 52 $i += 1 WEnd $registered = true EndIf EndFunc Func UnregisterKeys() If $registered Then $i = 0 While $i < 10 HotKeySet($i); $i += 1; WEnd $registered = false EndIf EndFunc
This paste will be private.
From the Design Piracy series on my blog: