mIRC Homepage

getting name of window using a hash table with ...

Posted By: foshizzle

getting name of window using a hash table with ... - 15/01/08 03:56 AM

How do you get a name of a window with hash table data with multiple names....

like
hash table -- GUI

data
-@blah
-@boom
...etc...

just ask if you dont understand(I'm making a GUI)
Posted By: argv0

Re: getting name of window using a hash table with ... - 15/01/08 05:18 AM

the name of any window? or a specific one? If you know the name of it, then.. well, you already have it. If you want the "first" window in your hash table, though-- you can't do that.

Your question is quite vague so I'll go over all the ways to get values from hash tables.

Hash tables don't maintain order, they're a data structure similar to your english dictionary. You have a "key" (the english word) and the corresponding "value" (the definition of the word).. you do lookups by the key name, not by the index number. For instance, because you don't (easily) know how many words are between "aardvark" and "arrow", you can't just say "give me the next word", because there is no simple correlation between one key and the next. They're not maintained that way in memory, so its your job to figure out the next key.

If you want to maintain order in a hash table, make the key a number value ranging from 1-n and then have the value contain the rest of the data.

You can also use $hget(htable,N) where N is a value from 1-size. In this case, mIRC will grab the "Nth" key-- but before you go AHA!, know that the order is not guaranteed. It might pull "arrow" at index 1 and "aardvark" at index 2, for instance. Even though you may have entered them in the other way around.

Finally, you can use $hfind to search for a key name if you know part of the name, like "@b*".. again these results are not ordered, but this might be what you're looking for.
Posted By: foshizzle

Re: getting name of window using a hash table with ... - 15/01/08 03:41 PM

if you have ever used the Blizzard GUI from picwin.tk, thats what im talking about, I want it because for mouse events you need a specified window... altough there might be a way... thx for that anyway

what i will try, and i hope it works, is i will create an if statement inside my general code for a highlight and i will create mouse events for a check on the active window(if the hash table name matches the window name)
Posted By: foshizzle

Re: getting name of window using a hash table with - 15/01/08 10:20 PM

Does this work?
Code:
menu $active {
  sclick:if ($active == $hfind(GUI,$active) { window -c $active }
}

and if not, how do i get it to
Posted By: hixxy

Re: getting name of window using a hash table with - 15/01/08 11:08 PM

Try it yourself you lazy git, then come back and ask for help if it doesn't work.
Posted By: Riamus2

Re: getting name of window using a hash table with - 16/01/08 01:45 AM

As mentioned, try things first... then ask if it doesn't work. It saves everyone some time. smile

That said, you're missing a ), so it will not work. And I'm not entirely sure that you're going to get a good comparison in that IF... it will depend on how your hash table is configured. Just try it and see if it works (after adding your missing ) ).
Posted By: foshizzle

Re: getting name of window using a hash table with - 16/01/08 02:51 AM

i did try it
Posted By: foshizzle

Re: getting name of window using a hash table with - 16/01/08 03:05 AM

Code:
alias GUI { 
  window -pkodCfB +b @GUI -1 -1 400 400
  hmake @GUI
  hadd @GUI name @GUI
}
menu $active {
  sclick: { if ($active == $hfind(GUI,$active) == name) { window -c $active } }
}

heres what i have, i think the hash tables are wrong, can someone fix it please? i just learned them lol
Posted By: Bekar

Re: getting name of window using a hash table with - 16/01/08 03:41 AM

you hmade @GUI, not GUI.
Posted By: foshizzle

Re: getting name of window using a hash table with - 16/01/08 04:18 AM

Code:
alias GUI { 
  window -pkodCfB +b @GUI -1 -1 400 400
  $iif($hget(@GUI), hfree @GUI, )
  hmake @GUI
}
menu $active {
  sclick: { if ($hget($active) == $active) { window -c $active } }
}

still doesnt work...
Posted By: argv0

Re: getting name of window using a hash table with - 16/01/08 04:34 AM

you can't do "menu $active"

$active is meaningless at that level of code

Why would you have the $iif over a regular if statement by the way?
Posted By: foshizzle

Re: getting name of window using a hash table with - 16/01/08 01:45 PM

idk
do u know how i would get this to work though?
Posted By: argv0

Re: getting name of window using a hash table with - 16/01/08 06:55 PM

As I said, menu $active is meaningless.. Follow the proper syntax, type /help menu prefix
Posted By: foshizzle

Re: getting name of window using a hash table with - 17/01/08 02:25 AM

i knwo it but how
Posted By: Bekar

Re: getting name of window using a hash table with - 17/01/08 02:47 AM

Use the /window command's ability to use a defined Popup menu:

Code:
alias GUI { 
  window -pkodCfB +b @GUI -1 -1 400 400 @MyPopup
  if ($hget(@GUI)) { hfree @GUI }
  hmake @GUI
  hadd @GUI name @GUI
}
menu @MyPopup {
  sclick: {
    if ($active == $hget(@GUI,name)) {
      window -c $active
    }
  }
}

Something like that perhaps.. although the point of the hash table at this point is.. well, there isn't a point.
Posted By: foshizzle

Re: getting name of window using a hash table with - 17/01/08 03:36 AM

i know, with that, but i want this to be a GUI, so i need multiple windows.. thus requiring some way to tell if a window is a GUI window....
Posted By: argv0

Re: getting name of window using a hash table with - 17/01/08 04:43 AM

but you see, you know its a GUI window because you made the menu specifically for that window name

"menu @MyPopup {"

AFAIK, you cannot make a menu for an arbitrary custom window, so you will always know the menu you made is for a specific window. This goes back to how i said "menu $active" is meaningless, and that you should consult /help menu prefix
Posted By: foshizzle

Re: getting name of window using a hash table with - 17/01/08 03:43 PM

I know that, but do u know any way around it?
Posted By: Riamus2

Re: getting name of window using a hash table with - 17/01/08 03:52 PM

Try something like this...

Code:
menu * {
  $iif(@* iswm $window($active),GUI):Do something here
}


If you need the menu to only work for custom windows starting with "@GUI", then put "@GUI*" instead of "@*".

Granted, that doesn't give sclick ability, but you may be able to work around needing that depending what you're doing.
Posted By: qwerty

Re: getting name of window using a hash table with - 17/01/08 05:31 PM

Small sidenote, $window($active) is the same as $active (as the latter always returns the name of an existing window (or $null, although that wouldn't happen in popups)).
Posted By: foshizzle

Re: getting name of window using a hash table with - 17/01/08 08:05 PM

k, thx ppl.. i thought about that last night as i was going to sleep so, and i also thought about using a dll, but i dont want to do that... so thx anyway
Posted By: Riamus2

Re: getting name of window using a hash table with - 17/01/08 11:05 PM

Yeah, you're right. Not sure what I was thinking. shocked
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 12:27 AM

next topic:
whats an easy way to check if the mouse is in x which is listed in a hash file(using while loops to check for multi)

used to check if press is in a button
Posted By: Wims

Re: getting name of window using a hash table with - 19/01/08 12:34 AM

Depending on how your hash table is :

Code:
var %a = $hfind(table,$+($mouse.x,.*),0,w)
while (%a) { echo -a $hfind(table,$+($mouse.x,.*),%a,w) | dec %a }
In this exemple your item should be like X.Y, it list all match for the X value.
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 02:38 AM

thx
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 02:57 AM

so, how do i get this to work...
Code:
  uclick: { if ($hget($active) == $active) { 
      var %x $hfind($active,$+($mouse.x,.*),0,w),%y $hfind($active,$+($mouse.y,.*),0,w)
      if (while (%a) { echo -a $hfind($active,$+($mouse.x,.*),%a,w) | dec %a } >= 20) && (while (%a) { echo -a $hfind($active,$+($mouse.x,.*),%a,w) | dec %a } >= 30) {
        window -c $active
        ;if ($inrect($mouse.x,$mouse.y,20,60,180,20)) {
        ;window -c $active
  } } }
Posted By: Wims

Re: getting name of window using a hash table with - 19/01/08 01:48 PM

Hum, i'm not sure about what you mean since you don't use the right syntax.
Quote:
if ($hget($active) == $active) {
could be
Quote:
if ($hget($active))

Code:
var %x $hfind($active,$+($mouse.x,.*),0,w),%y $hfind($active,$+($mouse.y,.*),0,w)
You're using wildcare incorrectly here, %y should be :
Code:
$hfind($active,$+(*.,$mouse.y),0,w)

You're using %x %y but the while is based on %a
you have an /while inside an /if statement
one of your condition is a /while...
explain more precisely what you want ? smile
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 05:06 PM

i have my hash table that looks like this

item ID - name (hash name is @Gui in this case)

1 - button X Y W H Text
2 - box X Y W H Text
3 - text X Y W H Text

i want it to search all the IDs and see if any of them are buttons then i want to tokenize the values and use them to see if its pressed in that area

ex :

1 - button 10 10 100 20 blah

i want to be able to click at 10 10 100 20 and do the event

Posted By: Wims

Re: getting name of window using a hash table with - 19/01/08 05:43 PM

Code:
uclick:{
if ($hget($active)) { 
var %exid = $regsubex($str(a,$hget($v1,0).item),/a/g,$+($isclick($mouse.x,$mouse.y,$gettok($hget($v1,\n).data,2-6,32),\n),.))
 }
}

alias isclick tokenize 32 $1- | return $iif($inrect($1,$2,$3,$4,$5,$6),$7)
Something like that should works, the $regsubex should return all Ids that match the X Y, separate by a "."

Edit : corrected the /g and the ) that return the error.
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 05:53 PM

Quote:
Too few parameters: $gettok
Posted By: Wims

Re: getting name of window using a hash table with - 19/01/08 06:10 PM

I've edited my code
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 06:16 PM

?
Posted By: Wims

Re: getting name of window using a hash table with - 19/01/08 06:21 PM

Use the new code :
Code:
uclick:{
if ($hget($active)) { 
var %exid = $regsubex($str(a,$hget($v1,0).item),/a/g,$+($isclick($mouse.x,$mouse.y,$gettok($hget($v1,\n).data,2-6,32),\n),.))
echo -a > %exid
 }
}

alias isclick tokenize 32 $1- | return $iif($inrect($1,$2,$3,$4,$5,$6),$7)
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 06:35 PM

thx, but how do u change what %exid says
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 06:39 PM

and then we come up with

Code:
  mouse: { if ($hget($active)) {
      var %exid = $regsubex($str(a,$hget($v1,0).item),/a/g,$+($isclick($mouse.x,$mouse.y,$gettok($hget($v1,\n).data,2-6,32),\n),.))
      if (*... !iswm %exid) {
        gui.draw button @GUI 2 20 25 180 20 Close
      }
      var %exid = $regsubex($str(a,$hget($v1,0).item),/a/g,$+($isclick($mouse.x,$mouse.y,$gettok($hget($v1,\n).data,2-6,32),\n),.))
      if (*... iswm %exid) {
        tokenize 32 button $active 2 20 25 180 20 Close
        drawrect -frn $2 $rgb(247,242,255) 1 $4 $calc($5 + 25) $6 $7
        drawrect -frn $2 $rgb(224,220,250) 1 $calc($4 + 2) $calc($5 + 2 + 25) $calc($6 - 2) $calc($7 - 2)
        drawrect -rn $2 $rgb(191,186,195) 1 $4 $calc($5 + 25) $6 $7
        $iif($8, drawtext -rn $active $rgb(202,197,215) Verdana 12 $calc($4 + $6 / 2 - $width($8-,Verdana,12) / 2 + 1) $calc($5 + $7 / 2 - $height($8-,Verdana,12) / 2 + 1 + 25) $8-, )
        $iif($8, drawtext -rn $active $rgb(26,26,26) Verdana 12 $calc($4 + $6 / 2 - $width($8-,Verdana,12) / 2) $calc($5 + $7 / 2 - $height($8-,Verdana,12) / 2 + 25) $8-, )
        drawdot $active
      }
  } }
  sclick: { if ($hget($active) == $active) { 
      tokenize 32 button $active 2 20 25 180 20 Close
      if ($inrect($mouse.x,$mouse.y,20,55,180,20)) {
        drawrect -frn $active $rgb(202,197,215) 1 $4 $calc($5 + 25) $6 $7
        drawrect -frn $active $rgb(184,180,200) 1 $4 $calc($5 + 25) $calc($6 - 2) $calc($7 - 2)
        drawrect -rn $active $rgb(151,146,155) 1 $4 $calc($5 + 25) $6 $7
        $iif($8, drawtext -rn $active $rgb(202,197,215) Verdana 12 $calc($4 + $6 / 2 - $width($8-,Verdana,12) / 2 + 1) $calc($5 + $7 / 2 - $height($8-,Verdana,12) / 2 + 1 + 25) $8-, )
        $iif($8, drawtext -rn $active $rgb(26,26,26) Verdana 12 $calc($4 + $6 / 2 - $width($8-,Verdana,12) / 2) $calc($5 + $7 / 2 - $height($8-,Verdana,12) / 2 + 25) $8-, )
        drawdot $active
  } } }

how to fix that..
Posted By: hixxy

Re: getting name of window using a hash table with - 19/01/08 06:40 PM

What's wrong with it and which part isn't working?
Posted By: Wims

Re: getting name of window using a hash table with - 19/01/08 06:52 PM

What ? %exid return the id(s) you've clicked on
If %exid = 1.2.4, you've clicked on Id ($hget(table,Id)) 1, 2 and 4.
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 07:07 PM

can u change the script i pasted so it works the way i specified below the mouse event and change it so it is the way i wanted
Posted By: Wims

Re: getting name of window using a hash table with - 19/01/08 07:52 PM

Code:
if (*... !iswm %exid) {
gui.draw button @GUI 2 20 25 180 20 Close
}
In which case this statement would be true ?
It's the same question for the second statement, %exid return the Nth item... Would you like that %exid return the type of id (button, or else) ?
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 09:11 PM

ive changed that to click...
but what would it say if i did a mouse event or a sclick
Posted By: foshizzle

Re: getting name of window using a hash table with - 19/01/08 09:15 PM

add the id one and could you also make one that gives back the coords because that would be really helpful
Posted By: Wims

Re: getting name of window using a hash table with - 20/01/08 01:14 AM

I'm not sure what you mean and i'm not sure this can help you but i'll try...

Code:
menu @* {
mouse:ev mouse
sclick:ev sclick
dclick:ev dclick
uclick:ev uclick
rclick:ev rclick
;lbclick:use them if you want...
;leave:
;drop:
}


alias ev {
if ($hget($active)) var %exid = $regsubex($str(a,$hget($v1,0).item),/a/g,$+($isids($mouse.x,$mouse.y,$gettok($hget($v1,\n).data,1-5,32),\n),.))
else return
echo -a event : $1
echo X Y : $mouse.x $mouse.y
var %a $numtok(%exid,46)
while (%a) {
tokenize 32 $gettok(%exid,%a,46)
echo -a Id for X Y : (Control: $2 - Id : $1)
dec %a
 }
} 
alias isids tokenize 32 $1- | return $iif($inrect($1,$2,$4,$5,$6,$7),$8 $3)
Posted By: foshizzle

Re: getting name of window using a hash table with - 20/01/08 03:07 AM

cool
© 2022 mIRC Discussion Forums