[VB]訊息輔助輸入(原始碼) (原創程式)
有的文字可能常常用到,方便打字慢的人不必每次都手動輸入
只要把常用的字存到BYREF.TXT裡,程式就把那些文字載出
你只要開啟程式 把滑鼠停駐在要輸入文字的視窗上 點擊 程式上
你要輸出的文字兩下,就會幫你完成輸出的動作了。
Option Explicit
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
ByVal cy As Long, ByVal wFlags As Long) As Long
Const SWP_NOMOVE = &H2 '不更動目前視窗位置
Const SWP_NOSIZE = &H1 '不更動目前視窗大小
Const HWND_TOPMOST = -1 '設定為最上層
Const HWND_NOTOPMOST = -2 '取消最上層設定
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim lhwnd As Long
Private Sub Form_Load()
'將 APP 視窗設定成永遠保持在最上層
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS
Dim a
Open App.Path & "/byref.txt" For Input As #1
While Not EOF(1)
Line Input #1, a
List1.AddItem a '增加list1.additem
Wend
Close #1
End Sub
Private Sub Text1_Change()
End Sub
Private Sub Form_Unload(Cancel As Integer)
'取消最上層設定
SetWindowPos Me.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS
End Sub
Private Sub List1_DblClick()
SetForegroundWindow lhwnd
DoEvents
SendKeys List1.Text
End Sub
Private Sub Timer1_Timer()
If GetForegroundWindow <> Me.hwnd Then lhwnd = GetForegroundWindow
End Sub
Private Sub 重新整理_Click()
Dim a
List1.Clear
Open App.Path & "/byref.txt" For Input As #1
While Not EOF(1)
Line Input #1, a
List1.AddItem a '增加list1.additem
Wend
Close #1
End Sub
Private Sub 結束_Click()
Unload Me
End Sub
Private Sub 編輯_Click()
Dim s1 As String, s2 As String, s3 As String
s1 = App.Path
s2 = "\BYREF.txt"
s3 = "Notepad.exe"
Shell s3 & " " & s1 & s2, vbNormalFocus
End Sub
如有錯誤 歡迎指正