First of all, im posting this from my cellphone so if there are any typos i am truly sorry. Second, i welcome criticism as long as you dont insult me or my knowledge of mSL. This is my simple passgen coded with DCX. Uses system icons. Enjoy.
alias pass {
if ($dialog(pass)) { dialog -x pass }
dialog -m pass pass
}
alias DCX_pass {
}
dialog pass {
title "ProSec-iRc PassGen"
size -1 -1 100 60
option dbu
box "", 1, 1 3 98 51
}
on *:dialog:pass:init:*: {
dcx Mark $dname pass_cb
xdialog -g pass +b $rgb(0,0,0)
xdialog -c $dname 2 button 5 18 190 19
xdid -t $dname 2 Alpha
xdid -w $dname 2 +n 146 shell32.dll
xdialog -c $dname 3 button 5 39 190 19
xdid -t $dname 3 Numeric
xdid -w $dname 3 +n 146 shell32.dll
xdialog -c $dname 4 button 5 61 190 19
xdid -t $dname 4 Alpha-Numeric
xdid -w $dname 4 +n 146 shell32.dll
xdialog -c $dname 5 button 5 82 190 19
xdid -t $dname 5 Close
xdialog -w $dname 5 +a 44 shell32.dll
xdid -w $dname 5 +n 27 shell32.dll
}
alias pass_cb {
if ($2 == sclick) && ($3 == 2) {
echo -a $rand(a,z) $+ $rand(A,Z) $+ $rand(a,z) $+ $rand(A,Z) $+ $rand(a,z) $+ $rand(A,Z) $+ $rand(a,z) $+ $rand(A,Z)
}
else if ($2 == sclick) && ($3 == 3) {
echo -a $rand(0,9) $+ $rand(0,9) $+ $rand(0,9) $+ $rand(0,9) $+ $rand(0,9) $+ $rand(0,9) $+ $rand(0,9) $+ $rand(0,9)
}
else if ($2 == sclick) && ($3 == 4) {
echo -a $rand(0,9) $+ $rand(0,9) $+ $rand(a,z) $+ $rand(A,Z) $+ $rand(0,9) $+ $rand(0,9) $+ $rand(A,Z) $+ $rand(a,z)
}
else if ($2 == sclick) && ($3 == 5) {
dialog -x pass
}
}
Unfortunately, colored buttons have to be drawn using bitmap images in DCX. You can either specify a button bitmap or just use an image control. The windows API allows you to change the background color of a button object, but DCX does not support the property of BackColor yet, as far as i know.
Looking at the documentation, I have never messed with hgradient or vgradient. I do not know how to use them.
On the note of reducing code, if using v6.35 or higher, you can use:
$regsubex($str(.,4),/./g,$r(a,z) $+ $r(A,Z))
rather than
$rand(a,z) $+ $rand(A,Z) $+ $rand(a,z) $+ $rand(A,Z) $+ $rand(a,z) $+ $rand(A,Z) $+ $rand(a,z) $+ $rand(A,Z)
to trim a bit
ProSec
i use dcx because it looks cleaner. i just like the look lol. still trying to figure out how to do colored buttons though.
I can show you how to do coloured TEXT. As for coloured buttons, I don't think I had figured that out, either. I faintly remember trying when building Limeplayer... but the text was the best I could get going....
EDIT: Actually, it's not possible as of 1.4.0 (the last official build released via their website). When you try to use xdid -C +b it will just give the button a thick black outline no matter what colour you choose.
http://dcx.scriptsdb.org/archive.htm For the official download spot. Also, this site has instructions for all the DCX commands, so if you wanted to modify this script it would be easier.
I don't get why DCX was used for a such a simple system, though x.x
Here's a link to all the DLLs on my site, http://www.hawkee.com/phpBB2/viewtopic.php?t=23225
Truthfully i dont like using loops, as its simpler to do it this way, and as far as the dcx dll, when i first started scripting, no one would help me. Im self taught, which means i had to find these particular dlls myself. Made me a better scripter. Besides, a quick google search will get you the appropriate file. And most importantly, im posting these things from a semi-smartphone, so i cant really upload files. It took me around an hour to transcribe these 60+ lines of code from my phone. Thanks for the tip though.
You could cut down some by using a while loop to create the random passwords by passing a number of arguments to the alias itself, such as: length of the password, Pass type (numeric, alpha-numeric, etc.) Doing so could provide a wider spectrum of passwords to be generated.
It may also be prudent to, since it uses DCX, add a link to the file or post the DCX zip as a 'script' here on Hawkee so we can use it without having to go looking for it..