Shoutbox

[problem] Buttons in windows - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [problem] Buttons in windows (/showthread.php?tid=78388)

[problem] Buttons in windows by waynewilson2 on 10-22-2007 at 08:40 PM

ok, so i made a window, i got help with that, but...

i dont know how to make buttons do actions, such as close, open, navigate, stuff like that...

Thanks In Advance.


RE: [problem] Buttons in windows by roflmao456 on 10-22-2007 at 09:41 PM

code:
function OnWindowidEvent_CtrlClicked(PlusWnd, ControlId){
switch(ControlId){
case "control-id-of-button": // when a button with this id is clicked..
PlusWnd.Close(1); // Closes the window
break;
case "control-id-of-another-button":
Interop.Call("user32","MessageBoxW", 0, "Button 2 has been clicked", "some script", 64); // Displays a message box.
break;
}
}

yeah so "PlusWnd.Close(1);" closes the window.
replace "Windowid" with your window's ID.
RE: [problem] Buttons in windows by waynewilson2 on 10-22-2007 at 11:01 PM

TYVM roflmao, you seem to be able to help out alot...lmfao
from now on, if i need help, imma talk to you first...

oh, and another thing i was wondering about... how do i put textboxs and stuff like that in??


RE: [problem] Buttons in windows by Spunky on 10-22-2007 at 11:22 PM

For textboxes... change
'Control type:xsi="ButtonControl"'

to

'Control type:xsi="EditControl"'

in the xml file


RE: [problem] Buttons in windows by roflmao456 on 10-23-2007 at 12:51 AM

quote:
Originally posted by SpunkyLoveMuff
For textboxes... change
'Control type:xsi="ButtonControl"'

to

'Control type:xsi="EditControl"'

in the xml file

and to get the text from the textbox (or other controls):

code:
Debug.Trace(PlusWnd.GetControlText("textbox-id-control"));

will pop up in your debug.
RE: [problem] Buttons in windows by waynewilson2 on 10-23-2007 at 05:29 AM

ok, thanks for that stuff, also, i just thought of sumthin else... how would i make it log the text within the box to a file? lol, im new to this crap, im good with other stuff, but unfortunately not that...

the windows are the only thing i've had probs with so far...


RE: [problem] Buttons in windows by roflmao456 on 10-23-2007 at 08:13 PM

quote:
Originally posted by waynewilson2
ok, thanks for that stuff, also, i just thought of sumthin else... how would i make it log the text within the box to a file? lol, im new to this crap, im good with other stuff, but unfortunately not that...

the windows are the only thing i've had probs with so far...

http://www.tutorial-web.com/asp/fso/

i think it's

code:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var file = fso.OpenTextFile(MsgPlus.ScriptFilesPath + "\\log.txt",2,true); // will create log.txt in your script files path
file.Write(PlusWnd.GetControlText("textbox-id"));

RE: [problem] Buttons in windows by waynewilson2 on 10-23-2007 at 08:16 PM

ok TYVM...again lol


RE: [problem] Buttons in windows by waynewilson2 on 10-23-2007 at 08:49 PM

ok...new problem :( when reading an array, how would i go about comparing that array to another string, kind of like a filtering system? lol

Thanks In Advance


RE: [problem] Buttons in windows by NanaFreak on 10-23-2007 at 08:54 PM

code:
var Arr = new Array("123","456","789","456","abc","jkl","omn","456");
var Str = "456"
for(i=0; i<Arr.length; i++){
if(Arr[i] == "456"){
Debug.Trace("Arr["+i+"] == 456");
}
}

that should put this in the debug:
Arr[1] == 456
Arr[3] == 456
Arr[7] == 456
RE: [problem] Buttons in windows by waynewilson2 on 10-23-2007 at 08:55 PM

ok, thanks :)


RE: [problem] Buttons in windows by waynewilson2 on 10-23-2007 at 09:02 PM

is there any way to check if the array's string contains the string, but is not exactly alike it?? :S :S


RE: [problem] Buttons in windows by roflmao456 on 10-23-2007 at 09:36 PM

quote:
Originally posted by waynewilson2
is there any way to check if the array's string contains the string, but is not exactly alike it?? :S :S
this is close to what i used in WLMini Media Player:
code:
for(x in somearray){
if(somestring.search(somearray[x]) != -1){
Debug.Trace(somearray[x]); // prints the found stuff.
}
}

RE: [problem] Buttons in windows by waynewilson2 on 10-23-2007 at 09:44 PM

lol, a bit confusin, but ill figure it out, thanks roflmao


RE: [problem] Buttons in windows by Spunky on 10-23-2007 at 10:12 PM

code:
for(x in somearray){ //For each array element
    if(somestring.search(somearray[x] != -1){ //search the target text for array element
        // !=-1 means the string text was found (only returns -1 when text is not found, else returns the index or position of the first character
        Debug.Trace(somearray[x]); //Print it so we know it found the text
    }
}

Just to try and explain it :p
RE: [problem] Buttons in windows by waynewilson2 on 10-24-2007 at 05:13 AM

umm...i tried that, and every time i try to search the array, it returns this in the debug window...

code:
Error: Expected ')' in regular expression (code: -2146823268)
       File: my pm chat.js. Line: 150.
Function OnEvent_ChatWndReceiveMessage returned an error. Code: -2147352567


help please :S

the code im using to search is like this(vars are defined)
code:
function filtaNow(ChitChatter, tehmess){
    for(x in filta0){ //For each array element
        if(tehmess.search(filta0[x]) != -1){ //This is line 150
        // !=-1 means the string text was found (only returns -1 when text is not found, else returns the index or position of the first character
            Debug.Trace(somearray[x]); //Print it so we know it found the text
        }
    }
   
}


RE: [problem] Buttons in windows by Spunky on 10-24-2007 at 11:17 AM

you have to Debug.Trace(filta0[x]); not somearray[x]...

As for the error... check what filta0[x] is by tracing it on line 149. It may be that it is empty or something strange


RE: [problem] Buttons in windows by markee on 10-24-2007 at 11:25 AM

The problem was in spuky's post.

quote:
Originally posted by SpunkyLoveMuff
code:
for(x in somearray){ //For each array element
    if(somestring.search(somearray[x]) != -1){ //search the target text for array element
        // !=-1 means the string text was found (only returns -1 when text is not found, else returns the index or position of the first character
        Debug.Trace(somearray[x]); //Print it so we know it found the text
    }
}

Just to try and explain it :p


Edit: in relation to spunky's next post....
quote:
Originally posted by SpunkyLoveMuff

quote:
Originally posted by markee
spuky's
* spuky runs :p
Maybe I wanted to shorten it more 8-)

RE: [problem] Buttons in windows by Spunky on 10-24-2007 at 12:47 PM

erm...
* Spunky runs

EDIT:

quote:
Originally posted by markee
spuky's

* spuky runs :p
RE: [problem] Buttons in windows by waynewilson2 on 10-24-2007 at 08:19 PM

thanks for the help, i got it to work now, but...
when it calls that for statement, it just makes a list of every string in the array...i don't see why, and when i change

code:
if(temess.search(filta0[x] != -1)){
to
code:
if(temess.search(filta0[x] != -1) == 0){
it returns nothing at all...

would it be possible to use a while statement, rather than a for statement? :S :S
RE: [problem] Buttons in windows by NanaFreak on 10-24-2007 at 08:50 PM

quote:
Originally posted by markee
    if(somestring.search(somearray[x]) != -1){ //search the target text for array element
make it that, not the second one that you had =\
RE: [problem] Buttons in windows by waynewilson2 on 10-24-2007 at 10:41 PM

like i said, the first one returns every string in the array, the second one returns nothing, neither is doing me any good

and the bracket is in the wrong spot...


RE: [problem] Buttons in windows by roflmao456 on 10-24-2007 at 10:54 PM

quote:
Originally posted by waynewilson2
like i said, the first one returns every string in the array, the second one returns nothing, neither is doing me any good

and the bracket is in the wrong spot...
the bracket is in the correct spot:
code:
if(tehmess.search(filta0[x]) != -1)


are you sure that "filta0" is an Array? :P
code:
var filta0 = new Array("something here", "something there")


* roflmao456 goes to test some code
RE: [problem] Buttons in windows by waynewilson2 on 10-24-2007 at 10:56 PM

quote:
Originally posted by roflmao456
quote:
Originally posted by waynewilson2
like i said, the first one returns every string in the array, the second one returns nothing, neither is doing me any good

and the bracket is in the wrong spot...
the bracket is in the correct spot:
code:
if(tehmess.search(filta0[x]) != -1)


when i use it with the bracket in the spot that nanafreak put it in, i get an error tellin me that it expects a bracket in that line, i put another bracket anywhere, and it gives me another error...
RE: [problem] Buttons in windows by roflmao456 on 10-24-2007 at 11:06 PM

oops! the search thing is backwards :$

code:
var filta0 = new Array("something here", "something there");
function filtaNow(tehmess){
    for(x in filta0){
        Debug.Trace("Search #" + x + ": " + filta0[x]);
        if(filta0[x].search(tehmess) != -1){
            Debug.Trace("Found Search #" + x + ": " + filta0[x]);
            }
        }
    }

that should work :P
RE: [problem] Buttons in windows by waynewilson2 on 10-25-2007 at 01:23 AM

YAY it works now, thank you guys very much for all your help, and roflmao456, if i have any more probs, ill go straight to you first |-) :D


RE: [problem] Buttons in windows by markee on 10-25-2007 at 12:14 PM

Wow that's really stupid and makes me love regular expressions even more. Especially the fact that they use the string as the object and find macthes withing it.  Though I must admit that it then does get confusing trying to remember which way exec and replace go.... (or is it match.... there are too many different ways of doing things.

The way I do checks like this is as follows

code:
if((arr = RegExpObj.exec(stringObj)) !== null){
//put some code here
}
This way not only do I get the match, I get what exactly it matched and can get lots more iformation about the match (like rest ofthe string to the left or right and havig an array of all of the matches and other stuff).  I highly advise people to use this method instead.  If you don't use any symbols then you can still store all of your words in an array and what is better is that you can make sure that it is that word and not part of a word.
code:
var RegExpObj = new RegExp("\b("+arrayObj.join("|")+")\b");
or if you would prefer the word to be even in part of a word, like "hi" will be found in "this" for example with the following code (but not hte previous)
code:
var RegExpObj = new RegExp("("+arrayObj.join("|")+")");
Both of these can be really useful when coding something that the user might edit, you just need to remember the put a \ before any special symbols that will be used (eg "$", "^", ".", etc.).

This method would mean that you do not need the for statement but would just be using a regular expression in your if statemet instead.

I understand if this has just gone way over your head but other members like roflmao might find this useful for future scripts.
RE: [problem] Buttons in windows by waynewilson2 on 10-25-2007 at 08:42 PM

wow... you know, i did not understand a single thing out of that post, i would rather work with stuff that i can understand && work with... thanks for trying tho...oh, and, please don't try to explain it, you'll just skrew me up more...lol, i learn stuff on my own, with stuff that people teach me...


RE: [problem] Buttons in windows by markee on 10-25-2007 at 11:21 PM

quote:
Originally posted by waynewilson2
i learn stuff on my own, with stuff that people teach me...
I don't see how that even makes sense (just look at the logic).... :P

Anyway, just so you are aware I realised that it was beyond what you probably would understand at the moment, however this was more for the likes of roflmao and other scripters so they can continue to develop their scriptig ability.  It was my opinion that I explained what the code does in a good manner, enough for a person familiar with JScript or Javascript should understand with ease.  Regular expressions are not easy but they are far superior to searching for an exact phrase.  Personally I have never used the search method as I honestly believe you are far better spending a day or so getting used to regular expressions and using them instead.
RE: [problem] Buttons in windows by waynewilson2 on 10-26-2007 at 02:32 AM

ok, what i meant, is that when people give me something that i ask for, i take that, and examine it for a while, and on my own, i figure out what it does, how it works, and what not...

but now i got a new problem

code:
Error: 'length' is null or not an object (code: -2146823281)

i get that error when i try to use my filtering...

code:
            if ((tehfiltabud.length >= 1000) == 0){

that is the line that its skrewing up in, i have a few lines with the .length in it, but i cannot get past that one...

thanks in advance...


and in reply to that paragraphed part, as you may have not noticed, the purpose of these posts was originally for buttons, then kept changing, umm... what else, lol... it eventually made its way to stuff like that, but when you made that post, i was looking for something to look for a partial match, not an exact...lol
RE: [problem] Buttons in windows by waynewilson2 on 10-26-2007 at 05:25 AM

ok, i fixed my last problem, i thank you all very much for the help :D its greatly appreciated


RE: [problem] Buttons in windows by markee on 10-26-2007 at 07:03 AM

The only time I find I run into that problem is that the variable is not a string or an array.  These are the two most common causes to my knowledge.  Try debuging the variable just before the if statement to check.  You may also wish to re-code your if statement.

code:
(tehfiltabud.length >= 1000
return a boolean variable, if it is true then it equals 1 and false equals 0.  I think you understand this by putting it in, but instead of having
code:
if ((tehfiltabud.length >= 1000) == 0){
you can have
code:
if (!(tehfiltabud.length >= 1000)){
as the ! turns false to true and true to false, but what would be even better is to do
code:
if (tehfiltabud.length < 1000){
which is just the opposite.  I'm sure you will understand the logic behind that.

EDIT: Looks like I was a little slow, but maybe that extra info might help your code.
RE: [problem] Buttons in windows by waynewilson2 on 10-26-2007 at 09:11 PM

yea, i already knew how to program with the ! marks, that checks if sumthin is false, i do more java than javascript programming, i just would rather know the longer methods...lmao, thanks for the help


RE: [problem] Buttons in windows by waynewilson2 on 10-26-2007 at 10:18 PM

unfortunately i dont know xml, so i need help again, can sum1 please tell me how to make a textbox that contains text, but cannot be edited by the user, only by the script? :S:S

Please And Thanks :D :)


RE: [problem] Buttons in windows by roflmao456 on 10-26-2007 at 10:28 PM

code:
<Control xsi:type="EditControl" Id="someedit">
<Position Left="0" Top="0" Width="50" />
<Attributes>
<ReadOnly>true</ReadOnly>
</Attributes>
<DefaultText>some text...</DefaultText>
</Control>

quote:
Originally posted by waynewilson2
unfortunately i dont know xml, so i need help again, can sum1 please tell me how to make a textbox that contains text, but cannot be edited by the user, only by the script? :S:S

Please And Thanks :D :)

RE: [problem] Buttons in windows by waynewilson2 on 10-26-2007 at 10:39 PM

TYVM


RE: [problem] Buttons in windows by waynewilson2 on 10-26-2007 at 11:01 PM

quote:
Originally posted by roflmao456
yeah so "PlusWnd.Close(1);" closes the window.
replace "Windowid" with your window's ID.

i just tried this, and for some reason, its not workin...
RE: [problem] Buttons in windows by roflmao456 on 10-26-2007 at 11:46 PM

quote:
Originally posted by waynewilson2
quote:
Originally posted by roflmao456
yeah so "PlusWnd.Close(1);" closes the window.
replace "Windowid" with your window's ID.

i just tried this, and for some reason, its not workin...

if you're placing that into a function (not the OnwindowidEvent_CtrlClicked)

then you will probably have to create the window in a global variable.
RE: [problem] Buttons in windows by waynewilson2 on 10-27-2007 at 05:27 PM

i wasn't putting it into another function, it didn't quote the code, but... i put it into the function for the window, and it does not close it or anything...


RE: [problem] Buttons in windows by roflmao456 on 10-28-2007 at 05:25 PM

quote:
Originally posted by waynewilson2
i wasn't putting it into another function, it didn't quote the code, but... i put it into the function for the window, and it does not close it or anything...
what's your code? (or whole script attached as .txt)
RE: [problem] Buttons in windows by waynewilson2 on 10-29-2007 at 12:25 AM

nvm, i got it...lol, i was using the wrong thing to close the window... thanks for trying to help


RE: [problem] Buttons in windows by waynewilson2 on 10-29-2007 at 02:02 AM

another thing...LMFAO im horrible, how exactly would i go about writing to the textbox?? lol


RE: [problem] Buttons in windows by roflmao456 on 10-29-2007 at 02:43 AM

quote:
Originally posted by waynewilson2
another thing...LMFAO im horrible, how exactly would i go about writing to the textbox?? lol
code:
PlusWnd.SetControlText("controlid","text");

look in the scripting doc. it's there
RE: [problem] Buttons in windows by waynewilson2 on 10-29-2007 at 03:02 AM

lol, kk, thanks