Last active
December 15, 2023 00:31
-
-
Save Mr-Ojii/d68ed1e26f5da22b88334c2c9aeb663f to your computer and use it in GitHub Desktop.
テキストソースにマウス状態を結び付けます
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--初めて書いたOBSスクリプトなので、バグがあったらすみません | |
--[[ | |
These codes are licensed under CC0. | |
http://creativecommons.org/publicdomain/zero/1.0/deed.ja | |
]] | |
obs = obslua | |
source_name = "" | |
C = {} | |
function set_text() | |
local b = (C.GetAsyncKeyState(1) < 0) | |
local source = obs.obs_get_source_by_name(source_name) | |
if source ~= nil then | |
local settings = obs.obs_data_create() | |
if b then | |
obs.obs_data_set_string(settings, "text", "Press") | |
else | |
obs.obs_data_set_string(settings, "text", "Release") | |
end | |
obs.obs_source_update(source, settings) | |
obs.obs_data_release(settings) | |
obs.obs_source_release(source) | |
end | |
end | |
function script_description() | |
return "テキストソースにマウスの状態を結びつけます" | |
end | |
function script_properties() | |
local props = obs.obs_properties_create() | |
local p = obs.obs_properties_add_list(props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) | |
local sources = obs.obs_enum_sources() | |
if sources ~= nil then | |
for _, source in ipairs(sources) do | |
source_id = obs.obs_source_get_unversioned_id(source) | |
if source_id == "text_gdiplus" or source_id == "text_ft2_source" then | |
local name = obs.obs_source_get_name(source) | |
obs.obs_property_list_add_string(p, name, name) | |
end | |
end | |
end | |
obs.source_list_release(sources) | |
return props | |
end | |
function script_update(settings) | |
source_name = obs.obs_data_get_string(settings, "source") | |
end | |
function script_load(settings) | |
local ffi = require("ffi") | |
ffi.cdef[[ | |
short GetAsyncKeyState(int nVirtKey); | |
]] | |
C = ffi.C | |
obs.timer_add(set_text, 10) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FFIでWindows APIを呼び出しているので、Windows上でしか使えません。