- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 253
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-11-22
|
¥»©«³Ì«á¥Ñ Hsieh ©ó 2011-12-3 21:57 ½s¿è
¦^´_ 1# user999
http://blog.xuite.net/crdotlin/excel/13554651
'¤@¯ë¼Ò²Õ Module1 µ{¦¡½X- Option Explicit
- 'API«Å§i
- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
- (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
- (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
- Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
- (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
- 'timeSetEvent¨ç¼Æ½Ð°Ñ¦Ò:http://msdn2.microsoft.com/en-us/library/ms713423.aspx
- Private Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As Long, ByVal uResolution As Long, _
- ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long
- Private Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As Long) As Long
- Private Const EM_SETPASSWORDCHAR = &HCC
- Dim lTimeID As Long 'Timer ID
- Const pswdInputBoxTitle = "pswdInputBox" '¿é¤J±K½Xªº¹ï¸Ü®Ø¼ÐÃD
-
- 'TimeProc callback ¨ç¼Æ½Ð°Ñ¦Ò:http://msdn2.microsoft.com/en-us/library/ms713420.aspx
- Sub TimeProc(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, _
- ByVal dw1 As Long, ByVal dw2 As Long)
- Dim hwd As Long '¿é¤J±K½Xªº¹ï¸Ü®Ø¥y¬`
- 'VBA InputBox¹ï¸Ü®Ø¤§Class Name¬O "#32770",
- '¼ÐÃD¬° "pswdInputBox", ³o¬O¦bInputBox¨ç¼ÆªºTitle¤Þz¤¤¦Ûqªº
- '½Ðª`·NApplication.InputBox¤èªk©Ò¥X²{ªº¹ï¸Ü®ØClass Name¬O "bosa_sdm_XL9"
- hwd = FindWindow("#32770", pswdInputBoxTitle)
- If hwd <> 0 Then 'Y¹ï¸Ü®Ø¦s¦b
- '¨ú±o¿é¤Jªº¤å¦r®Ø¥y¬`, ¸Ó¤å¦r®ØªºClass Name¬O"Edit", µL¼ÐÃD,
- '¦ÓApplication.InputBox¤èªk©Ò¥X²{ªº¹ï¸Ü®Ø¤§¤å¦r®ØªºClass Name¬O"EDTBX"
- hwd = FindWindowEx(hwd, 0, "Edit", vbNullString)
- '³]©w±K½X¦r¤¸¬° "*", "*"ªºASCII½X¬°42
- SendMessage hwd, EM_SETPASSWORDCHAR, 42, 0
- '³]©w§¹¦¨, ¨ú®øp®É¾¹
- timeKillEvent lTimeID
- End If
- End Sub
- '¦Û©w¸q¨ç¼ÆpswdInputBox, ¬O¤@Ó¿é¤J±K½X¨Ï¥ÎªºInputBox, ¿é¤Jªº¤º®e³£¥H "*" Åã¥Ü.
- Function pswdInputBox() As Variant
- '±Ò°Ê¤@Ó¯S©wªºTimer¨Æ¥ó, 0.01¬í©µ¿ð, 0.05¬í¬Ý¤@¦¸
- lTimeID = timeSetEvent(10, 50, AddressOf TimeProc, 1, 1)
- 'Åã¥ÜInputBox¹ï¸Ü®Ø
- pswdInputBox = InputBox(Prompt:="½Ð¿é¤J½s¿è±K½X", Title:=pswdInputBoxTitle)
- End Function
½Æ»s¥N½X 'ªí³æ¼Ò²ÕUserform1µ{¦¡½X
ªí³æ¤W³]¸m¤@Ó¼ÐÅÒLabel1¡B¤Î1Ó«ö¶sCommandButton1
- Private Sub CommandButton1_Click()
- Label1.Caption = ""
- If pswdInputBox <> 123456 Then
- '±K½X¤£¥¿½T, Åã¥Ü°T®§
- Label1.Caption = "¹ï¤£°_¡A±K½X¿ù»~¡A§AµL½s¿èÅv!"
- Else
- Label1.Caption = "Åwªï¨Ï¥Î¥»¨t²Î"
- End If
- End Sub
½Æ»s¥N½X |
|