mirror of
https://github.com/yv1ing/ShotRDP.git
synced 2025-09-16 15:10:57 +08:00
修改截图调用方式,加入可选的尺寸参数
This commit is contained in:
@@ -28,7 +28,9 @@ type RdpClient struct {
|
||||
sec *sec.Client // 安全层
|
||||
pdu *pdu.Client // PDU协议层
|
||||
|
||||
channels *plugin.Channels
|
||||
channels *plugin.Channels
|
||||
screenWidth int
|
||||
screenHeight int
|
||||
}
|
||||
|
||||
type Position struct {
|
||||
@@ -49,13 +51,17 @@ var (
|
||||
positionMap = make(map[Position]*common.Bitmap)
|
||||
)
|
||||
|
||||
func Newclient(host string, logLevel glog.LEVEL) *RdpClient {
|
||||
func Newclient(host string, logLevel glog.LEVEL, screenWidth, screenHeight int) *RdpClient {
|
||||
_logger := log.New(os.Stdout, "", 0)
|
||||
|
||||
glog.SetLogger(_logger)
|
||||
glog.SetLevel(logLevel)
|
||||
|
||||
return &RdpClient{Host: host}
|
||||
return &RdpClient{
|
||||
Host: host,
|
||||
screenWidth: screenWidth,
|
||||
screenHeight: screenHeight,
|
||||
}
|
||||
}
|
||||
|
||||
func (client *RdpClient) Login(domain, username, password string) ([]byte, error) {
|
||||
@@ -130,7 +136,7 @@ func (client *RdpClient) initProtocolStack(conn net.Conn, domain, username, pass
|
||||
|
||||
// 配置桌面信息
|
||||
client.channels = plugin.NewChannels(client.sec)
|
||||
client.mcs.SetClientDesktop(uint16(800), uint16(600))
|
||||
client.mcs.SetClientDesktop(uint16(client.screenWidth), uint16(client.screenHeight))
|
||||
|
||||
// 设置认证信息
|
||||
client.sec.SetDomain(domain)
|
||||
@@ -214,7 +220,7 @@ func (client *RdpClient) setEventHandler() {
|
||||
去除requestedProtocol中的PROTOCOL_HYBRID,避免使用NLA
|
||||
*/
|
||||
|
||||
func RealGetScreen(host string) ([]byte, error) {
|
||||
client := Newclient(host, glog.INFO)
|
||||
func RealGetScreen(host string, screenWidth, screenHeight int) ([]byte, error) {
|
||||
client := Newclient(host, glog.INFO, screenWidth, screenHeight)
|
||||
return client.Login("", "", "")
|
||||
}
|
||||
@@ -13,7 +13,7 @@ func TestGetScreen(t *testing.T) {
|
||||
Windows 10 ✔
|
||||
*/
|
||||
|
||||
imgBytes, err := RealGetScreen("127.0.0.1:3389")
|
||||
imgBytes, err := RealGetScreen("127.0.0.1:3389", 1024, 800)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
Reference in New Issue
Block a user