给程序加入动态生成验证码
By
admin
at 2022-11-09 • 0人收藏 • 896人看过
点击图片框动态生成验证码源码, 不是识别,是生成
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=393;bottom=284) winform.add( edit={cls="edit";left=73;top=175;right=222;bottom=219;align="center";edge=1;font=LOGFONT(h=-24);multiline=1;z=2}; picturebox={cls="picturebox";left=71;top=43;right=327;bottom=152;bgcolor=12639424;notify=1;z=1} ) /*}}*/ import gdip; import gdip.graphics; import gdip.family; import gdip.solidBrush; import console console.open() winform.picturebox.oncommand = function(id,event){ math.randomize() var str = ""; for(i=1;5;1){ str = string.concat(str,math.random(0,9)); } winform.edit.text = str; var bmp = gdip.bitmap(130,40); var g = gdip.graphics(bmp); var pen = gdip.pen( 0xFF008000 , 2, 2/*_GdipUnitPixel*/ ); for(i=1;10;1){ g.drawLine(pen,math.random(0,bmp.width),math.random(0,bmp.height),math.random(0,bmp.width),math.random(0,bmp.height)); } for(i=1;500;1){ bmp.setPixel(math.random(0,bmp.width),math.random(0,bmp.height),0xFF000000); } var fonts = { "微软雅黑", "宋体", "黑体" }; var colors = {0xFF0FFF00,0xFF0000FF,0xFFFF0000,0xFF000000,0xFF008000}; var strformat = gdip.stringformat(); for(i=1;5;1){ var brush = gdip.solidBrush(colors[math.random(1,5)]); var family = gdip.family(fonts[math.random(1,3)]); var curFont = family.createFont( 25,2/*_GdipFontStyleItalic*/, 2/*_GdipUnitPixel*/) g.drawString( str[[i]] , curFont, gdip.RECTF((i-1)*25,0), strformat,brush); brush.delete(); curFont.delete(); family.delete(); } strformat.delete(); winform.picturebox.image = bmp.copyHandle(); } winform.show(); win.loopMessage();
2 个回复 | 最后更新于 2022-12-04
登录后方可回帖
牛plus