Scusate per il titolo ma non sapevo come inquadrare bene il problema in una riga.
Vado a spiegare
Devo aspettare la chiusura di varie applicazioni, lo faccio così..
Contenuto del modulo
il codice per una applicazione il cui percorso è in txtProcess.Text è ad esempio questa:codice:Option Explicit Private Type STARTUPINFO cb As Long lpReserved As Long lpDesktop As Long lpTitle As Long dwX As Long dwY As Long dwXSize As Long dwYSize As Long dwXCountChars As Long dwYCountChars As Long dwFillAttribute As Long dwFlags As Long wShowWindow As Integer cbReserved2 As Integer lpReserved2 As Long hStdInput As Long hStdOutput As Long hStdError As Long End Type Private Type PROCESS_INFORMATION hProcess As Long hThread As Long dwProcessId As Long dwThreadId As Long End Type Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Public Const WAIT_TIMEOUT As Long = 258& Private Const WAIT_FAILED As Long = &HFFFFFFFF Private Const NORMAL_PRIORITY_CLASS = &H20& Private Const STARTF_USESHOWWINDOW As Long = &H1 Private Const STARTF_USESIZE As Long = &H2 Private Const STARTF_USEPOSITION As Long = &H4 Private Const STARTF_USECOUNTCHARS As Long = &H8 Private Const STARTF_USEFILLATTRIBUTE As Long = &H10 Private Const STARTF_RUNFULLSCREEN As Long = &H20 Private Const STARTF_FORCEONFEEDBACK As Long = &H40 Private Const STARTF_FORCEOFFFEEDBACK As Long = &H80 Private Const STARTF_USESTDHANDLES As Long = &H100 Private Const STARTF_USEHOTKEY As Long = &H200 Public Function ShellSospensiva(ByVal CommandLine As String, ByVal Directory As String, ByVal WindowStyle As VbAppWinStyle, ByVal WaitTime As Long) As Long Dim proc As PROCESS_INFORMATION Dim Start As STARTUPINFO With Start .dwFlags = STARTF_USESHOWWINDOW .wShowWindow = WindowStyle .cb = Len(Start) End With Call CreateProcess(0, CommandLine, 0, 0, 0, NORMAL_PRIORITY_CLASS, 0, Directory, Start, proc) If proc.hProcess <> 0 Then ShellSospensiva = WaitForSingleObject(proc.hProcess, WaitTime) Call CloseHandle(proc.hProcess) Else ShellSospensiva = WAIT_FAILED End If End Function
Il mio problema è: come faccio ad utilizzare sendkeys per inviare tasti a queste applicazioni?codice:Private Sub cmdAvvia_Click() Select Case ShellSospensiva(txtProcesso.Text, CurDir$, vbNormalFocus, CLng(txtAttesa.Text)) Case 0: MsgBox "Esecuzione completata con esito positivo", vbInformation Case WAIT_TIMEOUT: MsgBox "Supero del tempo massimo di attesa", vbExclamation Case Else: MsgBox "Si è verificato un errore", vbCritical End Select
Grazie

Rispondi quotando