我正在学习Caleb Doxsey 的《Go 编程简介》一书
在关于服务器的第 13 章中,我们给出了代码:
package main
import (
"encoding/gob"
"fmt"
"net"
)
func server() {
// listen on a port
ln, err := net.Listen("tcp", ":9999")
if err != nil {
fmt.Println("server, Listen", err)
return
}
for {
// accept a connection
c, err := ln.Accept()
if err != nil {
fmt.Println("server, Accept", err)
continue
}
// handle the connection
go handleServerConnection(c)
}
}
func handleServerConnection(c net.Conn) {
// receive the message
var msg string
err …Run Code Online (Sandbox Code Playgroud) 这是我的 C++ 代码:
#include <iostream>
#include <windows.h>
HHOOK hook;
LRESULT CALLBACK keyboardHook(int nCode, WPARAM wParam, LPARAM lParam)
{
std::cout << "Hook callback" << std::endl;
return CallNextHookEx(hook, nCode, wParam, lParam);
}
int main(int argc, char **argv)
{
hook = SetWindowsHookEx(WH_KEYBOARD, keyboardHook, NULL, NULL);
if (hook == NULL) {
std::cout << "Error " << GetLastError() << std::endl;
return 1;
}
std::cout << "Hook set" << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
我使用 Visual Studio 编译它,如下所示:
cl /D_WIN32_WINNT=0x0401 foo.cc /link user32.lib
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我收到错误 1428。
C:\>foo.exe
Error 1428
Run Code Online (Sandbox Code Playgroud)
这就是错误1428的含义。 …
我想改进我的SendInput()功能,但遇到了错误。
错误_无效_参数
Run Code Online (Sandbox Code Playgroud)87 (0x57) The parameter is incorrect.https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx
我有点困惑哪个参数不应该正确。
如果我忘记了什么,请随时询问。
INPUT in[6] = {0};
//Press Enter Key
in[0].type = INPUT_KEYBOARD;
in[0].ki.wScan = 0;
in[0].ki.dwFlags = 0;
in[0].ki.time = 0;
in[0].ki.dwExtraInfo = 0;
in[0].ki.wVk = VK_RETURN;
//release enter key
in[1] = in[0];
in[1].ki.dwFlags = KEYEVENTF_KEYUP;
//Hold Shift key and press key 7
in[2].type = INPUT_KEYBOARD;
in[2].ki.wScan = 0;
in[2].ki.dwFlags = 0;
in[2].ki.time = 0;
in[2].ki.dwExtraInfo = 0;
in[2].ki.wVk = VK_SHIFT;
in[3].type = INPUT_KEYBOARD;
in[3].ki.wScan = 0;
in[3].ki.dwFlags = …Run Code Online (Sandbox Code Playgroud) 我正在使用 OpenCV python 将单个 HSL 值转换为 RGB 值。
由于没有 HSL2RGB 标志,所以我使用 HLS2RGB 标志。我假设 HSL 和 HLS 指的是相同的颜色空间,但只是翻转 S 和 L 值。是对的吗?
所以这是我的尝试:
import cv2
hls = (0, 50, 100) # This is color Red
rgb = cv2.cvtColor( np.uint8([[hls]] ), cv2.COLOR_HLS2RGB)[0][0]
Run Code Online (Sandbox Code Playgroud)
转换后rgb值为[70,30,30]
然而,当我在在线 RGB 选择器上检查这个 RGB 值时,颜色是深棕色。
知道转换过程中哪里可能出错吗?谢谢