Private Sub cmd_Android_Camera_Click()
On Error GoTo err_cmd_Android_Camera_Click
'KEYCODE_POWER = 26
'KEYCODE_CAMERA = 27
'KEYCODE_BACK = 4
'KEYCODE_HOME = 3
Dim cmmd As String
'how long does it take to take the picture
istart = Timer
'set BE_Path
Call BE_or_FE
'Adb location
App_Location = BE_Path & "Camera_App\Android_Mobile\Adb.exe"
Save_images_to = BE_Path & "images\"
'image capture mode
cmmd1 = App_Location & " shell " & Chr(34) & "am start -a android.media.action.STILL_IMAGE_CAMERA" & "; sleep 1; "
cmmd2 = "input keyevent KEYCODE_ENTER" & "; sleep 2; "
cmmd3 = "input keyevent KEYCODE_BACK" & ";" & Chr(34)
cmmd = cmmd1 & cmmd2 & cmmd3
'Debug.Print cmmd
Call ShellWait(cmmd, vbHidden)
'transfer the image to the PC
cmmd = App_Location & " pull /sdcard/DCIM/100ANDRO/ " & Save_images_to & "temp\"
Call Shell(cmmd, vbHidden)
'Delete the pictures from the mobile camera folder
cmmd = App_Location & " shell rm /sdcard/DCIM/100ANDRO/*.jpg"
Call Shell(cmmd, vbHidden)
PauseTime = 1
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
'Delete the existing Employee_ID
Kill Save_images_to & Me.Employee_ID & ".jpg"
'move the picture from folder temp and change its name
Dim StrFile As String
StrFile = Dir(Save_images_to & "temp\")
Do While Len(StrFile) > 0
Mobile_Pic = StrFile
StrFile = Dir
Loop
Name Save_images_to & "temp\" & Mobile_Pic As Save_images_to & Me.Employee_ID & ".jpg"
PauseTime = 1
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
'show the picture in the Form
Me.Pic.Picture = Save_images_to & Me.Employee_ID & ".jpg"
'Delete the temp folder
RmDir Save_images_to & "temp\"
'MsgBox Timer - istart
End Sub
هذا هو الكود بعد التعديل