Hotkey for Mu Online

Ask gaming related questions
Runner
Posts: 3
Joined: 11 Dec 2017, 20:21

Hotkey for Mu Online

11 Dec 2017, 20:29

Hello!

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
User avatar
jeeswg
Posts: 5266
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Hotkey for Mu Online

12 Dec 2017, 03:04

Try NumpadIns, for when NumLock is off.
Runner
Posts: 3
Joined: 11 Dec 2017, 20:21

Re: Hotkey for Mu Online

12 Dec 2017, 03:48

NumLock is always on.
I tried running it as admin so now pressing numpad0 works but i don't know if it does get the ahk_id.
also tried this, still didn't work.

Code: Select all

#NoEnv
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Window
SendMode Input
#SingleInstance Force
SetTitleMatchMode 2
#WinActivateForce
SetControlDelay 1
SetWinDelay 0
SetKeyDelay -1
SetMouseDelay -1
SetBatchLines -1


Gosub WinSetupStuff

Gosub Macro1
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
	
	
Macro1:
IfWinExist, %vWinID%
Loop
{
    Send, {Home}, %vWiniD%
    Sleep, 1000
    Send, {Home}, %vWiniD%
    Sleep, 180000
}
Return
Runner
Posts: 3
Joined: 11 Dec 2017, 20:21

Re: Hotkey for Mu Online

14 Dec 2017, 04:34

bump

Return to “Gaming”

Who is online

Users browsing this forum: Evil-e and 24 guests