Skip to content

Desktop

GhostglowDev edited this page Mar 21, 2024 · 2 revisions
local pc = require "ghostutil.desktop"

See source code

Wiki made by TBar09

WARNING: Some of these functions are super dangerous and could harm your system if you don't use them with caution! Please use with care.

(GhostglowDev, T-Bar, and the GhostUtil Contributors is NOT responsible for any harm done to any computer as a result of using these functions without care)

runCMDCode(codeToRun:String) -> Void

Runs a Command Prompt (CMD) code.

  • codeToRun: the Command Prompt code you want to run.

Example:

function onCreatePost()
    pc.runCMDCode("start https://www.youtube.com/watch?v=dQw4w9WgXcQ")
end

runNircmdCode(codeToRun:String, includeNircmdTag:Bool) -> Void

Runs Nircmd code (use with care please).

  • codeToRun: the Nircmd code you want to run (must include "nircmd.exe " at the beginning)
  • includeNircmdTag: Do you want the "nircmd.exe " part to be added automatically?

Example:

function onSongStart()
    pc.runNircmdCode([[nircmd.exe infobox "Title" "message" ]], false)

    pc.runNircmdCode([[infobox "Title" "message" ]], true)
end

infobox(message:String, title:String) -> Void

Makes a default message box, similar to the "window.alert()" function in Application.

  • message: The message inside the box.
  • title: The title of the message box.

Example:

function onSongStart()
    pc.infobox("This is a cool message. Hi!", "This is a title!")
end

qbox(message:String, title:String, yesFunction:String, whatToRun:String, onTop:Bool) -> Void

Similar to infobox, only this is a question box and triggers something when you press "yes".

  • message: The message inside the box.
  • title: The title of the message box.
  • yesFunction: The code to run if you press "yes".
  • whatToRun: What should be ran if you press "yes"? can be "command" or "program".
  • onTop: Is the question box created on top of all apps?

Example:

function onSongStart()
    pc.qbox("Do you like GhostUtil?", "Quick question", "calc.exe", "program", false)

    pc.qbox("are cats cool?", "Quick question... again", [[infobox "Yea, cats are cool" "Correct Answer" ]], "command", true)
end

runNircmdScript(script:String) -> Void

Runs a Nircmd script containing commands. (for now, must be in a subfolder of where nircmd is)

  • script: The filepath of the script, starting in the 'nircmd' folder.

Example:

function onCreate()
    pc.runNircmdScript("nirscripts/myscript.ncl")
end

turnMonitorOff() -> Void

Turns your monitor off, what more is there to it? (Use at your own risk)

Example:

function onGameOver()
    pc.turnMonitorOff()
end

exitwin(shutdownType:String, additionalOption:String) -> Void

Terminates the current session of Windows. (Use at your own risk)

  • shutdownType: can be:
    • 'logoff' - Logs off the current user and displays the log-on dialog to allow another user to log-in.
    • 'reboot' - Performs a reboot.
    • 'poweroff' - Shut down the entire system, and then turns off the power. (only if your pc supports this)
    • 'shutdown' - Shuts down the entire system and reboots, only it doesn't turn off the power.
  • additionalOption: can be:
    • 'force' - Terminates all running applications, no question. This can cause an application to lose data, so use it with care.
    • 'forceifhung' - Only terminates the application IF its not responding (only on Windows 2000 or XP).

Example:

function onNoteMiss()
    pc.exitwin('reboot')

    pc.exitwin('reboot', 'force')
end

initshutdown(message:String, timeOutInSeconds:Int, shutdownType:String) -> Void

Initiates a system shutdown. (Use at your own risk)

  • message: The message displayed before the the shutdown.
  • timeOutInSeconds: How many seconds it takes before the shutdown, gives you a chance to close it.
  • shutdownType: can be:
    • 'reboot' - Performs a reboot.
    • 'force' - Terminates all running applications, no question. This can cause an application to lose data, so use it with care.

Example:

function onGameOver()
    pc.initshutdown("This is a message, your pc is about to be shut off.", 10)

    pc.initshutdown("This is a message, your pc is about to be rebooted.", 10, 'reboot')
end

performMonitorAction(action:String) -> Void

Performs a monitor action. (Use at your own risk)

  • action: The action to be performed:
    • 'off' - Turns the monitor off.
    • 'async_off' - Turn off the monitor. Use this value if Nircmd remains in memory when using monitor off.
    • 'on' - Turns on the monitor.
    • 'low' - Set the monitor to low power mode/state.

Example:

function onCreatePost()
    if lowQuality then
        pc.performMonitorAction('low')
    end
end
Clone this wiki locally