Thursday, May 21, 2009

mIRC Scripting : Popups



This session of my mIRC Scripting tutorials will show you how to manage those lovely popups that we all seem to get addicted to in the early days. It was designed for beginners who do not have any previous experience managing their mIRC Popup menus. If you are totally new to the Popups session and have no idea how and where to begin, here's help.

Popups

In simple way, Popups are the menus that appear when you right click on an mIRC window. They are a list of predefined commands . Popups are also used to control window mouse events.

Look at the screenshot shown at the right, that's how a Popup looks like. You get that one when you right click in the nickname list (the column at the right corner of the channel window, where you see the nicknames). Try clicking there. Depending on whether you are using a script or not you should see something similar to the picture shown here; it's the default mIRC nickname list Popup. As you can see from the shown picture there are some available menus such Info, Whois, Query, Control ect...

Creating Popups

There are 2 ways to create popups :
  1. One is to use the Popups Editor in the scripts editor which is divided into sections already, so, you don't have to declare what kind of manu it is, just create the menu items.
  2. And the second way is by using the Remote Tab and using the menu declaration.

1. Creating Popus using Popups Editor

Now let's start with creating your first Popup using the Popups tab section in the Scripts Editor.
First take a look at the Popup files for the Popups in mIRC. Press ALT+P (this takes you directly to the Scripts Editor in Popups mode). See the codes? Most probably the Popups file for the Status window will be put in the Edit mode. Right click in the Status window and analyze the codes and the corresponding Popup. If you want to see the Popup file for NickList, click on View and choose Nick List. Now take a look at the codes and compare with what you see in the Nick List Popup when you right click. Making sense?

Let's get going with what we were upto. First you have to decide which window you want to write the Popup for. If it's for the Channel window, click on View and select Channel, similarly, the same for other windows. Now write the following codes in the Popups Editor. We are going to make a Popup for the channel window. Make sure you have chosen Channel from the View Menu.
- 
My First Popup: / 
- 
Hello: say Hello everybody! 
Bye: say Good bye everybody! 
- 
Greetings 
.Thanks Friends:say Thanks for being wonderful friends!
.New Year: say New Year Wishes to all! 
.God Bless: say The blessing of God on all!
-
Love Sayings:{
  say The greatest healing therapy is friendship and love!
  .timer 1 3 say When you love someone, all your saved-up wishes start coming out!
  .timer 1 7 say Love is the emblem of eternity, it confounds all notion of time!
}
-
Quit: quit Killed by a Popup! 
Close mIRC: exit
Sure you have to join a channel and right click in the main channel window to see the result of the above code. If you did all correctly you should see the Popup menu such the below picture:



Using the above code as an example, I will cover the topic on Popups for beginners. Let me explain you the code. The - is to create a line separator between the menus. I used it in the first line to separate the new Popup menu from the already existing Channel Modes menu of the channel Popup. The menu 'My First Popup' is a functionless menu, I used it to give a name to the Popup we just created.

Popups menu definitions follow this pattern Menu name: mIRC-command. For eg: Hello: /say Hello everybody will perform the command /say Hello everybody when you click on Hello in the Popup menu. Hello is the menu name and /say Hello everybody is the command executed by mIRC. Similarly Bye is the menu name and /say Good bye everybody! is the command.

In the next menu we have Greetings as the main and Thanks Friends, God Bless and New Year as submenus. Submenus are created by putting a . (dot) infront of the submenu name following the menu name. And if you want to create submenus under a submenu, you need to put .. (two dots) in front of the sub-submenu name following the submenu name.

In the Love Sayings menu, we have 3 commands. To include more than one command in the Popup (also in Remote), we enclose the commands within { } (curley brackets). Look at the Love Sayings Popup code...

Love Sayings:{
  say The greatest healing therapy is friendship and love!
  .timer 1 3 say When you love someone, all your saved-up wishes start coming out!
  .timer 1 7 say Love is the emblem of eternity, it confounds all notion of time!
}


In additon to that In the commands of this popup you can see .timer 1 3. It's an mIRC command which starts a timer and executes the mIRC command(s) according to the specification. timer 1 3 will execute the command following it, once after 3 secs (1 3). You can observe the same in new menu if you want to. Say you want to sing "Show me Some Emotion" a song by Celine Dion and send some words of the lyric to the current channel, then your codes should be something like :

A song by Celine Dion:{
  me would like to present "Show me Some Emotion" a song by Celine Dion!?
  .timer 1 5 say I've tried my best for so long
  .timer 1 8 say To break down these walls
  .timer 1 11 say But you build them strong
  .timer 1 14 say So I stand here waiting, wondering why
  .timer 1 17 say Oh why
  .timer 1 20 say Why you don't give a little bit
  .timer 1 23 say Break down and give a little bit
  .timer 1 26 say Show, show some emotion
  .timer 1 29 say Open, open your heart, ooh
  .timer 1 32 say Set free an ocean
  .timer 1 35 say Only a feeling can save us now
  .timer 1 38 say You say you've been hurt
  .timer 1 41 say Well you're not alone
  .timer 1 45 say and so on..
}
It contains 15 commands, all of them enclosed within { }. Try removing the . (dot) before the timer command and see what happens.

2. Creating Popups using Remote Editor

You can also create and write Popup code in the Remote Editor by using menu declaration. Below is the basic pattern to create Popup menus using this method :

menu window_name(channel,nicklist,status,menubar,query,@window) {
  menu_name: mirc_command(s)
}
For example :

menu channel {
  leave this channel: part
}
This code is to create a popup menu for the channel window. If you want to create a popup menus for the nick list section (the column at the right corner of the channel window, where you see the nicknames) then the code should look like menu nicklist { leave this channel:part }, and use the same way for other mIRC windows. Just make sure you write all the codes in the Remote tab section in the Scripts Editor. The codes for our first Popups (the popups which we've created in the first session of this tutorial) should look like in the below screenshot when we create this using this method:



easy right!?.

If you want to create a Popup for more than one window name, you can include the locations (window name) separated with a comma after menu. like This :
menu channel,nicklist,query {
  Exit Program: exit
}
wasn't that cool?. With this I close the chapter on Popups. Next I invite you to join me in the vastest and most important subject on mIRC scripting : "Remotes".

Tips: You want to test and debug your remote online scripts without being connected to the Internet?, just run your own IRC server and connect to it. A good one is WIRCSRV. Once you get it running type /server 127.0.0.1 in mIRC to connect.

0 comments:

Post a Comment