vba excel 使用 adb 的宏
vba excel macro to use adb
我正在尝试创建一个允许我截取屏幕截图、视频并通过 adb 检索它们的宏。
使用 shell + line 我几乎可以做任何事情,但我无法停止录制。
停止录音的命令是ctrl+c,但是通过sendkeys发送是行不通的。
Private Sub CommandButton2_Click()
If ComboBox1.Value = "data, ora e titolo" Then
nomevideo = Format(Now, "dd-mm-yy_hh-mm-ss_") & "_" & TextBox2.Value & ".mp4"
ElseIf ComboBox1.Value = "data e titolo" Then
nomevideo = Format(Now, "dd-mm-yy_") & TextBox2.Value & ".mp4"
Else
nomevideo = Format(Now, "dd-mm-yy_hh-mm-ss") & ".mp4"
End If
video = "adb shell screenrecord /sdcard/" & nomevideo
Debug.Print video & "registra video"
Shell video
CommandButton13.Visible = True
End Sub
Private Sub CommandButton5_Click()
SendKeys "^c"
Debug.Print "stop video"
End Sub
您需要在发送 control-c 之前使用 AppActivate 激活 adb window。有关详细信息,请参阅 https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/appactivate-statement。
好的,使用shell时保持window打开:
这有效
Dim programma As Long, newhour, newminute, newsecond, waittime As Variant
programma = Shell("C:\Windows\system32\cmd.exe", vbNormalFocus)
AppActivate programma
newhour = Hour(Now())
newminute = Minute(Now())
newsecond = Second(Now()) + 1
waittime = TimeSerial(newhour, newminute, newsecond)
Application.Wait waittime
Application.SendKeys ("adb shell screenrecord /sdcard/gigio.mp4~"), True
AppActivate programma
newhour = Hour(Now())
newminute = Minute(Now())
newsecond = Second(Now()) + 1
waittime = TimeSerial(newhour, newminute, newsecond)
Application.Wait waittime
Application.SendKeys ("^c"), True
我正在尝试创建一个允许我截取屏幕截图、视频并通过 adb 检索它们的宏。 使用 shell + line 我几乎可以做任何事情,但我无法停止录制。 停止录音的命令是ctrl+c,但是通过sendkeys发送是行不通的。
Private Sub CommandButton2_Click()
If ComboBox1.Value = "data, ora e titolo" Then
nomevideo = Format(Now, "dd-mm-yy_hh-mm-ss_") & "_" & TextBox2.Value & ".mp4"
ElseIf ComboBox1.Value = "data e titolo" Then
nomevideo = Format(Now, "dd-mm-yy_") & TextBox2.Value & ".mp4"
Else
nomevideo = Format(Now, "dd-mm-yy_hh-mm-ss") & ".mp4"
End If
video = "adb shell screenrecord /sdcard/" & nomevideo
Debug.Print video & "registra video"
Shell video
CommandButton13.Visible = True
End Sub
Private Sub CommandButton5_Click()
SendKeys "^c"
Debug.Print "stop video"
End Sub
您需要在发送 control-c 之前使用 AppActivate 激活 adb window。有关详细信息,请参阅 https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/appactivate-statement。
好的,使用shell时保持window打开:
这有效
Dim programma As Long, newhour, newminute, newsecond, waittime As Variant
programma = Shell("C:\Windows\system32\cmd.exe", vbNormalFocus)
AppActivate programma
newhour = Hour(Now())
newminute = Minute(Now())
newsecond = Second(Now()) + 1
waittime = TimeSerial(newhour, newminute, newsecond)
Application.Wait waittime
Application.SendKeys ("adb shell screenrecord /sdcard/gigio.mp4~"), True
AppActivate programma
newhour = Hour(Now())
newminute = Minute(Now())
newsecond = Second(Now()) + 1
waittime = TimeSerial(newhour, newminute, newsecond)
Application.Wait waittime
Application.SendKeys ("^c"), True