Click here to Skip to main content
15,887,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, I want to create chrome launch with full screen mode, and i want to close the chrome with keyboard like ALT+F but when i press ALT+F chrome still open. How I can implement my idea?
this is my code

What I have tried:

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Brun.Click
        Dim okcancel As String
        okcancel = MessageBox.Show("Xambrowser ini di buat oleh Syarif SMKIU, tekan OK untuk melanjutkan", "Informasi", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
        If okcancel = DialogResult.OK Then
            Dim ProcessProperties As New ProcessStartInfo("chrome.exe")
            ProcessProperties.Arguments = Turl.Text & " " & Targ.Text
            Dim myProcess As Process = Process.Start(ProcessProperties)

            Brun.Text = "Stop"
            Brun.ForeColor = Color.Green
            Me.KeyPreview = True
            Timer1.Start()
        End If
    End Sub
    Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
        If e.Alt And e.KeyCode.ToString = "F" Then
            MessageBox.Show("terimakasih")
            Brun.Text = "RUN"
            Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("chrome")
            For Each p As Process In pProcess
                p.Kill()
            Next
        End If
    End Sub
End Class
Posted
Updated 16-Feb-19 22:10pm

We can't tell without your exact system and your code running. It may be as simple as you haven't set the Form KeyPreview property to "True", we can't tell.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger.
Put a breakpoint on the line
MessageBox.Show("terimakasih")
Then run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 
Why re-invent what is already available? You can close any application in Windows with Alt+F4.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900