Const Kb_Pgm = "Osk.exe"
Private Sub UserForm_Initialize()
CreateObject("Shell.Application").shellexecute _
CreateObject("Scripting.FileSystemObject").GetSpecialFolder(1) & "\" & Kb_Pgm
Me.Repaint
' ......
' ......
End Sub
Private Sub UserForm_Terminate()
Set Svc = GetObject("winmgmts:root\cimv2")
For Each Oproc In Svc.execQuery( _
"select * from win32_process " & _
" where name like '" & Kb_Pgm & "'")
Oproc.Terminate
Next
Set Oproc = Nothing
Set Svc = Nothing
End Sub
Private Sub OpenVirtualKeyboard1()
keyboard = Shell("CMD /C " & """" & "C:\Windows\System32\osk.exe" & """")
End Sub
Option Explicit
Type SHELLEXECUTEINFO
cbSize As Long: fMask As Long: hwnd As Long: lpVerb As String: lpFile As String: lpParameters As String: lpDirectory As String: nShow As Long
hInstApp As Long: lpIDList As Long: lpClass As String: hkeyClass As Long: dwHotKey As Long: hIcon As Long: hProcess As Long
End Type
#If VBA7 Then
Public Declare PtrSafe Function ShellExecuteEx Lib "shell32.dll" (lpExecInfo As SHELLEXECUTEINFO) As LongPtr
Declare PtrSafe Function Wow64DisableWow64FsRedirection Lib "kernel32.dll" (ByRef ptr As LongPtr) As Boolean
Declare PtrSafe Function Wow64RevertWow64FsRedirection Lib "kernel32.dll" (ByRef ptr As LongPtr) As Boolean
#Else
Public Declare Function ShellExecuteEx Lib "shell32.dll" (lpExecInfo As SHELLEXECUTEINFO) As Long
Declare Function Wow64DisableWow64FsRedirection Lib "kernel32.dll" (ByRef ptr As Long) As Boolean
Declare Function Wow64RevertWow64FsRedirection Lib "kernel32.dll" (ByRef ptr As Long) As Boolean
#End If
Sub OpenVirtualKeyboardApi()
Dim shInfo As SHELLEXECUTEINFO, lngPtr As Long
With shInfo
.cbSize = Len(shInfo)
.lpFile = "C:\Windows\Sysnative\cmd.exe" 'best to use Known folders here
.lpParameters = "/c start osk.exe"
.lpDirectory = "C:\windows\system32" 'best to use Known folders here
.lpVerb = "open"
.nShow = 0
End With
Call Wow64DisableWow64FsRedirection(lngPtr)
Call ShellExecuteEx(shInfo)
Call Wow64RevertWow64FsRedirection(lngPtr)
End Sub
Salut Pat, Même avec runas ?re
@fanch55
ca ne fonctionne pas chez moi
il arrive parfois que vous ayez l'erreur "chemin introuvable"
Private Sub UserForm_Initialize()
CreateObject("Shell.Application").shellexecute _
CreateObject("Scripting.FileSystemObject").GetSpecialFolder(1) & "\" & Kb_Pgm, , "runas"
Me.Repaint
' ......
' ......
End Sub
Ah ben ça m'en bouche un coin ...
Private Sub UserForm_Initialize()
CreateObject("Shell.Application").shellexecute "Osk.exe"
End Sub
Merci Pat pour ce temps passé .Bonjour f@fanch55