Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

how can i use SetContextMenuHook?

Ask for help
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

how can i use SetContextMenuHook?

Post by 01101011 »

when i use contextmenu in Razor i have success

Code: Select all

Assistant.Macro.ContextMenu|0x0000E1E|200|3007003
but when i use contextmenu in stealth i dont have any return/success

Code: Select all

SetContextMenuHook($00000E1E, 3007003);
or

Code: Select all

SetContextMenuHook($00000E1E, 200);
i doing some thing wrong?

ty for attention =]]]
Last edited by 01101011 on 14.05.2020 11:32, edited 1 time in total.
GeeZeR
Apprentice
Apprentice
Posts: 226
Joined: 28.01.2012 19:48

Re: how can i use SetContextMenuHook?

Post by GeeZeR »

SetContextMenuHook(VendorID : Cardinal; EntryNumber : Byte)
Stealth 8.10.2 | Клиент: 7.0.13.4
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

Re: how can i use SetContextMenuHook?

Post by 01101011 »

hmn, some times it works, some times not

Code: Select all

Program ContexMenu;
var
i : integer;
npc : cardinal;
begin
FindDistance := 1;
npc := FindType($0191,ground); //female npc
RequestContextMenu(npc);
SetContextMenuHook(npc, 0);
end.
i try 398 times with 1 char, but when i changed the char, in the first try i haved success.
when i use the Razor, no matter the char, aways it works. i doing some things wrong in the stealth?
GeeZeR
Apprentice
Apprentice
Posts: 226
Joined: 28.01.2012 19:48

Re: how can i use SetContextMenuHook?

Post by GeeZeR »

try to swap RequestContextMenu(npc); and SetContextMenuHook(npc, 0);, i use this code in a loop and it always works:

Code: Select all

CheckLag(10000);
AutoSell(GetType(FindItem) , $FFFF, 350);
SetContextMenuHook(NPCBuyer, 2);
RequestContextMenu(NPCBuyer);
ClearContextMenu;
ClearShopList;
Stealth 8.10.2 | Клиент: 7.0.13.4
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

Re: how can i use SetContextMenuHook?

Post by 01101011 »

i thing my shard has a problem, some times i get contextmenu with click in the npc, some times not. but even when i can't get the menu by clicking on npc, Razor contextmenu still works.

i don't know if its important, but when i can't get the npc menu (manually) clicking in the npc, SetContextMenuHook() don´t works, when i get the menu (manually) clicking in the npc, SetContextMenuHook() works
GeeZeR
Apprentice
Apprentice
Posts: 226
Joined: 28.01.2012 19:48

Re: how can i use SetContextMenuHook?

Post by GeeZeR »

yea i've noticed that too, try to play with those commands using checklag. I didn't research this feature a lot. My code works well in my case.
Stealth 8.10.2 | Клиент: 7.0.13.4
GeeZeR
Apprentice
Apprentice
Posts: 226
Joined: 28.01.2012 19:48

Re: how can i use SetContextMenuHook?

Post by GeeZeR »

Sometimes Stealth commands reacts on a menu appearance but the menu items are not present at that moment because of lag and they appear a bit later. Try to use some simple loop checking if the menu items are present (GetContextMenu).
http://stealth.od.ua/Doc:Manual/Reference/ContextMenu
Stealth 8.10.2 | Клиент: 7.0.13.4
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

Re: how can i use SetContextMenuHook?

Post by 01101011 »

when ContextMenu its works the script return all context, but when ContextMenu not works, the script return nothing

Code: Select all

Program ContexMenu;
var
MenuList : TStringList; 
i : integer;
npc : cardinal;
{$Include 'CheckLag.inc'}
begin
CheckLag;
FindDistance := 2:
npc := FindType($0191,ground); //female npc
SetContextMenuHook(npc, 0);
RequestContextMenu(npc);
MenuList := TStringList.Create;
GetContextMenu(MenuList);           
for i := 0 to MenuList.Count-1 do
begin
    addtosystemjournal(MenuList[i]);
end;
MenuList.Free; 
ClearContextMenu;
end.
the problem is the shard with stealth, some times SetContextMenuHook() its works, but after few minutes stop working. but i think having solution, because Razor contextmenuaction aways works
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

Re: how can i use SetContextMenuHook?

Post by 01101011 »

Log when i click on NPC to open Context Menu (manual click).

Code: Select all

00:00:00:000: CharName boy, Client -> Server: 0xBF, len: 6
0000: BF 00 06 00 24 54                                       ....$T

00:00:00:000: CharName boy, Client -> Server: 0xBF, len: 9
0000: BF 00 09 00 13 04 9E F9 3C                              ........<

00:00:00:000: CharName boy, Server -> Client: 0x1C, len: 50
0000: 1C 00 32 04 9E F9 3C 01 90 00 03 E8 00 03 54 61         ..2...<.......Ta
0010: 72 73 6b 68 61 6c 77 2c 20 6d 61 67 65 00 00 00         rskhalw,.mage...
0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 48 69 21         .............Hi!
0030: 21 00                                                   !.

00:00:00:000: CharName boy, Client -> Server: 0xBF, len: 6
0000: BF 00 06 00 24 62                                       ....$b

00:00:00:000: CharName boy, Server -> Client: 0x77, len: 17
0000: 77 04 9E F9 3C 01 90 14 59 00 7A 00 02 83 F8 00         w...<...Y.z.....
0010: 07                                                      .

00:00:00:000: CharName boy, Server -> Client: 0xBF, len: 22
0000: BF 00 16 00 14 00 01 04 9E F9 3C 02 00 67 1B 59         ..........<..g.Y
0010: 00 00 00 68 1B 5A                                       ...h.Z

00:00:00:000: CharName boy, Client -> Server: 0xBF, len: 6
0000: BF 00 06 00 24 5C                                       ....$\

00:00:00:000: CharName boy, Client -> Server: 0xBF, len: 11
0000: BF 00 0B 00 15 04 9E F9 3C 00 67                        ........<.g

00:00:00:000: CharName boy, Server -> Client: 0x77, len: 17
0000: 77 04 9E F9 3C 01 90 14 59 00 7A 00 02 83 F8 00         w...<...Y.z.....
0010: 07                                                      .

00:00:00:000: CharName boy, Server -> Client: 0x2E, len: 15
0000: 2E 7F FE 59 DC 0E 7C 00 1A 04 9E F9 3C 00 00            ...Y..|.....<..

00:00:00:000: CharName boy, Server -> Client: 0x2E, len: 15
0000: 2E 7F FE 5C A2 0E 7C 00 1B 04 9E F9 3C 00 00            ...\..|.....<..

00:00:00:000: CharName boy, Server -> Client: 0x3C, len: 145
0000: 3C 00 91 00 07 42 66 F5 C2 0E FA 00 00 05 00 39         <....Bf........9
0010: 00 7C 00 7F FE 59 DC 00 00 45 E5 CF A8 1F 14 00         .|...Y...E......
0020: 00 02 00 89 00 76 00 7F FE 59 DC 00 00 45 E7 47         .....v...Y...E.G
0030: 12 0F 84 00 00 14 00 36 00 43 00 7F FE 59 DC 00         .......6.C...Y..
0040: 00 45 E8 20 87 0F 7A 00 00 32 00 12 00 89 00 7F         .E....z..2......
0050: FE 59 DC 00 00 45 E9 B2 7A 0F 86 00 00 14 00 32         .Y...E..z......2
0060: 00 4E 00 7F FE 59 DC 00 00 45 EA 60 DF 0F 85 00         .N...Y...E.`....
0070: 00 14 00 78 00 83 00 7F FE 59 DC 00 00 45 EA D4         ...x.....Y...E..
0080: 9D 0F 7B 00 00 32 00 62 00 92 00 7F FE 59 DC 00         ..{..2.b.....Y..
0090: 00                                                      .

00:00:00:000: CharName boy, Server -> Client: 0x74, len: 125
0000: 74 00 7D 7F FE 59 DC 07 00 00 00 0A 0B 42 6C 6F         t.}..Y.......Blo
0010: 6F 64 20 4D 6F 73 73 00 00 00 00 0B 08 47 69 6E         od.Moss......Gin
0020: 73 65 6E 67 00 00 00 00 0C 0E 4D 61 6E 64 72 61         seng......Mandra
0030: 6B 65 20 52 6F 6F 74 00 00 00 00 0F 0C 42 6C 61         ke.Root......Bla
0040: 63 6B 20 50 65 61 72 6C 00 00 00 00 05 07 47 61         ck.Pearl......Ga
0050: 72 6c 69 63 00 00 00 00 00 00 42 6c 61 6e 6b 00         rlic......Blank.
0060: 52 75 6e 65 00 00 00 00 00 00 00 00 00 00 42 6f         Rune..........Bo
0070: 6f 6b 00 4d 61 67 65 00 00 00 00 00 00                  ok.Mage......

00:00:00:000: CharName boy, Server -> Client: 0x3C, len: 5
0000: 3C 00 05 00 00                                          <....

00:00:00:000: CharName boy, Server -> Client: 0x74, len: 8
0000: 74 00 08 7F FE 5C A2 00                                 t....\..

00:00:00:000: CharName boy, Server -> Client: 0x24, len: 9
0000: 24 04 9E F9 3C 00 30 00 00                              $...<.0..

00:00:00:000: CharName boy, Server -> Client: 0x11, len: 121
0000: 11 00 79 05 6D 5E E9 43 68 61 72 4e 61 6d 65 00         ..y.m^.CharName.
0010: 62 6f 79 00 00 00 00 00 00 00 00 00 00 00 00 00         boy.............
0020: 00 00 00 00 00 00 56 00 56 00 06 01 00 3C 00 40         ......V.V....<.@
0030: 00 3D 00 3F 00 3F 00 3C 00 3C 00 00 01 12 00 00         .=.?.?.<.<......
0040: 00 3B 00 FA 01 00 E1 00 00 00 00 00 00 00 00 00         .;..............
0050: 00 00 00 00 01 00 08 00 00 00 00 00 00 00 00 00         ................
0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         ................
0070: 00 00 00 00 00 00 00 00 00                              .........
ty for attention boys =]]]
GeeZeR
Apprentice
Apprentice
Posts: 226
Joined: 28.01.2012 19:48

Re: how can i use SetContextMenuHook?

Post by GeeZeR »

Code: Select all

Program test;

var
MenuList : TStringList;
i : integer;
npc : cardinal;
begin
	FindDistance := 4;
	npc := FindType($0191,ground); //female npc
	MenuList := TStringList.Create;

	SetContextMenuHook(npc, 0);
	RequestContextMenu(npc);
	GetContextMenu(MenuList);           
	for i := 0 to MenuList.Count-1 do begin
	    addtosystemjournal(MenuList[i]);
	end;
	MenuList.Free;
	ClearContextMenu;
end.
0|6123|Open Paperdoll|0|0
1|6105|Open Bankbox|0|0
2|6103|Buy|0|0
3|6104|Sell|0|0

it works 10/10
Stealth 8.10.2 | Клиент: 7.0.13.4
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

Re: how can i use SetContextMenuHook?

Post by 01101011 »

i can't use ContextMenu anymore, stopped working with all chars, i think when my shard restart the "contextmenu" will work again for one more time with all chars =[

any way to integrate Razor+Stealth?
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: how can i use SetContextMenuHook?

Post by Vizit0r »

Whats mean "restart"?
Anyway, give packets for ladt menu, which is not works.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

Re: how can i use SetContextMenuHook?

Post by 01101011 »

restart = like a shutdown and turn on again to debug the shard.

i think my shard doesn't work well with contextmenu, even without using stealth, some times i can't get npc menucontext with click.
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: how can i use SetContextMenuHook?

Post by Vizit0r »

strange shard :)
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
01101011
Neophyte
Neophyte
Posts: 21
Joined: 17.01.2019 0:19

Re: how can i use SetContextMenuHook?

Post by 01101011 »

hi guys, sorry for "An Corp" topic, but i find the error =]]

my shard don't use the right way to use menucontext, i go do exemplo:

in razor:
Assistant.Macro.ContextMenu|0x0G8D3HY|518|3007001 -> i use Buy
Assistant.Macro.ContextMenu|0x0G8D3HY|519|3007002 -> i use Sell

but if i use in stealth:
SetContextMenuHook($0G8D3HY, 3007002); because my shard don't use the "argument" 3007001 or 3007002, they use argument 518 to buy and 519 to sell.

i don't know if it was clean, but maybe has any way to stealth use that argument, i don't know

ty guys and sorry for "an corp" =]]]
Post Reply