大致上標題有講.
例如先開程式之後
再開一個純文字文件OR WORD
然後在文件上打資料
接著VB可以把那些所打的資料儲存下來
然後再把那些東西使用VB存成另一個文件檔~
當然主要問題還是上上面那行
\"把那些所打的資料儲存下來\"
在那段期間裡VB是維持在非駐點情形下(大概是這樣)
2006-08-23 17:54:04 · 1 個解答 · 發問者 ? 2 in 電腦與網際網路 ➔ 程式設計
剛剛試了一下
不過有錯誤跑出來
上面寫AddressOf的用法不正確耶~?
2006-08-26 09:51:10 · update #1
原來忘了放到BAS裡..
不過又有疑問
我們打的文字是儲存在哪個變數裡~?
2006-08-26 12:42:07 · update #2
我剛你講後,請你不要做非法事情,
你要用API函數(application programming interface) <<別說你不知道= =
SetWindowsHookEx
CallNextHookEx
UnhookWindowsHookEx
宣告法:
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Declare Function CallNextHookEx Lib "user32" Alias "CallNextHookEx" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function UnhookWindowsHookEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal hHook As Long) As Long
再開始執行的時候
Public hookid As Long'hook ㄉ ID
Public Const HC_ACTION = 0
Public Const WH_KEYBOARD = 2
private sub form_load()
If hookid <> 0 Then Exit Sub
hookid = SetWindowsHookEx(WH_KEYBOARD, AddressOf commander, App.hInstance, HC_ACTION)
end sub
'注意:AddressOf commander << commander 是你要自己建的函式(在BAS中)
'我現在用commander來舉例 ,你可以改名子
'Function commander(ByVal icode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If icode < 0 Then commander = CallNextHookEx(hookid, icode, wParam, lParam)
Exit Function
end if
'紀錄的事件自己寫(我不想多說)
'其中Wparam代表按下哪鍵(對照KeyCodeConstants 有些不行喔)
Call CallNextHookEx(hookid, icode, wParam, lParam)
end fuction
private sub form_unload()
If hookid <> 0 Then
UnhookWindowsHookEx hookid
hookid = 0
End If
end sub
不過我記得WINDOWS好像規定這3ㄍAPI要放DLL中,要不然好像不能執行(書上寫ㄉ)
2006-08-27 14:41:58 補充:
wparam << 這個所以你只要在寫個程序把WPARAM紀錄到記事本就可ㄌ(程序自己寫)wparam 他會是數字,可是他對應KeyCodeConstants 例如:wparam=65="A"=vbKeyA
2006-08-23 21:23:36 · answer #1 · answered by 果子 2 · 0⤊ 0⤋