VBS Okay/Cancel MsgBox generator

By Valware on Aug 06, 2012

This is a very small script that allows you to use an alias to make an OK/Cancel pop-up box come up with custom message and title.

Example syntax:
/MSGBOX This_is_the_title_of_the_box This is the message in the box.

If you don't enter any parameters, it will give you a syntax example in your active connections status window

As you can see, the title uses underscores instead of spaces. They'll get replaced on the actual message box to spaces, it's just so mIRC can tell which part is the title of the box, and which part is the message in the box.

For those looking to learn about the script;
What this script does is firstly check if you've entered any parameters.
If you haven't, then it'll give you a syntax example in your status window.
If you have, it'll write the parameters to the file in .vbs format, using the title of the box as the name of the file. It'll then run the file and delete it as soon as it's been run.

If you're curious as to how the file looks, you can delete the line;
.timer 1 1 remove $1 $+ .vbs

If you can't be arsed, the file consists of one line, and looks like this.

Your_title=msgbox("Your title",16,"Your message")

The 16 is to represent that the buttons are "OK" and "Cancel" in VBS.
If you want to change them, do a bit of research on what numbers do what.

Note: Clicking on either of the buttons just close the window, so it's basically just a notification window, one of the reasons I didn't choose to have "Yes" and "No" options.

If you want to use "Yes" and "No" options, you can simply use the mIRC equivilent of this, which is something like:

if ($?!="Do you want to proceed?" == $true) { proceed }

$true is equivilent to "Yes".
Use $false as the identifier for if "No" is clicked.

I enjoy helping others learn, and I'll do scripts on request, just leave me an inbox message. If you have any further questions about this particularly small script, feel free to leave a comment.

Enjoy!

alias msgbox {
  if ($1 == $null) {
    echo -se MSGBOX Syntax: /MSGBOX Title_Of_The_Box Message displayed on the box
    editbox -a /MSGBOX
  }
  elseif ($1-2 != $null) {
    write $1 $+ .vbs $2 $+ =msgbox(" $+ $2- $+ ",16," $+ $replace($1,$chr(95),$chr(32)) $+ ")
    run $1 $+ .vbs
    .timer 1 1 .remove $2 $+ .vbs
  }
}

Comments

Sign in to comment.
MoshMage   -  Aug 07, 2012

@Sorasyn oh..! right. My bad. ^^'

 Respond  
Sorasyn   -  Aug 07, 2012

@MoshMage Facepalm.... He's using mSL to demonstrate a "msgbox" in Visual Basic. If you want to get into the matter of "reinventing the wheel," it could be pointed out that almost every programming language has it's own variation of a message box.

 Respond  
MoshMage   -  Aug 07, 2012

don't you get tired of reinventing the wheel?

echo $input(hello world,owd,this is title)

use /help $input

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.