B4J Question Turn Screen On/Off (not pause or sleep or energy saver) only screen

inakigarm

Well-Known Member
Licensed User
Copied nricmd to File.DirApp (B4J app folder/Objects)

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    'MainForm.Show
    
    jshell.Initialize("shellevent","nircmd",Array As String("monitor","off"))
    jshell.WorkingDirectory=File.DirApp
    jshell.RunWithOutputEvents(1000)

End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Private Sub shellevent_StdErr (Buffer() As Byte, Length As Int)
    Dim Output As String = BytesToString(Buffer,0,Length,"UTF-8")
    Log(Output)
End Sub

Private Sub shellevent_StdOut (Buffer() As Byte, Length As Int)
    Dim Output As String = BytesToString(Buffer,0,Length,"UTF-8")
    Log(Output)
End Sub

Private Sub shellevent_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    Log(Success)
End Sub
 
Top