|
Joined: Nov 2009
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Nov 2009
Posts: 295 |
It'd be nice if mirc could check if there is another instance of mirc running from the same settings. Since it's always a pain when you accidentally open your mirc twice and all protection scripts like ghost and such get into a loop between the two mircs.
My idea is to just have mirc say "Another instance of mirc is running from this location." then have an exit or continue button
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
Good idea, and an option in the settings like "Check if mirc is running on start" including an enable/disable alias like (/checkmirc on/off) will be also good.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
+1. I use a script to check how many mIRC instances are running prior to running my main ON START event, so that I don't launch multiple connections to the same network by accident.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Mar 2011
Posts: 2
Bowl of petunias
|
Bowl of petunias
Joined: Mar 2011
Posts: 2 |
|
|
|
|
Joined: Nov 2009
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Nov 2009
Posts: 295 |
Yeah i'm thinking about scripting something for now, but a built in feature would probably be more reliable. Mind sharing how you are doing it? I was thinking check if a file exists before doing anything, if it does stop and close. That should work unless mirc crashes and is unable to delete the lock file when it closes. [update] I made a little script using the lock file idea.
on *:load:{ write running.lock | .reload -rs1 $script }
on *:unload: if ($isfile(running.lock)) remove running.lock
on *:start:{ if ($isfile(running.lock)) { set -e %er 1 | exit } | else write running.lock }
on *:exit: if (!%er) remove running.lock
It reloads it self as the 1st script since I know I have scripts that do connection stuff and it should run first. It works better than I hoped, but I do get the vars.ini file has changed popup since I do set a var in the check.
Last edited by pball; 24/03/11 11:10 PM.
|
|
|
|
Joined: Apr 2010
Posts: 969
Hoopy frood
|
Hoopy frood
Joined: Apr 2010
Posts: 969 |
I do something similar, except i check if the mirc.ini is being used: alias -l mFile { return "C:\mircini.txt" }
alias -l mCheck {
if ($read($mFile,snp,$mIRCIni)) {
var %l $v1
if ($1 == -s) { exit }
else {
write -dl $+ %l $mFile
if (!$read($mFile,np,1)) { .remove $mFile }
}
}
elseif ($1 == -s) {
write $mFile $mIRCIni
}
}
on *:Start:{
if ($script(1) != $script) { .reload -rs1 $script }
mCheck -s
}
on *:Unload:{ mCheck }
on *:Exit:{ mCheck }
|
|
|
|
Joined: Feb 2003
Posts: 31
Ameglian cow
|
Ameglian cow
Joined: Feb 2003
Posts: 31 |
I, too, would like to see this. I also try to use a script to keep track of mIRC's current instance, but computer crashes easily yield incorrect results. It would be very helpful if mIRC could tell me which instance it is via an identifier ("$mIRCInstance" perhaps).
Of course, the behavior of such an item would need to be determined: upon opening two instances, and closing the first, then opening a new instance, does the new instance receive a new ID number or revert to the first?
In this case, two identifiers may be appropriate: one to provide a unique ID (which is reset only upon system boot), and another to indicate how many instances were running at the time of mIRC's launch. (This seems somewhat parallel to the function of scid/scon.)
Maybe this isn't mIRC's job, but it would certainly make things easier.
|
|
|
|
Joined: May 2007
Posts: 37
Ameglian cow
|
Ameglian cow
Joined: May 2007
Posts: 37 |
A better workaround that doesn't involve creating a special file or something like that is: alias numMirc {
.comopen numMirc1 WbemScripting.SWbemLocator
if ($com(numMirc1)) .comclose numMirc1 $com(numMirc1,ConnectServer,3,dispatch* numMirc2)
if ($com(numMirc2)) .comclose numMirc2 $com(numMirc2,ExecQuery,3,bstr, $&
SELECT * FROM Win32_Process WHERE Name = "mirc.exe" $&
,dispatch* numMirc3)
if ($com(numMirc3)) {
var %total $comval(numMirc3,0)
.comclose numMirc3
return %total
}
:error
if ($com(numMirc1)) .comclose numMirc1
if ($com(numMirc2)) .comclose numMirc2
if ($com(numMirc3)) .comclose numMirc3
return -1
} I'm not sure what you mean by "running from the same settings". If you meant that you wanted to return only the number of mIRCs running that use the same .exe, change: SELECT * FROM Win32_Process WHERE Name = "mirc.exe" to SELECT * FROM Win32_Process WHERE ExecutablePath = $qt($replace($mircexe,\,\\)) I agree that this would be a nice feature to have implemented anyway, but the above script should work just as well!
Last edited by Chessnut; 11/04/11 03:38 AM.
|
|
|
|
Joined: Dec 2002
Posts: 344
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Dec 2002
Posts: 344 |
I'm not sure what you mean by "running from the same settings". He means sessions that use the same mirc.ini configuration file, basically. You might want to be able to run one copy of mIRC with mirc1.ini and a second copy of mIRC with mirc2.ini, but not be able to run two copies of mIRC with mirc1.ini at the same time. Unfortunately this looks to be a bit harder to do with your method (you'd have to compare $mircini from each session). I think a built-in method of preventing multiple sessions would work best for this. Not because it's impossible to do with scripting, but because it would be useful enough, IMO, to build into the program directly.
|
|
|
|
Joined: Nov 2009
Posts: 295
Fjord artisan
|
OP
Fjord artisan
Joined: Nov 2009
Posts: 295 |
drum you are correct about what I mean about a single instance of mirc running. I still believe a built in method would be best but Chessnut has posted something that seems like the best alternative. I have a little alias that returns if a given program is running, but the way it's made isn't helpful since it just gives true or false. However that code above is quite perfect since it can check if the current mirc exe is being ran twice. Thanks Chessnut p.s. i only ever run 1 mirc exe with 1 mirc.ini so i don't have to bother checking anything more than if the mirc exe is already running. edit: posting the final script, which is 99% Chessnut's and 1% on start event ^_^
on *:start: if ($numMirc > 1) exit
alias numMirc {
.comopen numMirc1 WbemScripting.SWbemLocator
if ($com(numMirc1)) .comclose numMirc1 $com(numMirc1,ConnectServer,3,dispatch* numMirc2)
if ($com(numMirc2)) .comclose numMirc2 $com(numMirc2,ExecQuery,3,bstr, $&
SELECT * FROM Win32_Process WHERE ExecutablePath = $qt($replace($mircexe,\,\\)) $&
,dispatch* numMirc3)
if ($com(numMirc3)) {
var %total $comval(numMirc3,0)
.comclose numMirc3
return %total
}
:error
if ($com(numMirc1)) .comclose numMirc1
if ($com(numMirc2)) .comclose numMirc2
if ($com(numMirc3)) .comclose numMirc3
return -1
}
Last edited by pball; 11/04/11 04:14 PM.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
In fact this is the script I use to keep my instances in check. Rather than exiting, I use the check to avoid any initialization: on *:START: {
if ($count_processes(mirc%.exe) <= 1) {
server irc.server.com ...
server irc.server2.com
}
}
This way I could start multiple instances of mIRC but without automatically creating multiple connections. Very useful for debugging, especially when testing different versions of the client. In that sense, it would be equally useful for mIRC to expose a builtin identifier to give us the number of running mIRC processes so we can use this check in our scripts.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Feb 2011
Posts: 462
Pan-dimensional mouse
|
Pan-dimensional mouse
Joined: Feb 2011
Posts: 462 |
This might not be reliant, but you could set mIRC to require a password on Startup.
Tools -> Options -> Other -> Lock
I have this set so that I do not accidentally open another instance of mIRC, and to also keep mIRC "locked down" while I am away from my computer.
|
|
|
|
|