i am trying to make a hotkey script for Mu Online. The key is Home, the timing is 3 minutes between set of strokes. But there is a hitch - Hotkey has to be pressed once for a feature disable, wait for 1 second and then again press the hotkey for feature enable.
I've tried doing this with a keyboard macro but the keys don't register.
Here's how it looks there: Home - 1000ms - Home - 180000 - repeat.
I got this far, but pressing numpad0 doesn't do anything.
Code: Select all
#NoEnv
#singleInstance, Force
#MaxThreadsPerHotkey, 2
SetBatchLines, -1
DetectHiddenWindows, On
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
SetTitleMatchMode, 2
SetKeyDelay, 30,50
SetMouseDelay 10
SendMode Event
key2send = {home} ;<-- change this key to the key you want to actually send
Gosub WinSetupStuff
#Persistent
Gosub Timer1s
Gosub Timer3m
Return
;=================================================
;get the game window unique instance id
;-------------------------------------------------
!w:: ;<-- Setup window id
WinSetupStuff:
Suspend On
While (!GetKeyState("NumPad0","P"))
{ ToolTip, Left Click on your game window and press NumPad0 to grab the window id
}
KeyWait, NumPad0
WinGet, vWinID,ID,A
Suspend, Off
ToolTip
vWinID = ahk_id %vWinID%
WinGetTitle, vWinName, %vWinID%
Return
;=================================================
; this is the timer that sends to the game window
;-------------------------------------------------------------------------
Timer3m:
IfWinExist, %vWinID%
{
ControlSend,,%key2send%, %vWiniD%
Sleep 500
}
SetTimer, Timer3m, 180000
Return
Timer1s:
IfWinExist, %vWinID%
{
ControlSend,,%key2send%, %vWiniD%
Sleep 500
}
SetTimer, Timer1s, 1000
Return
esc:: ExitApp
I tried something else but this still doesn't work.
Code: Select all
#NoEnv
#singleInstance, Force
#MaxThreadsPerHotkey, 2
SetBatchLines, -1
DetectHiddenWindows, On
CoordMode, Mouse, Screen
CoordMode, Pixel, Screen
CoordMode, Tooltip, Screen
SetTitleMatchMode, 2
SetKeyDelay, 30,50
SetMouseDelay 10
SendMode Event
key2send = {Home} ;<-- change this key to the key you want to actually send
#Persistent
Gosub Timer1s
Gosub Timer3m
Return
;=================================================
; this is the timer that sends to the game window
;-------------------------------------------------------------------------
Timer3m:
IfWinExist('ahk_exe play.exe')
{
ControlSend,,%key2send%, ahk_exe play.exe
Sleep 500
}
SetTimer, Timer3m, 180000
Return
Timer1s:
IfWinExist('ahk_exe play.exe')
{
ControlSend,,%key2send%, ahk_exe play.exe
Sleep 500
}
SetTimer, Timer1s, 1000
Return
esc:: ExitApp