le sendkeys de vb fera effet sur la fenetre en premier plan sur ton
windows (fenetre active)
d'ou le
appactivate "titre de la fenetre de l'appli ou envoyer le sendkeys"
dans le code suivant je met l'appli "XXXX' en fenetre active.
j'ouvre le menu par alt-a puis une fenetre par alt-v
j'y colle une r?f?rence (precedemment recuper?e) dans une zone de texte
par un control-c
si cette r?f?rence r?f?rence n'existe pas, l'appli ouvre une fenetre
pop up qui a pour titre "Attention"
ce pop up m'empeche de continuer mon traitement et je dois la fermer.
ceci est fait par la fonction EnumWindows qui verifie systematiquement
si il y a une fenetre "attention" activ?e. Si oui je la ferme.
j'espere que tu pourras t'en inspirer :
-voir les API du module
-ne pas oublier les sleep pour laisser le temps ? l'appli de r?agir..
AppActivate "XXXX"
Sleep 200
SendKeys "^A", True
Sleep 200
SendKeys "^V", True
Sleep 200
SendKeys "%C", True
Sleep 3000
'ferme Attention si elle existe
flgNODL = False
RetVal = EnumWindows(AddressOf MyEnumWinCallback, 0)
If flgNODL Then
.....
else
....
End If
DoEvents
un module
Option Explicit
Public flgNODL As Boolean
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any _
) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowText Lib "user32" Alias
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal
cch As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As
Long, ByVal lParam As Long) As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As
Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias
"GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Const WM_CLOSE As Long = &H10
Public Function MyEnumWinCallback(ByVal hWndX As Long, lParam As Long)
As Long
Dim CurTitleText As String
Dim RetVal As Long
Dim sTitle As String
Dim hwnd As Long
CurTitleText = Space$(80)
RetVal = GetWindowText(hWndX, CurTitleText, 80)
If InStr(CurTitleText, "Attention") <> 0 Then
sTitle = "Attention"
hwnd = FindWindow(vbNullString, sTitle)
Call SendMessage(hwnd, WM_CLOSE, 0, ByVal 0&)
flgNODL = True
End If
MyEnumWinCallback = True
CurTitleText = vbNullString
sTitle = vbNullString
End Function
Bon courrage
le sendkeys de vb fera effet sur la fenetre en premier plan sur ton
windows (fenetre active)
d'ou le
appactivate "titre de la fenetre de l'appli ou envoyer le sendkeys"
dans le code suivant je met l'appli "XXXX' en fenetre active.
j'ouvre le menu par alt-a puis une fenetre par alt-v
j'y colle une r?f?rence (precedemment recuper?e) dans une zone de texte
par un control-c
si cette r?f?rence r?f?rence n'existe pas, l'appli ouvre une fenetre
pop up qui a pour titre "Attention"
ce pop up m'empeche de continuer mon traitement et je dois la fermer.
ceci est fait par la fonction EnumWindows qui verifie systematiquement
si il y a une fenetre "attention" activ?e. Si oui je la ferme.
j'espere que tu pourras t'en inspirer :
-voir les API du module
-ne pas oublier les sleep pour laisser le temps ? l'appli de r?agir..
AppActivate "XXXX"
Sleep 200
SendKeys "^A", True
Sleep 200
SendKeys "^V", True
Sleep 200
SendKeys "%C", True
Sleep 3000
'ferme Attention si elle existe
flgNODL = False
RetVal = EnumWindows(AddressOf MyEnumWinCallback, 0)
If flgNODL Then
.....
else
....
End If
DoEvents
un module
Option Explicit
Public flgNODL As Boolean
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any _
) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowText Lib "user32" Alias
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal
cch As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As
Long, ByVal lParam As Long) As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As
Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias
"GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Const WM_CLOSE As Long = &H10
Public Function MyEnumWinCallback(ByVal hWndX As Long, lParam As Long)
As Long
Dim CurTitleText As String
Dim RetVal As Long
Dim sTitle As String
Dim hwnd As Long
CurTitleText = Space$(80)
RetVal = GetWindowText(hWndX, CurTitleText, 80)
If InStr(CurTitleText, "Attention") <> 0 Then
sTitle = "Attention"
hwnd = FindWindow(vbNullString, sTitle)
Call SendMessage(hwnd, WM_CLOSE, 0, ByVal 0&)
flgNODL = True
End If
MyEnumWinCallback = True
CurTitleText = vbNullString
sTitle = vbNullString
End Function
Bon courrage
le sendkeys de vb fera effet sur la fenetre en premier plan sur ton
windows (fenetre active)
d'ou le
appactivate "titre de la fenetre de l'appli ou envoyer le sendkeys"
dans le code suivant je met l'appli "XXXX' en fenetre active.
j'ouvre le menu par alt-a puis une fenetre par alt-v
j'y colle une r?f?rence (precedemment recuper?e) dans une zone de texte
par un control-c
si cette r?f?rence r?f?rence n'existe pas, l'appli ouvre une fenetre
pop up qui a pour titre "Attention"
ce pop up m'empeche de continuer mon traitement et je dois la fermer.
ceci est fait par la fonction EnumWindows qui verifie systematiquement
si il y a une fenetre "attention" activ?e. Si oui je la ferme.
j'espere que tu pourras t'en inspirer :
-voir les API du module
-ne pas oublier les sleep pour laisser le temps ? l'appli de r?agir..
AppActivate "XXXX"
Sleep 200
SendKeys "^A", True
Sleep 200
SendKeys "^V", True
Sleep 200
SendKeys "%C", True
Sleep 3000
'ferme Attention si elle existe
flgNODL = False
RetVal = EnumWindows(AddressOf MyEnumWinCallback, 0)
If flgNODL Then
.....
else
....
End If
DoEvents
un module
Option Explicit
Public flgNODL As Boolean
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any _
) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowText Lib "user32" Alias
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal
cch As Long) As Long
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As
Long, ByVal lParam As Long) As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As
Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias
"GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Const WM_CLOSE As Long = &H10
Public Function MyEnumWinCallback(ByVal hWndX As Long, lParam As Long)
As Long
Dim CurTitleText As String
Dim RetVal As Long
Dim sTitle As String
Dim hwnd As Long
CurTitleText = Space$(80)
RetVal = GetWindowText(hWndX, CurTitleText, 80)
If InStr(CurTitleText, "Attention") <> 0 Then
sTitle = "Attention"
hwnd = FindWindow(vbNullString, sTitle)
Call SendMessage(hwnd, WM_CLOSE, 0, ByVal 0&)
flgNODL = True
End If
MyEnumWinCallback = True
CurTitleText = vbNullString
sTitle = vbNullString
End Function
Bon courrage