SRL Archive - SRL Archives

QC.scar! QuickChat functions!


EvilChicken!

2008-05-21 13:07:47

Well, I hope this is the right section.

//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- » QuickChat procedures --//
//-----------------------------------------------------------------//

// » function QCOpen: Boolean; | by EvilChicken!
// » procedure OpenQC; | by EvilChicken!
// » procedure CloseQC; | by EvilChicken!
// » procedure QCOpenMenu(Menu: string; SubMenus: array of Char); | by EvilChicken!
// » procedure QCSayLevel; | by EvilChicken!

{*******************************************************************************
function QCOpen: Boolean;
By: EvilChicken!
Description: Returns true/false depending on if QuickChat window is open.
*******************************************************************************}
function QCOpen: Boolean;
begin
Result := (GetColor(37, 352) = 14869218) and LoggedIn;
end;

{*******************************************************************************
procedure OpenQC;
By: EvilChicken!
Description: Opens QuickChat window if it isn't open.
*******************************************************************************}
procedure OpenQC;
begin
if not LoggedIn or QCOpen then exit;
while CountColor(16711680, 6, 460, 512, 474) > 14 do
TypeByte(08);
if random(2) = 0 then
TypeByte(Chr(13)) else
MouseBox(12, 462, 72, 471, 1);
Wait(150 + random(85));
end;

{*******************************************************************************
procedure CloseQC;
By: EvilChicken!
Description: Closes QuickChat window if it is open.
*******************************************************************************}
procedure CloseQC;
begin
if (not LoggedIn) or (not QCOpen) then exit;
if random(2) = 0 then MouseBox(9, 348, 20, 358, 1) else
TypeByte(27);
Wait(150 + random(85));
end;

{*******************************************************************************
procedure QCOpenTab(Tab: string; SubTabs: array of Char);
By: EvilChicken!
Description: Opens QuckChat, clicks 'Menu' menu, then uses 'SubMenus' chars to
open submenus. 'Menu' options: 'general', 'trade', 'skill', group', 'clan'.
Use: QCOpenMeny('Trade', ['a', 'b', 'c']);
*******************************************************************************}
procedure QCOpenMenu(Menu: string; SubMenus: array of Char);
var
I: Integer;

begin
if not LoggedIn then Exit;
if QCOpen then
begin
CloseQC;
Wait(500 + random(1500));
end;
OpenQC;
case LowerCase(Menu) of
'general': if random(2) = 0 then
MouseBox(12, 363, 98, 373, 1) else TypeByte(GetKeyCode('g'));
'trade', 'items': if random(2) = 0 then
MouseBox(12, 377, 115, 385, 1) else TypeByte(GetKeyCode('t'));
'skill', 'skills': if random(2) = 0 then
MouseBox(12, 392, 113, 402, 1) else TypeByte(GetKeyCode('s'));
'group', 'event', 'events', 'group events': if random(2) = 0 then
MouseBox(12, 407, 110, 412, 1) else TypeByte(GetKeyCode('e'));
'clan', 'clans': if random(2) = 0 then
MouseBox(12, 420, 115, 429, 1) else TypeByte(GetKeyCode('c'));
else
begin
srl_Warn('QCOpenMenu', Menu + ' is an invalid QC menu ', warn_AllVersions);
Exit;
end;
end;
Wait(350 + random(250));
if GetArrayLength(SubMenus) > 0 then
for I := 0 to High(SubMenus) do
begin
TypeByte(GetKeyCode(SubMenus[I]));
Wait(1350 + random(500));
end;
end;

{*******************************************************************************
procedure QCSayLevel(Which: string);
By: EvilChicken!
Description: Says 'Which' skill level using Quick Chat.
*******************************************************************************}
procedure QCSayLevel(Which: string);
var
Skill: Char;

begin
case LowerCase(Which) of
'agility', 'agil': Skill := 'a';
'attack', 'atk': Skill := 'z';
'construction', 'con': Skill := 'c';
'cooking', 'cook': Skill := 'v';
'crafting': Skill := 'x';
'defence', 'def': Skill := 'd';
'farming', 'farm': Skill := 'f';
'firemaking', 'fm': Skill := 'p';
'fishing': Skill := 'w';
'fletching', 'fletch': Skill := 'e';
'helblore', 'herb': Skill := 'h';
'hitpoints', 'hp': Skill := 'l';
'hunting', 'hunter': Skill := 'u';
'magic', 'mage': Skill := 'm';
'mining': Skill := 'i';
'prayer', 'pray': Skill := 'y';
'range', 'ranged': Skill := 'r';
'runecrafting', 'rc': Skill := 'n';
'slayer': Skill := 's';
'smith', 'smithing': Skill := 'b';
'strength', 'str': Skill := 'g';
'summoning', 'sum': Skill := 'o';
'thieving', 'thief': Skill := 't';
'woodcutting', 'wc': Skill := 'j';
else
begin
srl_Warn('QCSayLevel', Which + ' is an invalid skill ', warn_AllVersions);
Exit;
end;
end;
QCOpenMenu('skills', [Skill, '2']);
end;


Lemme know what you think. ^^

Edit: The way QCOpenMenu works:
1: Type "QCOpenMenu(".
2: Type in one of these main tabs: 'Menu' options: 'general', 'trade', 'skill', group', 'clan'.
3: Type a comma! (",")
4: Type in a left bracket! ("[")
5: Type in the array of chars for the subtabs you want to go to. As strings! For example to say your woodcutting level, you would have to use nothing more than: QCOpenMenu('skills', ['j', '2']);

To see a chart of chars for the skills, have a look at QCSayLevel. (Which by th way took a long time to make. I hope you keep that in mind. :))

SKy Scripter

2008-05-21 13:12:24

this is pretty cool :p

ShowerThoughts

2008-05-21 13:14:25

pretty cool :D

Naike

2008-05-21 14:40:50

Should be added! looks great ;)

Drakan

2008-05-21 16:29:13

Nice looks very sexy and would be very usefu!

TheGuyWhoGotOn

2008-05-21 17:50:52

I like it, but I think it should open QC with the enter key. Of course after checking if anything has been typed.

Edit: I think you should also make it so people can type in just the letter they want instead of just the skill name and there should be a little guide to the names of the skills like here:

http://www.villavu.com/forum/showthread.php?t=30770

Smartzkid

2008-05-21 20:52:31

Well written, but IMO SRL doesn't need them.

TheGuyWhoGotOn

2008-05-21 21:45:48

From: Smartzkid
Well written, but IMO SRL doesn't need them.


It could still be helpful though, now you can use less time in typing out the reply and clicking stats/clicking back to the inventory. It's an overall faster way to do things in my eyes and I think it would be a great addition to SRL - Provided that a few changes be made to make it as fast as possible.

Gu3st...

2008-05-22 01:41:44

You should add a Random2 := Random(2) in the start, so that it either clicks whole the time or types chars whole the time. Like it is now it will (maybe) click, type, click, type.

And then say If Random2 = 0 instead of if Random(2) = 0. You get my point?

EvilChicken!

2008-05-22 02:04:45

From: Smartzkid
Well written, but IMO SRL doesn't need them.
Why not? Post your opinions? Thank you for your input anyway.

From: TheGuyWhoGotOn
I like it, but I think it should open QC with the enter key. Of course after checking if anything has been typed.

DONE! Thank you for your suggestion. And, you should yeplace your with mine, SendKeysVB is detectable IMO. (Kinda the same as SendText..?)

From: TheGuyWhoGotOn
Edit: I think you should also make it so people can type in just the letter they want instead of just the skill name and there should be a little guide to the names of the skills like here:

http://www.villavu.com/forum/showthread.php?t=30770


..

As you see, my function can be used to press as many keys as you want.
(Use: OpenQCMenu('general', ['d', '2', ect..]).

Just input an array of chars and it will go to the tabs and subtabs for you.
Take a look at QCSayLevel for an example.

From: TheGuyWhoGotOn
It could still be helpful though, now you can use less time in typing out the reply and clicking stats/clicking back to the inventory. It's an overall faster way to do things in my eyes and I think it would be a great addition to SRL - Provided that a few changes be made to make it as fast as possible.


Thanks a lot for your long, informational comment!
(*cough* Hermpie *cough*)


oh and Sky your so cool.. i love you!!!

From: Zytex!
You should add a Random2 := Random(2) in the start, so that it either clicks whole the time or types chars whole the time. Like it is now it will (maybe) click, type, click, type.

And then say If Random2 = 0 instead of if Random(2) = 0. You get my point?


I WAS going to do that, but then I realized that getting all the coords for the MouseBox'es would take even more time than getting the letters to the tabs&subtabs. (And that took a while, trust me.)
And I don't think anything's wrong with using the keys, it IS a much faster way in my opinion, but I can understand that you want to vary it, and I'll try my best to do so.

Takk. :)


Edit: I updated OpenQC again. Now it deletes any typed text that isn't sent in the chat window. ^^

Markus

2008-05-22 11:49:03

Just for your interest, array of char = string ;)

Naum

2008-05-23 03:55:41

Yeah we actually really need this, we must always be in line with all developments. Most of the Players now chat like this which makes it much easier to make an autoresponder ;)


Good Job EC!

TheGuyWhoGotOn

2008-05-23 17:54:50

From: EvilChicken!
Why not? Post your opinions? Thank you for your input anyway.


DONE! Thank you for your suggestion. And, you should yeplace your with mine, SendKeysVB is detectable IMO. (Kinda the same as SendText..?)



..

As you see, my function can be used to press as many keys as you want.
(Use: OpenQCMenu('general', ['d', '2', ect..]).

Just input an array of chars and it will go to the tabs and subtabs for you.
Take a look at QCSayLevel for an example.



Thanks a lot for your long, informational comment!
(*cough* SkY/Hermpie *cough*)



I WAS going to do that, but then I realized that getting all the coords for the MouseBox'es would take even more time than getting the letters to the tabs&subtabs. (And that took a while, trust me.)
And I don't think anything's wrong with using the keys, it IS a much faster way in my opinion, but I can understand that you want to vary it, and I'll try my best to do so.

Takk. :)


Edit: I updated OpenQC again. Now it deletes any typed text that isn't sent in the chat window. ^^


I'm glad I could help ^_^, voted yes.

PvH

2008-05-24 03:45:36

it seems really cool..
IMO… it is good to add in srl for responding
i'll vote yes;)

Markus

2008-05-24 08:08:30

Few things:
1.
if not LoggedIn then Exit;
Result := GetColor(37, 352) = 14869218;
Change that too
[LEFT] result := (GetColor(37, 352) = 14869218) and (LoggedIn);
2. TypeByte(GetKeyCode(Chr(13))) = TypeByte(chr(13));

Fix above stuff, maybe add some more functions and I'll add it to /misc/ :p
[/LEFT]

Narcle

2008-05-24 10:12:28

Should have something like this in there:

Function QCFast(str:string):boolean;
var
i:integer;
S:string;
begin
TypeByte(GetKeyCode(Chr(13)))
wait(300+random(50));
If QCOpen then
begin
S:=str;
for i := 0 to Length(S) do
begin
TypeSend(S[i]);
wait(150+random(50));
end;
end;
if not QCOpen then
Result := true;
end;

That way we can just have like "QCFast('gr2');" which is quick chats "No."

Edit: Just fyi, I typed this up as an example. I haven't tested to see if works.

Edit2: Or you could simply have TypeSend(str); in that procedure, since TypeSend actually delays key pressing… It just pushes enter after words but it wouldn't do anything then.

TheGuyWhoGotOn

2008-05-24 20:43:07

From: Narcle
Should have something like this in there:

Function QCFast(str:string):boolean;
var
i:integer;
S:string;
begin
TypeByte(GetKeyCode(Chr(13)))
wait(300+random(50));
If QCOpen then
begin
S:=str;
for i := 0 to Length(S) do
begin
TypeSend(S[i]);
wait(150+random(50));
end;
end;
if not QCOpen then
Result := true;
end;

That way we can just have like "QCFast('gr2');" which is quick chats "No."

Edit: Just fyi, I typed this up as an example. I haven't tested to see if works.

Edit2: Or you could simply have TypeSend(str); in that procedure, since TypeSend actually delays key pressing… It just pushes enter after words but it wouldn't do anything then.


Pressing enter would re-open quick chat.

SKy Scripter

2008-05-24 21:13:31

From: EvilChicken!


Thanks a lot for your long, informational comment!
(*cough* Hermpie *cough*)


oh and Sky your so cool.. i love you!!!




uhmmm thanks?? im sorry… im not really into.. gayness.. but thanks anyway. ;)

Harry

2008-05-24 22:56:35

From: SKy Scripter
uhmmm thanks?? im sorry… im not really into.. gayness.. but thanks anyway. ;)


Really? *disappointment*


Looks awesum EvilChicken! I was gonna make one, but looks like you beat me to it ;)

EvilChicken!

2008-05-25 12:16:49

From: Markus
Few things:
1.
if not LoggedIn then Exit;
Result := GetColor(37, 352) = 14869218;
Change that too
[LEFT] result := (GetColor(37, 352) = 14869218) and (LoggedIn);
2. TypeByte(GetKeyCode(Chr(13))) = TypeByte(chr(13));

Fix above stuff, maybe add some more functions and I'll add it to /misc/ :p
[/LEFT]



Done. Huge thanks! Woot, my own include?

From: Narcle

Or you could simply have TypeSend(str); in that procedure, since TypeSend actually delays key pressing… It just pushes enter after words but it wouldn't do anything then.


Thanks for your function, I also though of it, but I like mine better somehow.
And, TypeSend is too fast, and as someone also said, it opens up QC again.

Narcle

2008-05-25 12:25:16

From: EvilChicken!
Done. Huge thanks! Woot, my own include?



Thanks for your function, I also though of it, but I like mine better somehow.
And, TypeSend is too fast, and as someone also said, it opens up QC again.


Yeah you could make a custom one just for it. It would be way faster then current method.