Ian
07-23-2013, 09:58 AM
Before reading: I've noticed that there is something in SRL6 to get text from the MainScreen, but I'd made this before thinking to check and SRL6 has not yet been released so I might as well post it now.
So as you may or may not have noticed, there appears to be no UpText in RS3. So you can still check that what you're clicking on is the right thing, I've made IsMouseOverText.
Functions:
function IsMouseoverTextEx(Text, TextType:string): Boolean;
var
x, y, Color: Integer;
begin
Color := 0;
case Lowercase(TextType) of
'action', 'white': Color:= 12378347;
'object', 'cyan': Color:= 16776960;
'npc', 'yellow': Color:= 65535;
'f2pitem', 'pale blue': Color:= 13750712;
'p2pitem', 'orange': Color:= 2131675;
end;
if (Color = 0) then
begin
WriteLn('WARNING! ' + TextType + ' is not a valid TextType!');
Exit;
end;
GetMousePos(x, y);
Result := IsTextInAreaEx(0, 0, 798, 598, x, y, Text, 5, 'UpCharsEx', False, False, 0, 4, Color);
end;
function IsMouseoverText(Text : string) : Boolean; //By Rich
var
I : Integer;
Types : TStringArray;
begin
Types:= ['action', 'object', 'npc', 'f2pitem' 'p2pitem'];
for I:= 0 to 4 do
begin
Result:= IsMouseOverTextEx(Text, Types[I]);
if Result then
Exit;
end;
end;
Requirements for use: Make sure that you have Mouseover text enabled. Enable it in the graphics setting here:
http://i.imgur.com/3GD0dJ8.png
How to choose text:
Choose some text that doesn't have any capitals or odd symbols. Some capitals work but not all, so if your string with a capital doesn't work then try it without.
Do not use multi-line strings, they do not work.
Here's an example of text that you want, the green boxes are around good samples, the red around bad samples:
http://i.imgur.com/wmlyf4e.png
How to use in a script:
Example #1 (http://villavu.com/forum/usertag.php?do=list&action=hash&hash=1) :
if IsMouseoverTextEx('xchange', 'npc') then
begin
WriteLn('Mouse is over the GE clerk!');
ClickMouse(True);
end;
Example #2 (http://villavu.com/forum/usertag.php?do=list&action=hash&hash=2) :
if IsMouseoverText('xchange') then
begin
WriteLn('Mouse is over the GE clerk!');
ClickMouse(True);
end;
The first parameter in IsUptextEx, Text, is the string you've chosen to look for. The second parameter, TextType, is the type of text that you want the function to look for.
IsUptext is the same as IsUptextEx except it only has the text parameter. It will look for UpText text in all five TextTypes by default.
Valid arguments for TextType are:
'action' //(White text)
'object' //(Cyan text)
'npc' //(Yellow text)
'f2pitem' //(Pale Blue text)
'p2pitem' //(Orange text)
'white' //(Action)
'cyan' //(Object)
'yellow' //(NPC)
'pale blue' //(F2P Item)
'orange' //(P2P Item)
If you have any questions/suggestions feel free to post, hopefully this will be useful to people as a substitute to UpText until SRL6 is released :)
You can also use GetMouseOverText to show you what IsMouseoverText is seeing. Useful for debugging purposes.
function GetMouseoverText(TextType:string): string;
var
Color: Integer;
begin
Color := 0;
case Lowercase(TextType) of
'action', 'white': Color:= 12378347;
'object', 'cyan': Color:= 16776960;
'npc', 'yellow': Color:= 65535;
'f2pitem', 'pale blue': Color:= 13750712;
'p2pitem', 'orange': Color:= 2131675;
end;
if (Color = 0) then
begin
WriteLn('WARNING! ' + TextType + ' is not a valid TextType!');
Exit;
end;
Result := GetTextAtExWrap(0, 0, 798, 598, 0, 4, 1, Color, 5, 'UpCharsEx');
end;
So as you may or may not have noticed, there appears to be no UpText in RS3. So you can still check that what you're clicking on is the right thing, I've made IsMouseOverText.
Functions:
function IsMouseoverTextEx(Text, TextType:string): Boolean;
var
x, y, Color: Integer;
begin
Color := 0;
case Lowercase(TextType) of
'action', 'white': Color:= 12378347;
'object', 'cyan': Color:= 16776960;
'npc', 'yellow': Color:= 65535;
'f2pitem', 'pale blue': Color:= 13750712;
'p2pitem', 'orange': Color:= 2131675;
end;
if (Color = 0) then
begin
WriteLn('WARNING! ' + TextType + ' is not a valid TextType!');
Exit;
end;
GetMousePos(x, y);
Result := IsTextInAreaEx(0, 0, 798, 598, x, y, Text, 5, 'UpCharsEx', False, False, 0, 4, Color);
end;
function IsMouseoverText(Text : string) : Boolean; //By Rich
var
I : Integer;
Types : TStringArray;
begin
Types:= ['action', 'object', 'npc', 'f2pitem' 'p2pitem'];
for I:= 0 to 4 do
begin
Result:= IsMouseOverTextEx(Text, Types[I]);
if Result then
Exit;
end;
end;
Requirements for use: Make sure that you have Mouseover text enabled. Enable it in the graphics setting here:
http://i.imgur.com/3GD0dJ8.png
How to choose text:
Choose some text that doesn't have any capitals or odd symbols. Some capitals work but not all, so if your string with a capital doesn't work then try it without.
Do not use multi-line strings, they do not work.
Here's an example of text that you want, the green boxes are around good samples, the red around bad samples:
http://i.imgur.com/wmlyf4e.png
How to use in a script:
Example #1 (http://villavu.com/forum/usertag.php?do=list&action=hash&hash=1) :
if IsMouseoverTextEx('xchange', 'npc') then
begin
WriteLn('Mouse is over the GE clerk!');
ClickMouse(True);
end;
Example #2 (http://villavu.com/forum/usertag.php?do=list&action=hash&hash=2) :
if IsMouseoverText('xchange') then
begin
WriteLn('Mouse is over the GE clerk!');
ClickMouse(True);
end;
The first parameter in IsUptextEx, Text, is the string you've chosen to look for. The second parameter, TextType, is the type of text that you want the function to look for.
IsUptext is the same as IsUptextEx except it only has the text parameter. It will look for UpText text in all five TextTypes by default.
Valid arguments for TextType are:
'action' //(White text)
'object' //(Cyan text)
'npc' //(Yellow text)
'f2pitem' //(Pale Blue text)
'p2pitem' //(Orange text)
'white' //(Action)
'cyan' //(Object)
'yellow' //(NPC)
'pale blue' //(F2P Item)
'orange' //(P2P Item)
If you have any questions/suggestions feel free to post, hopefully this will be useful to people as a substitute to UpText until SRL6 is released :)
You can also use GetMouseOverText to show you what IsMouseoverText is seeing. Useful for debugging purposes.
function GetMouseoverText(TextType:string): string;
var
Color: Integer;
begin
Color := 0;
case Lowercase(TextType) of
'action', 'white': Color:= 12378347;
'object', 'cyan': Color:= 16776960;
'npc', 'yellow': Color:= 65535;
'f2pitem', 'pale blue': Color:= 13750712;
'p2pitem', 'orange': Color:= 2131675;
end;
if (Color = 0) then
begin
WriteLn('WARNING! ' + TextType + ' is not a valid TextType!');
Exit;
end;
Result := GetTextAtExWrap(0, 0, 798, 598, 0, 4, 1, Color, 5, 'UpCharsEx');
end;