If you are really interested in making this bot, you should probably look into "SCAR Divi":
It has built in mouse/keyboard automatization procedures + pattern (image/color) recognition + example scripts.
It was actually made for the specific purpose of botting in Runescape and was extremely good at it until more advanced methods were discovered.
The complexity/purpose of such a script is another issue...
Dodging enemy bullets would be pretty complicated, not to mention lag / other players / crowds of monsters have to be taken into account.
I personally sometimes use automated pick-upper... although it was more useful when there was only the drag-and-drop pick-up.
Maybe there are other usages too...