Code:
#include <ImageSearch.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
Global Const $VK_DELETE = 0x2E
Global Const $VK_ESCAPE = 0x1B
Global $hFunc,$pFunc,$hHook,$hMod
Global $x=0,$y=0,$result,$window="Mabinogi"
Opt("OnExitFunc","_cleanUp")
$hFunc = DllCallbackRegister('_KeyboardHook', 'lresult', 'int;uint;uint')
$pFunc = DllCallbackGetPtr($hFunc)
$hMod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, $pFunc, $hMod)
MsgBox(0,"Notice","Click OK to start")
If Not WinActive($window) Then WinActivate($window)
Sleep(3000)
While 1
If WinActive($window) Then
Send ("{F3}") ; Smash Hotkey
Send ("{ALTDOWN}")
Send ("{CTRLDOWN}")
Sleep (500)
If $x = 0 Then
Local $pos = MouseGetPos()
$x = $pos[0]
$y = $pos[1]
EndIf
MouseClick ("primary",$x,$y,4,100)
Sleep (500)
Send ("{CTRLUP}")
Sleep (4000)
$result = _ImageSearch("Fomor.png",1,$x,$y,100)
If $result = 1 Then ; If there is a fomor scroll, pick it up
MouseMove($x,$y,0)
Sleep (250)
MouseClick("primary",$x,$y,1)
Sleep(1000)
EndIf
$result = _ImageSearch("Gold.png",1,$x,$y,100)
If $result = 1 Then ; If there is gold on the ground, pick it up
MouseMove($x,$y,0)
Sleep (250)
MouseClick("primary",$x,$y,1)
Sleep(1000)
EndIf
Send ("{ALTUP}")
Else
Sleep(1000)
EndIf
WEnd
;Functions
Func _cleanUp()
ControlSend("", "", "", "text", 0)
Send("{ALTUP}")
Send("{CTRLUP}")
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallbackFree($hFunc)
EndFunc
Func _KeyboardHook($iCode, $iwParam, $ilParam)
Local $tKBDLLHS = DllStructCreate($tagKBDLLHOOKSTRUCT, $ilParam)
Local $iVkCode
If $iCode > -1 Then
$iVkCode = DllStructGetData($tKBDLLHS, 'vkCode')
If $iwParam = $WM_KEYUP Then
Switch $iVkCode
Case $VK_ESCAPE
;Exits.
Exit(0)
Case $VK_DELETE
;Short pause.
Sleep(10000)
EndSwitch
EndIf
EndIf
Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc