i have a AHK Script for the Game Realm of the Mad God.
There are two Issues i can't solve.
1. The say function sometimes "leaks" my previous clipboard.
example: i have something in clipboard like a youtube link and despite the fact that i check the clipboard if it contains the message it posts the youtube link instead of the message.
2. at somepoint i get weird behaviour like i didn't use a return correctly. i can't use the F keys and when i press ctrl+c it actually paste some of the script.
i can't find the place where i did something wrong.
Any Tips are greaty appreciated.
here is the script on pastebin: https://pastebin.com/GdXjGkWi
and here in code tag:
Code: Select all
#SingleInstance Force
#Persistent
#NoEnv
SetWorkingDir %A_ScriptDir%
SendMode Input
SetKeyDelay 0
SetMouseDelay 0
SetTitleMatchMode 3
GroupAdd rotmg, % "Realm of the Mad God"
GroupAdd rotmg, % "Realm of the Mad God - Google Chrome"
Loop
{
Process, Exist, Realm of the Mad God.exe
{
If errorLevel
{
WinSet, Style, -0x40000, ahk_class ApolloRuntimeContentWindow
WinMove, ahk_class ApolloRuntimeContentWindow,,,, 806, 629
}
}
Sleep, 5000
}
#IfWinActive ahk_class Chrome_WidgetWin_1
^+a::
{
Run, "C:\Users\<<USERNAME>>\Documents\Rotmg\Notepad++ Portable\Notepad++Portable.exe"
Return
}
#IfWinActive
#IfWinActive ahk_group rotmg
F1::
{
takeScreenshot()
Return
}
F3::
{
sendChat("Heal Please")
Return
}
F4::
{
sendChat("Thanks!")
Return
}
F5::
{
InputBox, tradingmsg, Trading message, Please enter a trading message:,,,,,,,,%tradingmsg%
keep_x_running = y
Loop,
{
ifWinActive Realm of the Mad God
{
If keep_x_running = y
{
sendChat(tradingmsg)
}
Else
{
Return
}
}
Sleep, 1500
}
Return
}
F6::
{
keep_x_running = n
Return
}
F7::
{
sendChat("/nexustutorial")
Return
}
F8::
{
sendChat("/tell mreyeball password")
Return
}
F9::
{
sendChat("/tell mreyeball stats")
Return
}
F10::
{
sendChat("/tell mreyeball lefttomax")
Return
}
F11::
{
sendChat("/tell mreyeball mates")
Return
}
F12::
{
sendChat("/tell mreyeball server")
Return
}
^+S::
{
Run, %A_ScriptDir%\MoveScreenshots.ahk
Return
}
X::
{
;swapItem(640,420) Slot 1
;swapItem(680,420) Slot 2
;swapItem(720,420) Slot 3
swapItem(760,420) Slot 4
Return
}
LAlt::
{
takeScreenshot()
Return
}
Numpad1::
{
sendChat("ready")
Return
}
NumpadEnd::
{
sendChat("ready")
Return
}
Numpad2::
{
sendChat("He lives and reigns and conquers the world")
Return
}
NumpadDown::
{
sendChat("He lives and reigns and conquers the world")
Return
}
+WheelUp::
{
Send {PgUp}
Return
}
+WheelDown::
{
Send {PgDn}
Return
}
XButton2::
{
SendInput I
Return
}
XButton1::
{
swapItem(640,420)
Return
}
MButton::
{
SendInput N
Return
}
SC028::
{
SendInput ae
Return
}
SC027::
{
SendInput oe
Return
}
SC01A::
{
SendInput ue
Return
}
+SC028::
{
SendInput AE
Return
}
+SC027::
{
SendInput OE
Return
}
+SC01A::
{
SendInput UE
Return
}
SC00C::
{
SendInput ss
Return
}
sendChat(Message)
{
ClipSaved = %ClipboardAll%
ClipWait
Clipboard = %Message%
ClipWait
Loop,
If Clipboard = %Message%
{
Blockinput, on
Send {Enter}
Send ^v
Send {Enter}
Blockinput, off
Break
}
Sleep, 100
Clipboard = %ClipSaved%
Return
}
takeScreenshot()
{
IniRead, OutputVar, %A_ScriptDir%\<<ININAME>>.ini, <<INIVAR>>, Switch
If (%OutputVar% == 0)
{
Run, "%A_ScriptDir%\Ifran View\i_view64.exe" /capture=2 /convert=C:\Users\<<USERNAME>>\Documents\Rotmg\Screenshots\Rotmg_$U(`%Y-`%m-`%d_`%H`%M`%S) %A_TickCount%.png
Return
}
Else
{
Run, "%A_ScriptDir%\Ifran View\i_view64.exe" /capture=2 /convert=<<PATH>><<USERNAME>>\Screenshots\Rotmg_$U(`%Y-`%m-`%d_`%H`%M`%S) %A_TickCount%.png
Return
}
}
swapItem(xPos,yPos)
{
MouseGetPos, mousePosX, mousePosY ; mousePosX/Y have old mouse position
WinGetPos, , , winSizeX, winSizeY, Realm of the Mad God ; winSizeX/Y have window size
BlockInput, on
CoordMode, Mouse, Relative
MouseMove, %xPos%, %yPos%
SendEvent {Control Up}
SendEvent {LButton Down}
SendEvent {LButton Up}
SendEvent {LButton Down}
SendEvent {LButton Up}
CoordMode, Mouse, Window
MouseMove, mousePosX, mousePosY
If (LB == "D") {
Send {LButton down}
}
BlockInput, off
Return
}
#IfWinActive