Click here to Skip to main content
13,895,757 members
Rate this:
 
Please Sign up or sign in to vote.
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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!
   
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Why re-invent what is already available? You can close any application in Windows with Alt+F4.
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190306.1 | Last Updated 17 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100