Skip to content

Commit 977c767

Browse files
committed
默认web按键展示页增加放大缩小按钮,页面上根据PR增加OBS插件的例子,增加开关用于控制 合并连续相同的字符,用×计数
1 parent 24c9741 commit 977c767

File tree

16 files changed

+165
-62
lines changed

16 files changed

+165
-62
lines changed

build/release/httpdist/dist/showKeyBoard.desc.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,7 @@ ctrlRadius = 20
150150
; 控制键显示的圆角半径
151151

152152
guiFadeMs =500
153-
; 按键提示渐变消失持续毫秒数
153+
; 按键提示渐变消失持续毫秒数
154+
155+
mergeChar = 1
156+
; 相同字母是否合并,默认为1

build/showKeyBoard(node).nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
; 安装程序初始定义常量
55
!define PRODUCT_NAME $(ToolLang)
6-
!define PRODUCT_VERSION "v1.56"
6+
!define PRODUCT_VERSION "v1.57"
77
!define /date DATESTR "%y%m%d"
88
!define ExeName "showKeyBoard.exe"
99
!define PRODUCT_PUBLISHER "Austin.Young"

build/showKeyBoard.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
; 安装程序初始定义常量
55
!define PRODUCT_NAME $(ToolLang)
6-
!define PRODUCT_VERSION "v1.56"
6+
!define PRODUCT_VERSION "v1.57"
77
!define /date DATESTR "%y%m%d"
88
!define ExeName "showKeyBoard.exe"
99
!define PRODUCT_PUBLISHER "Austin.Young"

common.ahk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ ReadAllIni() {
189189
global maxCountOfConnectFail,maxCountOfConnectFail := DescRead("common", "maxCountOfConnectFail", 60) ; 连续通讯失败多少次后提示报错
190190

191191
global guiFadeMs,guiFadeMs := DescRead("dialog", "guiFadeMs", 500) ; 窗口渐变消失ms数,0表示立刻消失
192+
193+
global showKeyOnlyWeb,showKeyOnlyWeb := DescRead("common", "showKeyOnlyWeb", "0")
194+
; 按键显示模式,1=只在Web上显示,桌面不显示,0=桌面和web均显示
195+
global mergeChar,mergeChar := DescRead("dialog", "mergeChar", "1")
196+
; 相同字母是否合并,默认为1
192197
}
193198
ReadAllIni()
194199
GetKeyList()
@@ -250,5 +255,3 @@ lastTextArr := [] ; lastTextArr := textArr
250255
; 最近一次窗口时间
251256
lastTextTick := 0 ; 用于控制是否显示新窗口
252257

253-
global showKeyOnlyWeb,showKeyOnlyWeb := DescRead("common", "showKeyOnlyWeb", "0")
254-
; 按键显示模式,1=只在Web上显示,桌面不显示,0=桌面和web均显示

dialog.ahk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ GetKeyText(arr)
369369
count :=1
370370
loop arr.Length{
371371
; 如果一样用 ❌✖×
372-
if preCh = arr[A_Index]{
372+
if (preCh = arr[A_Index]) && mergeChar = 1 {
373373
count += 1
374374
text := preDiffText "×" count
375375
}Else{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.56",
2+
"version": "1.57",
33
"name": "node",
44
"scripts": {
55
"build": "node ./build/buildMain.js"

showKeyBoard.ahk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
;编译信息
22
;@Ahk2Exe-SetName ShowKeyBoard
33
;@Ahk2Exe-SetDescription Show and Analyse Mouse/KeyBoard
4-
;@Ahk2Exe-SetProductVersion 1.56.0.0
5-
;@Ahk2Exe-SetFileVersion 1.56.0.0
4+
;@Ahk2Exe-SetProductVersion 1.57.0.0
5+
;@Ahk2Exe-SetFileVersion 1.57.0.0
66
;@Ahk2Exe-SetCopyright Austing.Young (2023 - )
77
;@Ahk2Exe-SetMainIcon res\keyboard.ico
88
;@Ahk2Exe-ExeName build/release/ShowKeyBoard.exe
99
#Requires AutoHotkey v2
1010
#SingleInstance Ignore
11-
global APPName := "ShowKeyBoard", ver:= "1.56"
11+
global APPName := "ShowKeyBoard", ver:= "1.57"
1212
#Include "lib/JSON.ahk"
1313
#include common.ahk
1414
#include langVars.ahk

ui-helper/public/obs/index.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<html>
2+
<meta charset="utf-8">
3+
4+
<body>
5+
<title>Open Broadcaster Software | OBS Plugin</title>
6+
<script src="obscjjs.js"></script>
7+
<div class="wk">
8+
<div id='danmu'>
9+
</div>
10+
</div>
11+
<script>
12+
</script>
13+
<style type="text/css">
14+
.wk {
15+
width: 100%;
16+
height: 80%;
17+
text-overflow: ellipsis;
18+
/* background-image: linear-gradient(-225deg, #D4FFEC 0%, #57F2CC 48%, #4596FB 100%); */
19+
20+
/* text-overflow:ellipsis;超出部分显示省略号 */
21+
white-space: nowrap;
22+
/*规定段落中的文本不进行换行 */
23+
}
24+
25+
#danmu {
26+
width: 60%;
27+
/* 位置,宽度 */
28+
height: 90%;
29+
/* 位置,高度 */
30+
line-height: 1.3;
31+
/* 行高,1.5是字体大小1.5倍,50px是固定大小 */
32+
font-size: 50px;
33+
/* 字体,大小 */
34+
font-weight: 700;
35+
/* 字体,粗细 */
36+
font-style: italic;
37+
/* 字体,风格,斜体还是正常还是中间 */
38+
float: left;
39+
padding-left: 10px;
40+
text-align: left;
41+
overflow: hidden;
42+
text-decoration: underline(to right, rgb(64, 211, 15), rgb(201, 61, 61));
43+
}
44+
45+
#danmu span {
46+
background: linear-gradient(to right, rgb(247, 247, 247), rgba(255, 255, 255, 0.589));
47+
-webkit-text-stroke: 2px black;
48+
-webkit-background-clip: text;
49+
/* 标准属性(未来兼容) */
50+
background-clip: text;
51+
color: transparent;
52+
}
53+
</style>
54+
</body>
55+
</html>

ui-helper/public/obs/obscjjs.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// =====================================
2+
// 极简 OBS 键盘显示版
3+
// 仅连接 ws://127.0.0.1:9000
4+
// =====================================
5+
6+
// 建立本地 WebSocket 连接
7+
const ws = new WebSocket("ws://127.0.0.1:9900");
8+
9+
// 连接成功
10+
ws.onopen = () => {
11+
console.log("已连接到 127.0.0.1:9900");
12+
ws.send("ahkKeyShow"); // 告诉服务器我们要接收键盘数据
13+
};
14+
15+
// 用于处理 0:: 动态刷新
16+
let lastNewDiv = null;
17+
18+
// 创建文本显示
19+
function createNewTxt(text) {
20+
let danmu = document.getElementById("danmu");
21+
if (!danmu) return;
22+
23+
let container = document.createElement("div");
24+
let span = document.createElement("span");
25+
26+
span.textContent = text;
27+
container.appendChild(span);
28+
29+
lastNewDiv = span;
30+
31+
// 插入到最前面
32+
if (danmu.firstChild) {
33+
danmu.insertBefore(container, danmu.firstChild);
34+
} else {
35+
danmu.appendChild(container);
36+
}
37+
38+
// 最多保留 5 条
39+
while (danmu.children.length > 5) {
40+
danmu.removeChild(danmu.lastChild);
41+
}
42+
}
43+
44+
// 接收消息
45+
ws.onmessage = async (event) => {
46+
let text = event.data instanceof Blob
47+
? await event.data.text()
48+
: event.data;
49+
50+
console.log("收到:", text);
51+
52+
// 如果是动态刷新
53+
if (text.startsWith("0::")) {
54+
text = text.replace("0::", "");
55+
if (lastNewDiv) {
56+
lastNewDiv.textContent = text;
57+
}
58+
} else {
59+
createNewTxt(text);
60+
}
61+
};
62+
63+
// 连接关闭
64+
ws.onclose = () => {
65+
console.log("连接已关闭");
66+
};
67+
68+
// 错误处理
69+
ws.onerror = (err) => {
70+
console.error("WebSocket错误:", err);
71+
};

ui-helper/public/showAnimateUI.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ let globalMonitor = 1
99
let timeOutList = [] // 产生新text的定时器句柄
1010
let objContainer = null
1111
let objMain = null
12-
let playState = 'running'
1312
// 创建一个窗口显示 Div
1413
let winOpt = {
1514
guiWidth: 240,
@@ -427,54 +426,10 @@ function initContain(monitor, opt) {
427426
}else{
428427
showKeyPress(opt)
429428
}
430-
431429
// fullScreenEvent
432430
// fullScreenEvent()
433431
}
434-
// 全屏代码
435-
// function fullScreen(id) {
436-
// const myDiv = document.getElementById('monitorId' + id);
437-
// toggleFullscreen(myDiv)
438-
// }
439432

440-
// function toggleFullscreen(myDiv) {
441-
// if (document.fullscreenElement) {
442-
// if (document.exitFullscreen) {
443-
// document.exitFullscreen();
444-
// } else if (document.webkitExitFullscreen) {
445-
// document.webkitExitFullscreen();
446-
// } else if (document.mozCancelFullScreen) {
447-
// document.mozCancelFullScreen();
448-
// } else if (document.msExitFullscreen) {
449-
// document.msExitFullscreen();
450-
// }
451-
// } else {
452-
// if (myDiv.requestFullscreen) {
453-
// myDiv.requestFullscreen();
454-
// } else if (myDiv.webkitRequestFullscreen) {
455-
// myDiv.webkitRequestFullscreen();
456-
// } else if (myDiv.mozRequestFullScreen) {
457-
// myDiv.mozRequestFullScreen();
458-
// } else if (myDiv.msRequestFullscreen) {
459-
// myDiv.msRequestFullscreen();
460-
// }
461-
//
462-
// }
463-
// }
464-
// 监控变化
465-
const observer = new ResizeObserver(entries => {
466-
for (const entry of entries) {
467-
// const { width, height } = entry.contentRect;
468-
// 需要重新演示动画
469-
if (entry.target.id == 'mainContain') {
470-
// 全屏时候忽略
471-
// if (globalinFullScreen) {
472-
// return
473-
// }
474-
initMain()
475-
}
476-
}
477-
});
478433
// 显示当前的窗口像素 根据子窗口的大小显示真实长宽
479434
function showSize() {
480435
setTimeout(() => {

0 commit comments

Comments
 (0)