mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 3 1 2 3
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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)


This is not the signature you are looking for
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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)


This is not the signature you are looking for
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
Does this work?
Code:
menu $active {
  sclick:if ($active == $hfind(GUI,$active) { window -c $active }
}

and if not, how do i get it to


This is not the signature you are looking for
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Try it yourself you lazy git, then come back and ask for help if it doesn't work.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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 ) ).


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
i did try it


This is not the signature you are looking for
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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

Last edited by foshizzle; 16/01/08 03:05 AM.

This is not the signature you are looking for
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
you hmade @GUI, not GUI.

Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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...


This is not the signature you are looking for
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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?


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
idk
do u know how i would get this to work though?


This is not the signature you are looking for
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
As I said, menu $active is meaningless.. Follow the proper syntax, type /help menu prefix


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
i knwo it but how


This is not the signature you are looking for
Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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.

Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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....


This is not the signature you are looking for
Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
I know that, but do u know any way around it?


This is not the signature you are looking for
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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)).


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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


This is not the signature you are looking for
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yeah, you're right. Not sure what I was thinking. shocked


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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


This is not the signature you are looking for
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
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.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
thx


This is not the signature you are looking for
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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
  } } }

Last edited by foshizzle; 19/01/08 02:58 AM.

This is not the signature you are looking for
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
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


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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



This is not the signature you are looking for
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
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.

Last edited by Wims; 19/01/08 06:10 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
Quote:
Too few parameters: $gettok

Last edited by foshizzle; 19/01/08 05:59 PM.

This is not the signature you are looking for
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
I've edited my code


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
?


This is not the signature you are looking for
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
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)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
thx, but how do u change what %exid says


This is not the signature you are looking for
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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..


This is not the signature you are looking for
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
What's wrong with it and which part isn't working?

Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
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.

Last edited by Wims; 19/01/08 06:53 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
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


This is not the signature you are looking for
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
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) ?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
ive changed that to click...
but what would it say if i did a mouse event or a sclick


This is not the signature you are looking for
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
add the id one and could you also make one that gives back the coords because that would be really helpful

Last edited by foshizzle; 19/01/08 10:13 PM.

This is not the signature you are looking for
Joined: Jul 2006
Posts: 4,186
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,186
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)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Aug 2007
Posts: 334
Pan-dimensional mouse
OP Offline
Pan-dimensional mouse
Joined: Aug 2007
Posts: 334
cool


This is not the signature you are looking for
Page 1 of 3 1 2 3

Link Copied to Clipboard