commit 655355f34af0c1a59e9d46f2ddfe6d0fb4042a33 Author: Connor Date: Sun Nov 8 17:00:37 2020 -0800 diff --git a/phasmo.ahk b/phasmo.ahk new file mode 100644 index 0000000..a71cd93 --- /dev/null +++ b/phasmo.ahk @@ -0,0 +1,133 @@ +#SingleInstance Force +#IfWinActive ahk_exe Phasmophobia.exe +Return + +; 1 = EMF Reader +; 2 = Flashlight +; 3 = Photo Camera +; 4 = Lighter +; 5 = Candle +; 6 = UV Light +; 7 = Crucifix +; 8 = Video Camera +; 9 = Spirit Box +; 10 = Salt +; 11 = Smudge Sticks +; 12 = Tripod +; 13 = Strong Flashlight +; 14 = Motion Sensor +; 15 = Sound Sensor +; 16 = Thermometer +; 17 = Sanity Pills +; 18 = Ghost Writing Book +; 19 = Infrared Light Sensor +; 20 = Parabolic Microphone +; 21 = Glowstick +; 22 = Head Mounted Camera + +*,:: +; add just the stuff you need. +Prologue("ahk_class UnityWndClass", mouseX, mouseY) +PhasmoAdd(2) ; Flashlight +PhasmoAdd(3) ; Photo Camera +PhasmoAdd(4) ; Lighter +PhasmoAdd(7) ; Crucifix +PhasmoAdd(8) ; Video Camera +PhasmoAdd(10) ; Salt +PhasmoAdd(11) ; Smudge Sticks +PhasmoAdd(12) ; Tripod +PhasmoAdd(13,2) ; Strong Flashlight (x2) +PhasmoAdd(14) ; Motion Sensor +PhasmoAdd(16) ; Thermometer +PhasmoAdd(17,4) ; Sanity Pills (x4) +PhasmoAdd(21) ; Glowstick +PhasmoAdd(22) ; Head Mounted Camera +Epilogue(mouseX, mouseY) +Return + +*;:: +; add one of everything. +Prologue("ahk_class UnityWndClass", mouseX, mouseY) +Loop 22 { + PhasmoAdd(A_Index) +} +Epilogue(mouseX, mouseY) +Return + +*':: +; remove one of everything. +Prologue("ahk_class UnityWndClass", mouseX, mouseY) +Loop 22 { + PhasmoRemove(A_Index) +} +Epilogue(mouseX, mouseY) +Return + +; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; +; internal stuff from hereon ; +; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; + +GetClientSize(hwnd, ByRef w, ByRef h) +{ + VarSetCapacity(rc, 16) + DllCall("GetClientRect", "uint", hwnd, "uint", &rc) + w := NumGet(rc, 8, "int") + h := NumGet(rc, 12, "int") +} + +Prologue(hint, ByRef mouseX, ByRef mouseY) +{ + global winW, winH + hwnd := WinExist(hint) + GetClientSize(hwnd, winW, winH) + SetDefaultMouseSpeed 0 + SetMouseDelay 0 + CoordMode Mouse, Screen + MouseGetPos mouseX, mouseY ; store mouse position to restore later + CoordMode Mouse, Client +} + +Epilogue(mouseX, mouseY) +{ + CoordMode Mouse, Screen + MouseMove mouseX, mouseY ; restore original mouse position + Sleep 100 ; prevent accidental repetition of macro +} + +PhasmoAdd(id, n:=1) +{ + global winW, winH + fakeW := 1.6 * winH + off := (winW - fakeW) / 2 + If id between 1 and 15 + MouseMove % off + fakeW * 0.41, winH * (id + 11.5) / 37.1 + If id between 16 and 22 + MouseMove % off + fakeW * 0.72, winH * (id - 3.5) / 37.1 + Sleep 10 + Click + Loop % n - 1 + { + Sleep 60 + Click + } + Sleep 10 +} + +PhasmoRemove(id, n:=1) +{ + global winW, winH + fakeW := 1.6 * winH + off := (winW - fakeW) / 2 + If id between 1 and 15 + MouseMove % off + fakeW * 0.435, winH * (id + 11.5) / 37.1 + If id between 16 and 22 + MouseMove % off + fakeW * 0.745, winH * (id - 3.5) / 37.1 + Sleep 10 + Click + Loop % n - 1 + { + Sleep 50 + Click + } + Sleep 10 +}