Created
June 12, 2025 04:01
-
-
Save dvgamerr/3dadbab14792c598517ab963a8ea57f0 to your computer and use it in GitHub Desktop.
AutoHotkey script ที่ช่วยให้คอมพิวเตอร์ไม่เข้าโหมด Sleep โดยการเลื่อนเมาส์อัตโนมัติ / กด F9 เพื่อเปิด/ปิดการทำงาน
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SingleInstance force | |
#Requires AutoHotkey >=v2.0 | |
CoordMode('Mouse', 'Screen') | |
CoordMode('ToolTip', 'Screen') | |
/** * * * * * CONFIGURATION * * * * * | |
* Add your details here. | |
* Coordinates should be in [x, y] format | |
* Interval is in milliseconds | |
* I modified your original concept to instead use only one hotkey. If MouseMover is on, | |
* F9 turns it off. If MouseMover is off, F9 turns it on. | |
*/ | |
F9::ActivateMouseMover({ | |
coord1: [0, 0], | |
coord2: [100, 40], | |
interval: 1000 | |
} | |
) | |
; * * * * * END CONFIGURATION * * * * | |
global mover | |
ActivateMouseMover(inputObject) { | |
global mover | |
if (!IsSet(mover)) { | |
mover := MouseMover(inputObject) | |
} | |
if (mover.toggle) { | |
mover.Stop() | |
} else { | |
mover.Start() | |
} | |
} | |
class MouseMover { | |
__New(inputObject) { | |
this.coord1 := inputObject.coord1 | |
this.coord2 := inputObject.coord2 | |
this.interval := inputObject.interval | |
this.toggle := false | |
this.switch := false | |
this.timer := ObjBindMethod(this, "MoveMouseOnInterval") | |
} | |
MoveMouseOnInterval() { | |
if (this.switch) { | |
MouseMove(this.coord1[1], this.coord1[2]) | |
this.switch := false | |
} else { | |
MouseMove(this.coord2[1], this.coord2[2]) | |
this.switch := true | |
} | |
} | |
Start() { | |
SetTimer(this.timer, this.interval) | |
this.toggle := true | |
this.DisplayTooltip("MouseMover is on") | |
} | |
Stop() { | |
SetTimer(this.timer, 0) | |
this.toggle := false | |
this.DisplayTooltip("MouseMover is off") | |
} | |
DisplayTooltip(str) { | |
MouseGetPos(&x, &y) | |
ToolTip(str, x, y) | |
SetTimer(() => ToolTip(), -2000) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment