473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Vb code works in vb not by self

ht
hi all,

im kinda new to vb and i have code that unhides a hidden from on a key press

for some reason though this code only works when running th app through by,
ie. it wont work in the standalone program. Source code can be downloaded
from http://www.geocities.com/thecubical/temp.zip

source code
----------------------from form--------------------------
Private Sub Command1_Click()
Dim ip As String
ip = InputBox("Please enter the ip to send the message to", "Ip to send
to")
Winsock1.Close 'must close to stop error
Winsock1.Connect ip, 123 'connect to ip and port
End Sub


Private Sub Form_Load()
Winsock2.Close 'must close to stop error
Winsock2.LocalPort = 123
Winsock2.Listen 'listen for incoming messages
'set a keyboard hook
hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf KeyboardProc,
App.hInstance, App.ThreadID)

End Sub

Private Sub Winsock1_Close()
On Local Error Resume Next
Winsock1.Close 'close winsock on error

End Sub
Private Sub Winsock1_Connect()
Dim message As String

message = InputBox("Please enter the message to send", "Type your
message")
Winsock1.SendData message 'send the message to client

End Sub
Private Sub Winsock2_Close()
Winsock2.Close 'boof
Winsock2.Listen 'boof

End Sub

Private Sub Winsock2_ConnectionRequest(ByVal requestID As Long)
'boof
If Winsock2.State <> sckConnected Then
Winsock2.Close
End If
'end boof

Winsock2.Accept requestID 'accept connection to server

End Sub

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim arriving_message As String
Winsock2.GetData arriving_message 'accept a message from server
MsgBox arriving_message 'print message in msgbox

End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String,
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal
HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Error " & Description, vbOKOnly + vbExclamation

End Sub
Private Sub Winsock1_SendComplete()
Winsock1.Close 'when server finished sending message
close connection

End Sub
Private Sub Winsock2_Error(ByVal Number As Integer, Description As String,
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal
HelpContext As Long, CancelDisplay As Boolean)
On Local Error Resume Next ' boof
MsgBox "Error " & Description, vbOKOnly + vbExclamation
Winsock2.Listen 'boof

End Sub
Private Sub Winsock2_SendComplete()
On Local Error Resume Next
Winsock1.Close 'when client finished getting message
close connection

End Sub
Private Sub Form_Unload(Cancel As Integer)
'remove the windows-hook
UnhookWindowsHookEx hHook
Winsock1.Close 'close winsocks on exit
Winsock2.Close

End Sub

------------------------from module---------------------
'In a module
Public Const WH_KEYBOARD = 2
Public Const VK_SHIFT = &H10
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal
ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As
Integer
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 UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As
Long
Public hHook As Long
Public Function KeyboardProc(ByVal idHook As Long, ByVal wParam As Long,
ByVal lParam As Long) As Long
'if idHook is less than zero, no further processing is required
If idHook < 0 Then
'call the next hook
KeyboardProc = CallNextHookEx(hHook, idHook, wParam, ByVal lParam)
Else
'check if SHIFT-S is pressed
If (GetKeyState(VK_SHIFT) And &HF0000000) And wParam = Asc("S") Then
'show the result
Form1.Show
ElseIf (GetKeyState(VK_SHIFT) And &HF0000000) And wParam = Asc("D")
Then
Form1.Hide
End If
'call the next hook
KeyboardProc = CallNextHookEx(hHook, idHook, wParam, ByVal lParam)
End If
End Function
----------------------------------------------------------

thanks for any help


Jul 17 '05 #1
0 4350

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Matthew | last post by:
Hi, I am working on a small project as well as trying to learn python. I parse a text file like def some_user_func(): # <name> Some user function #<description> The description pass
15
by: Ralf W. Grosse-Kunstleve | last post by:
****************************************************************************** This posting is also available in HTML format: http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html...
18
by: Ralf W. Grosse-Kunstleve | last post by:
My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... And Now for Something Completely Different: class autoinit(object):...
1
by: LenS | last post by:
If this is the wrong place to post this, please advise better place. Otherwise, I have created the following python program and it works. Running on XP. I think I am now at that stage of learning...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
7
by: mwt | last post by:
Hello - Last night I wrote my first code in Python -- a little producer/consumer toy to help me begin to understand things. The "Library" only has a few books. You can choose how many Readers are...
10
by: Mythmon | last post by:
I am trying to make a program that will basically simulate a chess clock in python. To do this I have two threads running, one that updates the currently running clock, and one that watches for a...
1
by: manatlan | last post by:
I was a fan of "SimpleGladeApp/tepache way" to build a pygtk app. I've build a new efficient/dynamic way to build a pygtk app ... Here is an example :...
0
by: vml | last post by:
Hello, I am trying to mograte from vb 6 to python. I have a very usefull AX control. It can be : -just a bitmap -an active picture where you can plot data and put cursors -a data explorer ...
4
by: tdahsu | last post by:
All, I'd appreciate any help. I've got a list of files in a directory, and I'd like to iterate through that list and process each one. Rather than do that serially, I was thinking I should...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.