Jump to content

Recommended Posts

Posted

This is a visual basic script I found, but I'm not familiar with visual basic programming. I'm looking into the functionality of this script. From what I gathered, it might be similar to what I'm looking for, but the site was in a different language and I'm not exactly sure if I completely comprehended what was interpreted. If someone who knows VB would care to comment on the functionality of this script, it would be helpful, thanks.

' this SOURCE comes from http://www.activevb.de

' and can be used freely. For possible damage

' is not responsible.

' around

errors or questions to clarify, you use please our forum.

' otherwise much fun and success with this SOURCE!

' at the beginning of project file Project1.vbp

------------

' the component ' Microsoft Windows

Common control 5,0 (SP2)

' (comctl32.ocx) ' is

needed.

' beginning form "Form1" alias Form1.frm

--------

' control member: Switching

surface "Command1"

' control member:

Inscription field "Label5"

' author:

Kopczynski

' E-Mail: D.Copy@gmx.de

option Explicit

private Sub Form_Load()

call SetHotKey(Me.hWnd, &H1 + &H2, &H77)

end to Sub

private Sub Form_Unload(Cancel As Integer)

call RemoveHotKey

end to Sub

private Sub Command1_Click() App.TaskVisible = False

Me.Hide

end to Sub

' end form "Form1"

alias Form1.frm ---------

' beginning module

"Module1" alias Module1.bas --------

option Explicit

private one Declare Function RegisterHotKey Lib "user32" (ByVal _

hWnd As Long, ByVal ID As Long, ByVal fsModifiers As _

Long, ByVal vk As Long) As Long

private Declare Function UnregisterHotKey Lib "user32" (ByVal _

hWnd As Long, ByVal ID As Long) As Long

private Declare Function CallWindowProc Lib "user32" alias _

"CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal _ hWnd As Long, ByVal Msg As Long, ByVal wParam As _

Long, ByVal lParam As Long) As Long

private Declare Function SetWindowLong Lib "user32" alias _

"SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex _

As Long, ByVal dwNewLong As Long) As Long

private Declare Function global DELETE atom Lib "kernel32" _ (ByVal nAtom As Integer) As Integer

private Declare Function global ADD atom Lib "kernel32" alias _

"GlobalAddAtomA" (ByVal lpString As stringer) As Integer

Const GWL_WNDPROC As Long = (-4&)

Const WM_HOTKEY As Long = &H312&

Public Enum ModKeys MOD_ALT = &H1 MOD_CONTROL = &H2 MOD_SHIFT =

&H4 MOD_WIN = &H8

end to

Enum

private OldProc As Long, hOwner As Long

private one iAtom As Integer

Public Sub SetHotKey(hWnd As Long, ModKey As ModKeys, _ vKey As Long) hOwner = hWnd iAtom =

GlobalAddAtom("MyHotKey")

call RegisterHotKey(hOwner, iAtom, ModKey, vKey) OldProc =

SetWindowLong(hOwner, GWL_WNDPROC, _ AddressOf WndProc)

end Sub

Public Sub RemoveHotKey()

If more hOwner = 0 Then exit Sub

call UnregisterHotKey(hOwner,

iAtom)

call SetWindowLong(hOwner, GWL_WNDPROC, OldProc)

call GlobalDeleteAtom(iAtom)

end to Sub

Public Function WndProc(ByVal hWnd As Long,

_

ByVal wMsg As Long, ByVal wParam As Long, _

ByVal lParam As Long) As Long

If wMsg = WM_HOTKEY and wParam = iAtom Then

Form1.Show

Else

WndProc = CallWindowProc(OldProc, hWnd, wMsg, wParam,

lParam)

end to If

end to Function

' end module "Module1" alias Module1.bas ---------

' end of project file Project1.vbp -------------

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...