Salut à tous
Je teste la présence d'une application en lancant un FINDWINDOW("appli",
argument)
Si elle existe ensuite, je voudrais la passer en premier plan, car elle est
dans la barre des tâches !
comment faire s'il vous plait ? Je pensais que GetWindowActive irait , mais
non !!!! :-(
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Jacques93
Bonjour News, News a écrit :
Salut à tous Je teste la présence d'une application en lancant un FINDWINDOW("appli", argument) Si elle existe ensuite, je voudrais la passer en premier plan, car elle est dans la barre des tâches ! comment faire s'il vous plait ? Je pensais que GetWindowActive irait , mais non !!!! :-(
Tu peux essayer ceci :
Après avoir récupéré la handle de la fenêtre, tu appelles :
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As Long, ByVal idAttachTo As Long, _ ByVal fAttach As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function GetForegroundWindow Lib "user32" _ () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _ Optional bRestoreIconic As Boolean = False) Dim ThreadID1 As Long, ThreadID2 As Long Dim X As Long
' Nouveau comportement de SetForeGroundWindow ' La fenêtre à activer doit appartenir au Thread appelant If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then X = AttachThreadInput(ThreadID1, ThreadID2, True) X = SetForegroundWindow(newHwnd) X = AttachThreadInput(ThreadID1, ThreadID2, True) Else X = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) And bRestoreIconic = True Then X = ShowWindow(newHwnd, SW_RESTORE) Else X = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub '-------------------------------------------------------------
-- Cordialement,
Jacques.
Bonjour News,
News a écrit :
Salut à tous
Je teste la présence d'une application en lancant un FINDWINDOW("appli",
argument)
Si elle existe ensuite, je voudrais la passer en premier plan, car elle est
dans la barre des tâches !
comment faire s'il vous plait ? Je pensais que GetWindowActive irait , mais
non !!!! :-(
Tu peux essayer ceci :
Après avoir récupéré la handle de la fenêtre, tu appelles :
Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function AttachThreadInput Lib "user32" _
(ByVal idAttach As Long, ByVal idAttachTo As Long, _
ByVal fAttach As Long) As Long
Private Declare Function IsIconic Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" _
() As Long
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _
Optional bRestoreIconic As Boolean = False)
Dim ThreadID1 As Long, ThreadID2 As Long
Dim X As Long
' Nouveau comportement de SetForeGroundWindow
' La fenêtre à activer doit appartenir au Thread appelant
If newHwnd = GetForegroundWindow() Then
Exit Sub
Else
ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0)
ThreadID2 = GetWindowThreadProcessId(newHwnd, 0)
If ThreadID1 <> ThreadID2 Then
X = AttachThreadInput(ThreadID1, ThreadID2, True)
X = SetForegroundWindow(newHwnd)
X = AttachThreadInput(ThreadID1, ThreadID2, True)
Else
X = SetForegroundWindow(newHwnd)
End If
If IsIconic(newHwnd) And bRestoreIconic = True Then
X = ShowWindow(newHwnd, SW_RESTORE)
Else
X = ShowWindow(newHwnd, SW_SHOW)
End If
End If
End Sub
'-------------------------------------------------------------
Salut à tous Je teste la présence d'une application en lancant un FINDWINDOW("appli", argument) Si elle existe ensuite, je voudrais la passer en premier plan, car elle est dans la barre des tâches ! comment faire s'il vous plait ? Je pensais que GetWindowActive irait , mais non !!!! :-(
Tu peux essayer ceci :
Après avoir récupéré la handle de la fenêtre, tu appelles :
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As Long, ByVal idAttachTo As Long, _ ByVal fAttach As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function GetForegroundWindow Lib "user32" _ () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _ Optional bRestoreIconic As Boolean = False) Dim ThreadID1 As Long, ThreadID2 As Long Dim X As Long
' Nouveau comportement de SetForeGroundWindow ' La fenêtre à activer doit appartenir au Thread appelant If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then X = AttachThreadInput(ThreadID1, ThreadID2, True) X = SetForegroundWindow(newHwnd) X = AttachThreadInput(ThreadID1, ThreadID2, True) Else X = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) And bRestoreIconic = True Then X = ShowWindow(newHwnd, SW_RESTORE) Else X = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub '-------------------------------------------------------------
-- Cordialement,
Jacques.
News
MERCI BEAUCOUP Ca fonctionne très bien !
:-)
"Jacques93" a écrit dans le message de news:
Bonjour News, News a écrit :
Salut à tous Je teste la présence d'une application en lancant un FINDWINDOW("appli", argument) Si elle existe ensuite, je voudrais la passer en premier plan, car elle est dans la barre des tâches ! comment faire s'il vous plait ? Je pensais que GetWindowActive irait , mais non !!!! :-(
Tu peux essayer ceci :
Après avoir récupéré la handle de la fenêtre, tu appelles :
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As Long, ByVal idAttachTo As Long, _ ByVal fAttach As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function GetForegroundWindow Lib "user32" _ () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _ Optional bRestoreIconic As Boolean = False) Dim ThreadID1 As Long, ThreadID2 As Long Dim X As Long
' Nouveau comportement de SetForeGroundWindow ' La fenêtre à activer doit appartenir au Thread appelant If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then X = AttachThreadInput(ThreadID1, ThreadID2, True) X = SetForegroundWindow(newHwnd) X = AttachThreadInput(ThreadID1, ThreadID2, True) Else X = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) And bRestoreIconic = True Then X = ShowWindow(newHwnd, SW_RESTORE) Else X = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub '-------------------------------------------------------------
-- Cordialement,
Jacques.
MERCI BEAUCOUP
Ca fonctionne très bien !
:-)
"Jacques93" <jacques@Nospam> a écrit dans le message de news:
usQre87OGHA.3196@TK2MSFTNGP09.phx.gbl...
Bonjour News,
News a écrit :
Salut à tous
Je teste la présence d'une application en lancant un FINDWINDOW("appli",
argument)
Si elle existe ensuite, je voudrais la passer en premier plan, car elle
est dans la barre des tâches !
comment faire s'il vous plait ? Je pensais que GetWindowActive irait ,
mais non !!!! :-(
Tu peux essayer ceci :
Après avoir récupéré la handle de la fenêtre, tu appelles :
Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function AttachThreadInput Lib "user32" _
(ByVal idAttach As Long, ByVal idAttachTo As Long, _
ByVal fAttach As Long) As Long
Private Declare Function IsIconic Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" _
() As Long
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" _
(ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _
Optional bRestoreIconic As Boolean = False)
Dim ThreadID1 As Long, ThreadID2 As Long
Dim X As Long
' Nouveau comportement de SetForeGroundWindow
' La fenêtre à activer doit appartenir au Thread appelant
If newHwnd = GetForegroundWindow() Then
Exit Sub
Else
ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0)
ThreadID2 = GetWindowThreadProcessId(newHwnd, 0)
If ThreadID1 <> ThreadID2 Then
X = AttachThreadInput(ThreadID1, ThreadID2, True)
X = SetForegroundWindow(newHwnd)
X = AttachThreadInput(ThreadID1, ThreadID2, True)
Else
X = SetForegroundWindow(newHwnd)
End If
If IsIconic(newHwnd) And bRestoreIconic = True Then
X = ShowWindow(newHwnd, SW_RESTORE)
Else
X = ShowWindow(newHwnd, SW_SHOW)
End If
End If
End Sub
'-------------------------------------------------------------
Salut à tous Je teste la présence d'une application en lancant un FINDWINDOW("appli", argument) Si elle existe ensuite, je voudrais la passer en premier plan, car elle est dans la barre des tâches ! comment faire s'il vous plait ? Je pensais que GetWindowActive irait , mais non !!!! :-(
Tu peux essayer ceci :
Après avoir récupéré la handle de la fenêtre, tu appelles :
Private Declare Function GetWindowThreadProcessId Lib "user32" _ (ByVal hWnd As Long, lpdwProcessId As Long) As Long Private Declare Function AttachThreadInput Lib "user32" _ (ByVal idAttach As Long, ByVal idAttachTo As Long, _ ByVal fAttach As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function GetForegroundWindow Lib "user32" _ () As Long Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindow Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub ForceForeGroundWindow(ByVal newHwnd As Long, _ Optional bRestoreIconic As Boolean = False) Dim ThreadID1 As Long, ThreadID2 As Long Dim X As Long
' Nouveau comportement de SetForeGroundWindow ' La fenêtre à activer doit appartenir au Thread appelant If newHwnd = GetForegroundWindow() Then Exit Sub Else ThreadID1 = GetWindowThreadProcessId(GetForegroundWindow(), 0) ThreadID2 = GetWindowThreadProcessId(newHwnd, 0) If ThreadID1 <> ThreadID2 Then X = AttachThreadInput(ThreadID1, ThreadID2, True) X = SetForegroundWindow(newHwnd) X = AttachThreadInput(ThreadID1, ThreadID2, True) Else X = SetForegroundWindow(newHwnd) End If If IsIconic(newHwnd) And bRestoreIconic = True Then X = ShowWindow(newHwnd, SW_RESTORE) Else X = ShowWindow(newHwnd, SW_SHOW) End If End If End Sub '-------------------------------------------------------------