diff --git a/phasmo.ahk b/phasmo.ahk new file mode 100644 index 0000000..d50eaf5 --- /dev/null +++ b/phasmo.ahk @@ -0,0 +1,125 @@ +#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,2) ; Tripod (x2) +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 +} + +PhasmoClick(relX, relY, n:=1) +{ + global winW, winH + fakeW := 1.6 * winH + off := (winW - fakeW) / 2 + MouseMove % off + fakeW * relX, winH * relY + Sleep 10 + Click + Loop % n - 1 + { + Sleep 60 + Click + } + Sleep 10 +} + +PhasmoAdd(id, n:=1) +{ + If id between 1 and 15 + PhasmoClick(0.41, (id + 11.5) / 37.1, n) + If id between 16 and 22 + PhasmoClick(0.72, (id - 3.5) / 37.1, n) +} + +PhasmoRemove(id, n:=1) +{ + If id between 1 and 15 + PhasmoClick(0.435, (id + 11.5) / 37.1, n) + If id between 16 and 22 + PhasmoClick(0.745, (id - 3.5) / 37.1, n) +}