Code: Select all
RunProgram("/usr/bin/pmset", "sleepnow", "")
Code: Select all
RunProgram("/usr/bin/pmset", "sleepnow", "")
Code: Select all
; PB 5.40+
; For security purposes, caller must be root or the console user
#MACH_PORT_NULL = 0
ImportC "-framework IOKit"
IOPMFindPowerManagement(master_device_port)
IOPMSleepSystem(fb)
IOServiceClose(connect)
EndImport
fb = IOPMFindPowerManagement(#MACH_PORT_NULL)
If #MACH_PORT_NULL <> fb
err = IOPMSleepSystem(fb)
If err
Debug "error"
EndIf
IOServiceClose(fb)
EndIf
And what's the Code behind the RunProgram function? Yes, it's such ObjC code -fsw wrote:In ObjectiveC:In PureBasic:Code: Select all
NSTask *pmsetTask = [[NSTask alloc] init]; pmsetTask.launchPath = @"/usr/bin/pmset"; pmsetTask.arguments = @[@"sleepnow"]; [pmsetTask launch];
Easy.Code: Select all
RunProgram("/usr/bin/pmset", "sleepnow", "")