Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

IsKeyDown help

Gears Phenom Gears Phenom
Gears Phenom

I have a Console App (VB.Net) that runs as it is supposed to with error handling and a few user inputs along the way.

 

The App is very basic - could be "Hello World" for testing purposes.

 

I'd like to have a hotkey to run this app with that would automatically jump to either a GOTO statement or Sub if the key is being pressed while the .exe is being launched.

 

Is this possible?  I am having difficulties doing so.    

 

 


Matt Johnson
Solid Edge Certified Professional (ST7 & ST8)
Solid Edge ST9 (SEEC) - Production
SE2019 Pre-Production Testing
NX11 (Tc Integration) Pre-Production Testing
Teamcenter 10.1.7
3 REPLIES 3

Re: IsKeyDown help

Genius
Genius

Hi @Johnson_BigMatt,

 

Maybe this info will sort your problem.

 

1. Right click on the application, what you want to assign a keyboard shortcut key.

1.jpg

 

2. click on create Shortcut, move that shortcut to anywhere.

2.jpg

 

 

3. Now right click on the shortcut, go to properties, select the shortcut zone and then press any key to assign.

3.jpg

 

This will work with Ctrl+Alt+key or Ctrl+Shift+key.

 

Thanks & Regards

V.Sudheer

Re: IsKeyDown help

Gears Honored Contributor Gears Honored Contributor
Gears Honored Contributor

Hi Matt,

 

Events in a console app?

I think you could add a Form and hide it while it 'hopefully' still listens to events.

 

Here are a few discussions I found online:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/b8342571-c1b3-403e-b762-cf4ba16e336e/console-...

 

https://bytes.com/topic/visual-basic-net/answers/377359-events-console-programs

 

and here's one on code-project:

https://www.codeproject.com/Articles/2357/Console-Event-Handling

 

and a simpler technique from DotNet Pearls:

https://www.dotnetperls.com/event-vbnet

Re: IsKeyDown help

Gears Phenom Gears Phenom
Gears Phenom

THx all,   I found my issue!!!

 

I did not have a stopping point (Console.ReadKey(True)) in my test...  so it was appearing as it did not work, where indeed it had.

 

here was my test this morning...  and when i went back to check my real code i noted i did not have the wait points (Console.ReadKey(True))

Module Module1

    Sub Main()
        ''Check for Key Press,  If So GoTo _AutoRun
        If My.Computer.Keyboard.CtrlKeyDown = True Then  'IsKeyDown(Key.Ctrl) Then
            AutoRun()
        End If
        'this would be the main body of code, prior to wanting to add the bypass
        Console.Title = "ISKeyDownTest - FALSE"
        Console.BackgroundColor = ConsoleColor.White
        Console.ForegroundColor = ConsoleColor.Black
        Console.Clear()
        Console.Beep(1500, 250)
        Console.WriteLine("Ctrl Key is NOT Down")
        Console.ReadKey(True)
    End Sub
    Sub AutoRun()
        'this would be calls only with no error handling.
        Console.Title = "ISKeyDownTest - TRUE"
        Console.BackgroundColor = ConsoleColor.Red
        Console.ForegroundColor = ConsoleColor.White
        Console.Clear()
        Console.Beep(1500, 250)
        Console.WriteLine("Ctrl KEY is DOWN!!!")
        Console.ReadKey(True)
    End Sub
End Module

 


Matt Johnson
Solid Edge Certified Professional (ST7 & ST8)
Solid Edge ST9 (SEEC) - Production
SE2019 Pre-Production Testing
NX11 (Tc Integration) Pre-Production Testing
Teamcenter 10.1.7