|
-
Dec 16th, 2008, 05:25 PM
#1
Thread Starter
Member
[RESOLVED] Creating vb .net macros
Hello,
I am trying to figure out how to get a program to respond a certain key combination is pressed. Eg. Ctrl+ Shift + Y + U. I have searched multiple forums and google and have been unable to find it. Any help would be greatly appreciated. Thanks In advance!
-
Dec 16th, 2008, 05:31 PM
#2
Hyperactive Member
Re: Creating vb .net macros
Not sure if .NET supports keyboard hooks. But that's how it could be done.
-
Dec 16th, 2008, 05:56 PM
#3
Addicted Member
Re: Creating vb .net macros
-
Dec 16th, 2008, 10:12 PM
#4
Thread Starter
Member
Re: Creating vb .net macros
Thanks! That keyboard hook worked great! I just have 1 more question if I may, I can run code to check key state on the keydown event of that keyboard hook. but the trick is, is that I can only see if 1 key is held down at a time, and I need to do atleast 2, any advise? here is the code I am currently using:
Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
-
Dec 17th, 2008, 03:04 AM
#5
Addicted Member
Re: Creating vb .net macros
You probally need to now if [alt]-[ctrl]-[shift]-[e] is presses, the rest of the keys can be detected as flags...
-
Dec 17th, 2008, 03:08 AM
#6
Re: Creating vb .net macros
have a look at the hotkeys link in my signature
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 17th, 2008, 09:45 AM
#7
Re: Creating vb .net macros
Do you mean something like this?
vb.net Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If ((e.KeyCode = Keys.Z) AndAlso (e.Modifiers = (Keys.Control Or Keys.Shift))) Then
'checks for CTRL+SHIFT+Z
End If
End Sub
-
Dec 17th, 2008, 10:09 AM
#8
Re: Creating vb .net macros
Hack makes a very good point... are you looking to respond to GLOBAL keyboard hooks on regardless of what app is in use when the certain combination is pressed? Or are you just looking to respond to certain keyboard combinations in your own form?
The solution to the 2 is very different..
-
Dec 17th, 2008, 11:45 AM
#9
Thread Starter
Member
Re: Creating vb .net macros
Hello again,
First off, thank you for all of your help thus far. I should only need to use it on the form. What I am doing is creating a program that will lock the computer much like windows does, but unlike windows will be harder to crack as the password will have a triple redundant 256 bit encryption with a salt. and cannot be closed by any other means then by bringing up the prompt with the key combination and then entering your personal login info. Dont know if any of that will make a difference in how I should approach it, but there it is incase it will. Thank you again for your help.
-
Dec 17th, 2008, 12:07 PM
#10
Re: Creating vb .net macros
How would you stop someone from just terminating your application?
-
Dec 17th, 2008, 01:38 PM
#11
Thread Starter
Member
Re: Creating vb .net macros
I am handling each individual on closing event, whenever the process for task manager becomes present it terminates it, the form is always on top and takes up the entire screen so they cannot get int cmd to use tskill.exe. If anyone would like to see the code I would be more then happy to post examples
-
Dec 17th, 2008, 02:32 PM
#12
Re: Creating vb .net macros
yes, if you would like to post a code example which locks down the system, I will be more than happy to look at it and show you where I can crack it (if I can).
-
Dec 17th, 2008, 02:41 PM
#13
Thread Starter
Member
Re: Creating vb .net macros
here it is.
Please forgive me, this code isnt very clean as I kind of just threw it together. I am planning on cleaning it up later, but at the moment I havent taken the time to do so.
Code:
Public Class frmMain
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public intTotal As Integer = 0
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If e.CloseReason = CloseReason.UserClosing And intTotal <> 1 Then
e.Cancel = True
ElseIf e.CloseReason = CloseReason.WindowsShutDown Then
On Error Resume Next
e.Cancel = True
Shell("shutdown -a")
ElseIf e.CloseReason = CloseReason.TaskManagerClosing Then
e.Cancel = True
ElseIf e.CloseReason = CloseReason.FormOwnerClosing Then
e.Cancel = True
ElseIf e.CloseReason = CloseReason.None Then
e.Cancel = True
ElseIf e.CloseReason = CloseReason.MdiFormClosing Then
e.Cancel = True
End If
End Sub
Private Sub ActivateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ActivateToolStripMenuItem.Click
Me.Show()
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
intTotal = 1
Me.Close()
End Sub
Private Sub frmMain_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim processes() As Process = Process.GetProcesses
Dim newprocess As New Process
For Each newprocess In processes
If newprocess.ProcessName = "taskmgr" Then
On Error Resume Next
newprocess.Kill()
Me.Activate()
End If
Next
If GetAsyncKeyState(Keys.Oemtilde) Then
frmLogin.Show()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
frmLogin.Show()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Me.Show()
End Sub
End Class
*Edit* I eventually will try and add system hooks, but at the moment that is a bit beyond me, if you guys know any reading material either online or book that will help me begin to learn the advanced concepts and practices of vb I would be very grateful for the information.
Also, this has one workaround that I dont believe I can fix and that is a hard shutdown, unless I can set it to run the program on login through the registry, but I do not know if that would work or not.
Last edited by dwm8888; Dec 17th, 2008 at 02:44 PM.
-
Dec 17th, 2008, 03:24 PM
#14
Re: Creating vb .net macros
well for starters, I run 4 monitors on this computer. If your intention is to lock a computer down by maximizing a borderless form, it already fails on my system because it would only cover one of my screens..
-
Dec 17th, 2008, 03:41 PM
#15
Thread Starter
Member
Re: Creating vb .net macros
First off I would like to say that I am drooling over the idea of a four monitor system. I am only a college student and as such can only afford to use my laptop to develop...
That being said, this software was developed for this laptop, like I said I really want to become proficient in learning the advanced concepts so I can develop my own system hooks and turn windows into my playtoy.
Unfortunately my college specializes in CIS with a focus on software development, and I am trying to get into personal and network security, with the hope of one day joining a Tiger Team.
If you know of a way that I can develop an adaptive subprocedure that would determine the number of monitors in use and then allow me to deploy a form on each that would be great!
-
Dec 17th, 2008, 03:49 PM
#16
Re: Creating vb .net macros
Look at the My.Computer.Screen class for easy acces in VB to info about the number of screens.
You can get the count via
My.Computer.Screen.AllScreens.Length
I still think you may run into brick wall after brick wall trying to do something like this, especially in a high level managed language like VB. Not trying to deter you, but windows security is no simple beast, MS has teams of security experts that have been doing NT type security on Windows for a while now, and of course they still can't even get it 100%...
I don't think a few top level forms covering the desktop, and a timer looking for and killing task manager is going to really secure the system.
-
Dec 17th, 2008, 04:02 PM
#17
Thread Starter
Member
Re: Creating vb .net macros
Oh, by no means was this supposed to do anything like that. This is just a simple little program to stop any wandering idiot with switchblade or cain and able to get onto your systems, it will in no way stop an expert, nor is it an attempt to. I am not trying to fix windows security holes, I dont know near enough for that and would develop that software in c++ and assembly.
I know that I am not going to solve the problems of windows myself, I am simply working on my way to learning the inner workings and over the course of my career I would like to learn more about security not just on a windows level but a system and network level. Security has become my joy over the last 5 months, and has me studying/programming nearly 15 hours a day.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|