Skip to content

Commit ef29d07

Browse files
committed
docs: modernize Thread.sleep to Task.sleep in README
1 parent 1e87a38 commit ef29d07

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,15 @@ if let center = SwiftAutoGUI.locateCenterOnScreen("target.png", confidence: 0.8,
173173
}
174174

175175
// Find all occurrences of an image on screen
176-
let buttons = SwiftAutoGUI.locateAllOnScreen("button.png")
177-
print("Found \(buttons.count) buttons")
178-
for (index, button) in buttons.enumerated() {
179-
print("Button \(index): \(button)")
180-
SwiftAutoGUI.move(to: CGPoint(x: button.midX, y: button.midY))
181-
SwiftAutoGUI.leftClick()
182-
Thread.sleep(forTimeInterval: 0.5)
176+
Task {
177+
let buttons = SwiftAutoGUI.locateAllOnScreen("button.png")
178+
print("Found \(buttons.count) buttons")
179+
for (index, button) in buttons.enumerated() {
180+
print("Button \(index): \(button)")
181+
SwiftAutoGUI.move(to: CGPoint(x: button.midX, y: button.midY))
182+
SwiftAutoGUI.leftClick()
183+
try await Task.sleep(nanoseconds: 500_000_000) // 0.5 seconds
184+
}
183185
}
184186

185187
// locateAllOnScreen with confidence threshold for flexible matching

0 commit comments

Comments
 (0)