Meilleur auteur de réponses
Démarrer le navigateur en mode caché ou minimisé

Question
-
Salut ! Chrome, il est bien gentil mais quand on le ferme, il ne reste pas près de l'horloge alors qu'il est sensé, par la case cochée, de travailler en arrière plan. Avant mon formatage, ça marchait bien et le démarrage hyper rapide.
Vous imaginez que si je'en parle c'est parce que ça ne marche plus et que sur le forum de Google, je n'ai pas de réponses positives.
D'où l'idée de faire un exe qui r'ouvrira dans mon dos, le-dit navigateur. Problème, le navigateur s'ouvre en plein écran. Pourtant le mode choisi est hide ou minimised.
Dim MyProcess As New Process
MyProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
MyProcess.StartInfo.FileName = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
MyProcess.Start()
Question, y-a-t-il un moyen d'ouvrir Chrome en mode caché ou minimisé ? Merci.
- Modifié Michel56100 lundi 9 mai 2016 01:18 faute
Réponses
-
Voici le code que j'ai utilisé, cela fonctionne bien pour trouver Chrome et minimiser la fenêtre:
Public Class Form1 Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As SHOW_WINDOW) As Boolean Private Enum SHOW_WINDOW As Integer SW_HIDE = 0 SW_SHOWNORMAL = 1 SW_NORMAL = 1 SW_SHOWMINIMIZED = 2 SW_SHOWMAXIMIZED = 3 SW_MAXIMIZE = 3 SW_SHOWNOACTIVATE = 4 SW_SHOW = 5 SW_MINIMIZE = 6 SW_SHOWMINNOACTIVE = 7 SW_SHOWNA = 8 SW_RESTORE = 9 SW_SHOWDEFAULT = 10 SW_FORCEMINIMIZE = 11 SW_MAX = 11 End Enum Dim strOuEstChrome As String = "C:\Users\Cyrille\AppData\Local\Google\Chrome\Application\chrome.exe" Dim strOuEstFirefox As String = "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim startInfo As New ProcessStartInfo(strOuEstChrome) startInfo.WindowStyle = ProcessWindowStyle.Minimized Process.Start(startInfo) Catch ex As Exception 'Debug.Print("Exception : " & ex.Message) RichTextBox1.AppendText("Strart Chrome Exception levée: " & ex.Message) End Try End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Try Dim startInfo As New ProcessStartInfo(strOuEstFirefox) startInfo.WindowStyle = ProcessWindowStyle.Minimized Process.Start(startInfo) Catch ex As Exception 'Debug.Print("Exception : " & ex.Message) RichTextBox1.AppendText("Start Firefox Exception levée: " & ex.Message) End Try End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click ' Loop sur tous les process For Each p As Process In Process.GetProcesses ' Si le nom de la MainWindow du process n'est pas vide If p.MainWindowTitle = String.Empty = False Then 'Affichage du processName et du titre de la Window dans la RTB de l'UI...pratique pour debug RichTextBox1.AppendText(p.ProcessName & " # " & p.MainWindowTitle & " # " & p.Id & Environment.NewLine) End If Next
' Minimiser la fenêtre chrome MinimizeWindow("chrome") End Sub
'Minimiser la Fenêtre par son nom Private Sub MinimizeWindow(ByVal strAppToMinimize As String)
' Loop sur les process du nom de l'app For Each p As Process In Process.GetProcessesByName(strAppToMinimize) ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE) Next p End Sub End Class
- Modifié Cyrille Précetti lundi 9 mai 2016 15:45 Correction commentaire du code en français
- Marqué comme réponse Michel56100 mardi 10 mai 2016 15:58
-
Vous pouvez scanner les process pour minimiser le plus tôt possible sans Timer:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim startInfo As New ProcessStartInfo(strOuEstChrome) startInfo.WindowStyle = ProcessWindowStyle.Minimized Process.Start(startInfo) Catch ex As Exception 'Debug.Print("Exception : " & ex.Message) RichTextBox1.AppendText("Strart Chrome Exception levée: " & ex.Message) End Try MinimizeAuLancement("chrome") End Sub Private Sub MinimizeWindow(ByVal strAppToMinimize As String) For Each p As Process In Process.GetProcessesByName(strAppToMinimize) ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE) Next p End Sub Private Sub MinimizeAuLancement(ByVal strAppToMinimize As String) Dim booChromeActif As Boolean = False While booChromeActif = False For Each p As Process In Process.GetProcesses 'If the MainWindowTitle of the process is not empty If p.MainWindowTitle = String.Empty = False Then 'Add the process name, the main window title, and the process ID (what windows uses to identify the process) to the listbox) RichTextBox1.AppendText(p.ProcessName & " # " & p.MainWindowTitle & " # " & p.Id & Environment.NewLine) If p.ProcessName = "chrome" Then booChromeActif = True End If End If Next End While MinimizeWindow("chrome") End Sub
- Marqué comme réponse Michel56100 mardi 10 mai 2016 15:57
Toutes les réponses
-
Essayez:
Try Dim startInfo As New ProcessStartInfo("VotreCheminVers\Chrome") startInfo.WindowStyle = ProcessWindowStyle.Minimized Process.Start(startInfo) Catch ex As Exception Debug.print("Exception : " & ex.Message) End Try
Vous pouvez regarder ce lien: http://stackoverflow.com/questions/36667714/start-chrome-minimized- Modifié Cyrille Précetti lundi 9 mai 2016 10:48
-
-
-
-
Bon, j'ai réussi à démarrer Chrome minimizé...
mais ce n'est probablement pas le droïd que vous recherchez... :)
1- votre emplacement de Chrome n'est pas correct, ici il est dans "C:\Users\Cyrille\AppData\Local\Google\Chrome\Application\chrome.exe"
2-Chrome démarre dans l'état où vous l'avez laissé: donc minimisez Chrome, puis Click-Droit\Fermer. Il se rouvrira en minimisé...
Donc une suggestion: lancez Chrome, trouvez sa fenêtre, minimisez cette fenêtre... c'est une autre question...
Et c'est pareil avec Firefox....- Modifié Cyrille Précetti lundi 9 mai 2016 13:18
-
Voici le code que j'ai utilisé, cela fonctionne bien pour trouver Chrome et minimiser la fenêtre:
Public Class Form1 Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal nCmdShow As SHOW_WINDOW) As Boolean Private Enum SHOW_WINDOW As Integer SW_HIDE = 0 SW_SHOWNORMAL = 1 SW_NORMAL = 1 SW_SHOWMINIMIZED = 2 SW_SHOWMAXIMIZED = 3 SW_MAXIMIZE = 3 SW_SHOWNOACTIVATE = 4 SW_SHOW = 5 SW_MINIMIZE = 6 SW_SHOWMINNOACTIVE = 7 SW_SHOWNA = 8 SW_RESTORE = 9 SW_SHOWDEFAULT = 10 SW_FORCEMINIMIZE = 11 SW_MAX = 11 End Enum Dim strOuEstChrome As String = "C:\Users\Cyrille\AppData\Local\Google\Chrome\Application\chrome.exe" Dim strOuEstFirefox As String = "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim startInfo As New ProcessStartInfo(strOuEstChrome) startInfo.WindowStyle = ProcessWindowStyle.Minimized Process.Start(startInfo) Catch ex As Exception 'Debug.Print("Exception : " & ex.Message) RichTextBox1.AppendText("Strart Chrome Exception levée: " & ex.Message) End Try End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Try Dim startInfo As New ProcessStartInfo(strOuEstFirefox) startInfo.WindowStyle = ProcessWindowStyle.Minimized Process.Start(startInfo) Catch ex As Exception 'Debug.Print("Exception : " & ex.Message) RichTextBox1.AppendText("Start Firefox Exception levée: " & ex.Message) End Try End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click ' Loop sur tous les process For Each p As Process In Process.GetProcesses ' Si le nom de la MainWindow du process n'est pas vide If p.MainWindowTitle = String.Empty = False Then 'Affichage du processName et du titre de la Window dans la RTB de l'UI...pratique pour debug RichTextBox1.AppendText(p.ProcessName & " # " & p.MainWindowTitle & " # " & p.Id & Environment.NewLine) End If Next
' Minimiser la fenêtre chrome MinimizeWindow("chrome") End Sub
'Minimiser la Fenêtre par son nom Private Sub MinimizeWindow(ByVal strAppToMinimize As String)
' Loop sur les process du nom de l'app For Each p As Process In Process.GetProcessesByName(strAppToMinimize) ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE) Next p End Sub End Class
- Modifié Cyrille Précetti lundi 9 mai 2016 15:45 Correction commentaire du code en français
- Marqué comme réponse Michel56100 mardi 10 mai 2016 15:58
-
Salut !
Merci pour ce code.
Mon emplacement de Chorme est correct. Il s'agit de la version 64 bits. Mais bizarrement, elle se situe à Program Files (x86) ce qui n'est pas logique mais c'est la seconde fois que je l'installe et Chrome ne laisse pas le choix de l'installation. Avant, j'avais la version 32 bits.
Par ailleurs, il faut cliquer sur le bouton 3 pour minimiser la fenêtre. Ca fait pas propre. :(
J'aurais aimé un code qui minimise au début. Sinon, ça ne fonctionnera pas correctement.
-
-
-
Vous pouvez scanner les process pour minimiser le plus tôt possible sans Timer:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim startInfo As New ProcessStartInfo(strOuEstChrome) startInfo.WindowStyle = ProcessWindowStyle.Minimized Process.Start(startInfo) Catch ex As Exception 'Debug.Print("Exception : " & ex.Message) RichTextBox1.AppendText("Strart Chrome Exception levée: " & ex.Message) End Try MinimizeAuLancement("chrome") End Sub Private Sub MinimizeWindow(ByVal strAppToMinimize As String) For Each p As Process In Process.GetProcessesByName(strAppToMinimize) ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MINIMIZE) Next p End Sub Private Sub MinimizeAuLancement(ByVal strAppToMinimize As String) Dim booChromeActif As Boolean = False While booChromeActif = False For Each p As Process In Process.GetProcesses 'If the MainWindowTitle of the process is not empty If p.MainWindowTitle = String.Empty = False Then 'Add the process name, the main window title, and the process ID (what windows uses to identify the process) to the listbox) RichTextBox1.AppendText(p.ProcessName & " # " & p.MainWindowTitle & " # " & p.Id & Environment.NewLine) If p.ProcessName = "chrome" Then booChromeActif = True End If End If Next End While MinimizeWindow("chrome") End Sub
- Marqué comme réponse Michel56100 mardi 10 mai 2016 15:57
-