Clipboard and sound
Clipboard
Section titled “Clipboard”Text only. The clipboard can stall, so clipboard.text() and clipboard.setText(text) work off the caller’s thread and are async. text() gives an empty string if there’s no text. Add "clipboard": true to your permissions.
import { Wraith } from "wraith";
const clipboard = Wraith.clipboard();
await clipboard.setText(`0x${address.toString(16)}`);const text = await clipboard.text();local Wraith = require("wraith").Wraith
local clipboard = Wraith.clipboard()
task.spawn(function() clipboard:setText(string.format("0x%X", address)):await() local text = clipboard:text():await()end)C# can’t await in an unsafe class, so await them from one that isn’t.
var clipboard = Clipboard.Instance;
await clipboard.SetTextAsync($"0x{address:X}");var text = await clipboard.TextAsync();#include <cstdio>
static sal::Future<void> copy_address() { auto clipboard = wraith::api().clipboard(); char hex[32]; std::snprintf(hex, sizeof hex, "0x%llx", static_cast<unsigned long long>(address)); co_await clipboard.setText(hex); auto pasted = co_await clipboard.text(); if (pasted) { std::string_view text = pasted->view(); // good till this thread takes another } co_return {};}let _ = salamander::spawn(async move { let clipboard = wraith::api().clipboard(); clipboard.set_text(&format!("0x{address:X}")).await?; let pasted = clipboard.text().await?; let text = unsafe { pasted.get() }.to_owned(); Ok::<(), wraith::ClipboardError>(())});Wait on them from a task.
const clipboard = ctx.wraith.clipboard();try sdk.tasks.wait(clipboard.setText("0x1234"));const text = try sdk.tasks.wait(clipboard.text());static sal_Promise pasting;
static void pasted(uintptr_t self) { (void)self; sal_string text = { 0 }; if (sal_Promise_take(pasting, &text) == SAL_OK) { /* text is good till this thread takes another */ } sal_Promise_release(pasting);}
static const sal_Task_table pasted_table = { SAL_TABLE(sal_Task), .call = pasted };
/* in start */Wraith_Clipboard clipboard = Wraith_Api_clipboard(w);char hex[32];int n = snprintf(hex, sizeof hex, "0x%llx", (unsigned long long)address);sal_Promise_release(Wraith_Clipboard_setText(clipboard, (sal_string){ hex, n > 0 ? (uintptr_t)n : 0 }));pasting = Wraith_Clipboard_text(clipboard);sal_Promise_then(pasting, (sal_Task){ 0, &pasted_table }, (sal_Queue){ 0, NULL });WAV files and Windows’ own sounds. One plays at a time, so a new one stops the last, and nothing plays while the user has Sounds off in Wraith’s settings. These work from any thread.
sound.play(wav)takes a WAV file’s bytes, copied first.sound.playSystem(sound)plays one of Windows’ own, aSound.System:default,info,warning,error,questionornotification.sound.stop()stops whatever’s playing.
import { Wraith } from "wraith";
const sound = Wraith.sound();
sound.play(wavBytes); // an array of bytessound.playSystem("notification");sound.stop();local Wraith = require("wraith").Wraith
local sound = Wraith.sound()
sound:play(wav_string)sound:playSystem("notification")sound:stop()var sound = Sound.Instance;
sound.Play(File.ReadAllBytes(Path.Combine(Config.Instance.PluginDirectory(), "sounds/ding.wav")));sound.PlaySystem(Sound.System.Notification);sound.Stop();#include <fstream>#include <iterator>#include <string>#include <vector>
// in startauto sound = wraith::api().sound();std::ifstream file(std::string(wraith::api().config().pluginDirectory()) + "/sounds/ding.wav", std::ios::binary);std::vector<uint8_t> wav{std::istreambuf_iterator<char>(file), {}};sound.play(wav);sound.playSystem(Wraith::Sound::System::notification);sound.stop();use wraith::SoundSystem;
let sound = wraith::api().sound();let wav = std::fs::read(format!("{}/sounds/ding.wav", wraith::api().config().plugin_directory())).ok()?;sound.play(&wav).ok()?;sound.play_system(SoundSystem::NOTIFICATION);sound.stop();const sound = ctx.wraith.sound();try sound.play(@embedFile("ding.wav"));sound.playSystem(.notification);sound.stop();static const uint8_t *wav; /* a WAV file's bytes */static uintptr_t wav_len;
/* in start */Wraith_Sound sound = Wraith_Api_sound(w);Wraith_Sound_play(sound, (Slice_u8){ wav, wav_len });Wraith_Sound_playSystem(sound, Wraith_Sound_System_notification);Wraith_Sound_stop(sound);wraith.io · Mods on the Hub · Get Wraith
Made with ♥ by Asgard
