找回密码
 加入
搜索
查看: 1042|回复: 3

探讨 仿农行密码输入盘(遇问题,请高人来帮忙)

[复制链接]
发表于 2009-5-1 02:15:59 | 显示全部楼层 |阅读模式
本帖最后由 lm959680 于 2009-5-1 11:29 编辑

那就说说我要的功能吧`~~  大侠们留点情~~别拍我砖啊`~~

反正我都是放源码的,连思路一起说了,大家别抢我“饭碗”。

仿农行的“密码输入键盘”,做个挂机锁~~用API锁键盘(代码已有)

程序现在出现的问题:随机数重复,生成的按钮读取不了数据但能操作!!

部份代码是现成研究的 是“破帽遮颜”大侠转官方的“随机变换颜色”哈哈 现学现卖~~~
先睡觉了,困困`~~
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $Button[10][10],$b
$Form1 = GUICreate("密码键盘", 133, 165, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
For $x = 1 To 3
        For $y = 1 To 4
                $Button[$x][$y] = GUICtrlCreateButton("", ($x * 42) - 36, ($y * 38) - 30, 38, 35)
                If $Button[$x][$y] <> 10 Or $Button[$x][$y] <> 14 Then
                        For $i = 1 To 10
                                $a = Random(0, 9,1)
                                While StringInStr($b, $a) <> 0
                                        $a = Random(0, 9,1)
                                WEnd
                                GUICtrlSetData($Button[$x][$y], $a)
                                GUICtrlSetOnEvent($Button[$x][$y], "_ButtonXY");这个ID用“-1”也控制的了。
                        Next
                        
                EndIf
        Next
Next
GUICtrlSetData($Button[2][4], "退格")
GUICtrlSetOnEvent($Button[2][4], "_ButtonBackspace");ID用“-1”的话,控制不了。不知原因在哪!所以全部指定ID算了``
GUICtrlSetData($Button[3][4], "清除")
GUICtrlSetOnEvent($Button[3][4], "_ButtonClear");这个ID用“-1”倒是控制的了。郁闷~~
GUISetState()

While 1
        Sleep(1000)
WEnd

Func _ButtonXY()
        MsgBox(0, "", GUICtrlRead($Button[$x][$y]))
EndFunc   ;==>_ButtonXY

Func _ButtonBackspace()
        Exit
EndFunc   ;==>_ButtonBackspace

Func _ButtonClear()
        Exit
EndFunc   ;==>_ButtonClear

Func Form1Close()
        Exit
EndFunc   ;==>Form1Close
 楼主| 发表于 2009-5-1 05:27:28 | 显示全部楼层
本帖最后由 lm959680 于 2009-5-1 05:31 编辑

看了没人帮~~  自己坐沙发`~~哼哼!!
发表于 2009-5-1 06:27:36 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#Include <Array.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)
Global $Button[13], $j = 0, $array[1]

$Form1 = GUICreate("密码键盘", 133, 165, -1, -1)

GUISetOnEvent($GUI_EVENT_CLOSE, "_ButtonXY")

$b = Random(0, 9, 1)
_ArrayAdd($array, $b)
_ArrayDelete($array, 0)

For $i = 1 To 9
        Do
                $b = Random(0, 9, 1)
                $Index = _ArraySearch($array, $b)
        Until $Index = -1
        _ArrayAdd($array, $b)
Next

Dim $x = 1, $y = 1

For $i = 1 To 12
        Select
                Case $i <= 10
                        $arrayButton = $array[$i - 1]
                Case $i = 11
                        $arrayButton = "退格"
                Case $i = 12
                        $arrayButton = "清除"
        EndSelect
        $Button[$i] = GUICtrlCreateButton($arrayButton, ($x * 42) - 36, ($y * 38) - 30, 38, 35)
        GUICtrlSetOnEvent($Button[$i], "_ButtonXY")
        $x += 1
        If $x = 4 Then
                $x = 1
                Switch $y
                        Case 1
                                $y = 2
                        Case 2
                                $y = 3
                        Case 3
                                $y = 4
                EndSwitch
        EndIf
Next
GUISetState()

While 1
        Sleep(1000)
WEnd

Func _ButtonXY()
        Switch @GUI_CtrlId
                Case $Button[12]
                        MsgBox(4096, "", "")
                Case $Button[11]
                        Exit
                Case $GUI_EVENT_CLOSE
                        Exit
                Case Else
                        MsgBox(4096, "", GUICtrlRead(@GUI_CtrlId))
        EndSwitch
EndFunc
写的乱七八糟的,但大体实现了楼主想要的效果
 楼主| 发表于 2009-5-1 11:28:06 | 显示全部楼层
本帖最后由 lm959680 于 2009-5-1 11:29 编辑

呵呵 还是“破帽遮颜”(貌是还没睡觉??)好`~~谢了`~~

看了下,问题都解决了``~我现抄就是现抄,死脑筋一个`~

我用易语言到是简单 实现了`~~   按钮加标记实现!!

.版本 2

_计算 ()

.子程序 _计算
.局部变量 按钮, 按钮
.局部变量 i, 整数型
.局部变量 a, 整数型
.局部变量 b, 文本型

置随机数种子 ()
.计次循环首 (10, i)
    a = 取随机数 (0, 9)
    .判断循环首 (寻找文本 (b, 到文本 (a), 1, 假) ≠ -1)
        a = 取随机数 (0, 9)
    .判断循环尾 ()
    按钮 = 取标记组件 (i)
    按钮.标题 = 到文本 (a)
    b = b + 到文本 (a)
.计次循环尾 ()
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-20 21:33 , Processed in 0.072923 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表