Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #128

Merged
merged 14 commits into from
Jan 19, 2024
97 changes: 97 additions & 0 deletions assets/script/http_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
from urllib.parse import urlparse, parse_qs
from signal import signal, SIGINT
from sys import exit
from json import loads, dumps
from argparse import ArgumentParser

class HttpHandler(BaseHTTPRequestHandler):
protocol_version = 'HTTP/1.1'
error_content_type = 'text/plain'
error_message_format = "Error %(code)d: %(message)s"

def do_GET(self):
path, args = self.parse_url()

if path == '/hello' and 'name' in args:
name = args['name'][0]

self.write_response(200, "text/plain", f"Hello, {name}!")
else:
self.send_error(404, 'Not found')

def do_POST(self):
path, _ = self.parse_url()
body = self.read_body()

if path == '/echo' and body and self.headers['Content-Type'] == "application/json":
json_body = self.parse_json(body)

if json_body:
self.write_response(202, "application/json",
dumps({"message": "Accepted", "request": json_body}, indent=2))
else:
self.send_error(400, 'Invalid json received')
elif path == '/echo' and body:
self.write_response(202, "text/plain", f"Accepted: {body}")
else:
self.send_error(404, 'Not found')

def parse_url(self):
url_components = urlparse(self.path)
return url_components.path, parse_qs(url_components.query)

def parse_json(self, content):
try:
return loads(content)
except Exception:
return None

def read_body(self):
try:
content_length = int(self.headers['Content-Length'])
return self.rfile.read(content_length).decode('utf-8')
except Exception:
return None

def write_response(self, status_code, content_type, content):
response = content.encode('utf-8')

self.send_response(status_code)
self.send_header("Content-Type", content_type)
self.send_header("Content-Length", str(len(response)))
self.end_headers()
self.wfile.write(response)

def version_string(self):
return "Tiny Http Server"

def log_error(self, format, *args):
pass


def start_server(host, port):
server_address = (host, port)
httpd = ThreadingHTTPServer(server_address, HttpHandler)
print(f"Server started on {host}:{port}")
httpd.serve_forever()


def shutdown_handler(signum, frame):
print('Shutting down server')
exit(0)


def main():
signal(SIGINT, shutdown_handler)
parser = ArgumentParser(description='Start a tiny HTTP/1.1 server')
parser.add_argument('--host', type=str, action='store',
default='127.0.0.1', help='Server host (default: 127.0.0.1)')
parser.add_argument('--port', type=int, action='store',
default=8000, help='Server port (default: 8000)')
args = parser.parse_args()
start_server(args.host, args.port)


if __name__ == "__main__":
main()
19 changes: 19 additions & 0 deletions assets/script/tcp_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#coding:utf-8
import sys
from socket import *
serverHost = 'localhost'
serverPort = 6000
#发送至服务端的默认文本
message = ['Hello network world']
#建立一个tcp/ip套接字对象
sockobj = socket(AF_INET, SOCK_STREAM)
#连接至服务器及端口
sockobj.connect((serverHost, serverPort))
for line in message:
#经过套按字发送line至服务端
sockobj.send(line.encode())
#从服务端接收到的数据,上限为1k
data = sockobj.recv(1024)
print('Client received:', repr(data))
#关闭套接字
sockobj.close( )
27 changes: 27 additions & 0 deletions assets/script/tcp_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#coding:utf-8
from socket import *
#''代表服务器为 localhost
myHost = ''
#在一个非保留端口号上进行监听
myPort = 6000
#设置一个TCP socket对象
sockobj = socket(AF_INET, SOCK_STREAM)
#绑定端口号
sockobj.bind((myHost, myPort))
#监听,允许5个连结
sockobj.listen(5)
#直到进程结束时才结束循环
while True:
#等待客户端连接
connection, address = sockobj.accept( )
#连接是一个新的socket
print('Server connected by', address)
while True:
#读取客户端套接字的下一行
data = connection.recv(1024)
#如果没有数量的话,那么跳出循环
if not data: break
#发送一个回复至客户端
connection.send('Echo from server => '.encode() + data)
#当socket关闭时eof
connection.close( )
16 changes: 16 additions & 0 deletions assets/script/udp_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import socket

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
addr = ("127.0.0.1", 6000)


s.sendto('hello server!'.encode(), addr)

while True:
response, addr = s.recvfrom(1024)
print(response.decode())
if response.decode() == "exit":
print("Session is over from the server %s:%s\n" % addr)
break

s.close()
13 changes: 13 additions & 0 deletions assets/script/udp_send.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import socket
import time

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
addr = ("127.0.0.1", 6000)



while True:
s.sendto('hello server!'.encode(), addr)
time.sleep(1)

s.close()
13 changes: 13 additions & 0 deletions assets/script/udp_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import socket

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("127.0.0.1", 6001))
print("UDP bound on port 6001...")

while True:
data, addr = s.recvfrom(1024)
print("Receive from ", addr, data)
if data == b"exit":
s.sendto(b"Good bye!\n", addr)
continue
s.sendto(b"Hello client, i'm a boy!" , addr)
19 changes: 19 additions & 0 deletions assets/web/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<select name="selectomatic">
<option id="non_multi_option" value="one">One</option>
<option selected="selected" value="two">Two</option>
<option value="four">Four</option>
<option value="still learning how to count, apparently">Still learning how to count, apparently</option>
</select>

<label id="lv" style="visibility:hidden;"> text</label>

<a href="" id="Courses">winui++</a>

<input id="text" />
<iframe
id="inlineFrameExample"
title="Inline Frame Example"
width="300"
height="200"
src="https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569861898606&layer=mapnik">
</iframe>
39 changes: 37 additions & 2 deletions docx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
# [0.31](https://github.com/shelllet/winui/compare/main...dev) (2023-12-22)
# [0.33](https://github.com/shelllet/winui/compare/main...dev) (2024-x-x)

### Changed:

1. 移动鼠标动作支持多显示器。
2. 优化统计分析模块。
3. 优化浏览器操作
4. 恢复 *For*(循环)动作名称。
5. *访问数组* 中的索引参数,去掉数字类型,使用表达式,同时支持字典访问。
5. 恢复 *前置窗口截图*,重命名为:[CaptureActiveWindow(活动窗口截取)](./actions/media/CaptureActiveWindow.md)。

### Deprecated:

### Note

1. 下载:about:blank

## [0.32](https://github.com/shelllet/winui/compare/main...dev) (2024-1-19)

### Changed:

1. 移动鼠标动作支持多显示器。
2. 优化统计分析模块。
3. 优化浏览器操作
4. 恢复 *For*(循环)动作名称。
5. *访问数组* 中的索引参数,去掉数字类型,使用表达式,同时支持字典访问。
5. 恢复 *前置窗口截图*,重命名为:[CaptureActiveWindow(活动窗口截取)](./actions/media/CaptureActiveWindow.md)。

### Deprecated:

### Note

1. 下载:https://winui.net/_media/winui++0.32.0-setup.x64.exe


## [0.31](https://github.com/shelllet/winui/compare/main...dev) (2023-12-22)

### Changed:

Expand All @@ -17,7 +52,7 @@

### 备注

1. 下载:https://winui.net/_media/simple/winui++0.31-setup.x64
1. 下载:https://winui.net/_media/winui++0.31.1-setup.x64.exe

## [0.30](https://github.com/shelllet/winui/compare/main...dev) (2023-11-10)

Expand Down
6 changes: 5 additions & 1 deletion docx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ _WinUi++_ 绝对不会嵌入任何广告、捆绑任何软件。也不会像国
- YT: [https://www.youtube.com/playlist?list=UULFs1P87PQvBDJAuJfkKRLqMQ](https://www.youtube.com/playlist?list=UULFs1P87PQvBDJAuJfkKRLqMQ)
- B 站:[https://space.bilibili.com/652005178/channel/collectiondetail?sid=84951](https://space.bilibili.com/652005178/channel/collectiondetail?sid=84951)

- 加入 [Discord](https://discord.gg/b4MeYbJrfk) 讨论。
- 如果你有 *Discord*, 加入 [Discord](https://discord.gg/b4MeYbJrfk) 讨论。

- 扫码加入微信交流群。

![wx](./introduction/images/wx.png ':size=40%')

<script>
Docsify.get('https://api.winui.net/simple/v3/latest').then(()=>{}, (reason)=>{
Expand Down
29 changes: 16 additions & 13 deletions docx/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- 流程
- [项目属性](./introduction/workflow/property.md)
- [使用逻辑](./introduction/workflow/logic.md)
- [鼠标/键盘宏录制](./introduction/workflow/Record.md)
- [鼠标/键盘宏录制](./introduction/workflow/mk_record)
- [变量](./introduction/workflow/variable.md)
- [流程操作技巧](./introduction/workflow/skill.md)
- [通配符匹配](./introduction/workflow/wildcard.md)
Expand All @@ -28,6 +28,7 @@
- [终止进程](./actions/system/KillProcess.md)
- [登录应用](./actions/system/LoginApplication.md)
- [剪切板](./actions/system/ClipboardValue.md)
- [输出文本](./actions/xml/OutputString.md)
- 异步操作
- [定时器](./actions/async/WorkTimer.md)
- [定时任务](./actions/async/WorkTask.md)
Expand Down Expand Up @@ -64,6 +65,7 @@
- [拖拽](./actions/mouse/DragPointer.md)
- [监听鼠标](./actions/mouse/ListenMouse.md)
- [偏移移动](./actions/mouse/MoveOffset.md)
- [点击*网格](./actions/mouse/CellClick.md)
- 窗口
- [查找窗口](./actions/window/FindWindow.md)
- [特定窗口](./actions/window/SpecialWindow.md)
Expand Down Expand Up @@ -117,29 +119,31 @@
- 媒体
- [窗口截图](./actions/media/CaptureWindow.md)
- [全屏截图](./actions/media/CaptureFullScreen.md)
- [活动窗口截图](./actions/media/CaptureActiveWindow.md)
- [声音播放](./actions/media/MediaPlay.md)
- [键盘/鼠标宏重放](./actions/media/PlayRecord.md)
- [相机图像](./actions/media/VideoFrame.md)
- [屏幕取色](./actions/media/PixelPoint.md)
- 网络
- [文件下载](./actions/network/HttpDownload.md)
- [视频下载](./actions/network/VideoDownload.md)
- [HEAD 请求](./actions/network/HttpHead.md)
- [GET 请求](./actions/network/HttpGet.md)
- [POST 请求](./actions/network/HttpPost.md)
- [网络服务](./actions/network/NetworkListen.md)
- [网络发送](./actions/network/NetworkSend.md)
- [网络接收](./actions/network/NetworkReceive.md)
- [数据发送](./actions/network/NetworkSend.md)
- [数据接收](./actions/network/NetworkReceive.md)
- [服务连接](./actions/network/NetworkConnect.md)
- 统计分析
- [文档](./actions/xml/XmlLoadDocument.md)
- [获取节点](./actions/xml/XmlGetNodeList.md)
- [节点名称](./actions/xml/XmlNodeName.md)
- [元素](./actions/xml/XmlDocumentElement.md)
- [文本替换](./actions/xml/XmlReplaceText.md)
- [保存](./actions/xml/XmlSaveDocument.md)
- [读取 Json](./actions/json/ReadJson.md)
- [加载文档](./actions/pandas/LoadDocument.md)
- [查询](./actions/pandas/DataFrameQuery.md)
- [统计行数](./actions/pandas/RowsCount.md)
- [行列选择 * 标签](./actions/pandas/NameLoc.md)
- [行列选择 * 索引](./actions/pandas/IndexLoc.md)
- [迭代行](./actions/pandas/IterRow.md)
- [保存文档](./actions/pandas/SaveDocument.md)
- 逻辑
- [迭代](./actions/control/Iterate.md)
- [循环](./actions/control/For.md)
- [判断](./actions/control/If.md)
- [判空](./actions/control/IsEmpty.md)
- [调用](./actions/control/Invoke.md)
Expand Down Expand Up @@ -175,7 +179,6 @@
- [颜色统计](./actions/algorithm/JoinString.md)
- 类型
- [字符串](./actions/type/TypeString.md)
- [Json](./actions/type/TypeJson.md)
- [网址](./actions/type/TypeUri.md)
- [坐标](./actions/type/TypePoint.md)
- [文件](./actions/type/TypeFile.md)
Expand Down Expand Up @@ -210,7 +213,6 @@
- [框架*设置焦点](./actions/web/WebFocusFrameDefault.md)
- [元素截图](./actions/web/WebScreenshot.md)
- [动作链*创建](./actions/web/WebActionChainsCreated.md)
- [动作链*执行](./actions/web/WebActionChainsPerform.md)
- [动作链.点击](./actions/web/WebActionClick.md)
- [动作链.点按](./actions/web/WebActionClickHold.md)
- [动作链.双击](./actions/web/WebActionDoubleClick.md)
Expand Down Expand Up @@ -287,4 +289,5 @@
- [ContourApproximationModes](./enums/ContourApproximationModes.md)
- [FeatureAlgorithm](./enums/FeatureAlgorithm.md)
- [WindowSortDirection](./enums/WindowSortDirection.md)
- [FileExtension](./enums/FileExtension.md)
- [Changelog](./CHANGELOG.md)
2 changes: 1 addition & 1 deletion docx/actions/algorithm/ColorPercentage.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

## 输出

> 所要统计的颜色所占的百分比,参考:[Number](../types/Number.md)。
> 所要统计的颜色所占的百分比,参考:[Number](./types/Number.md)。


## 脚本调用
Expand Down
2 changes: 1 addition & 1 deletion docx/actions/algorithm/ImageDifference.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

## 输出

> 相似性的指标(小数)。越低,表示匹配越好。*0*:表示完全匹配,参考: [Number](../types/Number.md)
> 相似性的指标(小数)。越低,表示匹配越好。*0*:表示完全匹配,参考: [Number](./types/Number.md)


## 脚本调用
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 迭代
# 循环
用来迭代相应的列表数据,遍历列表的每一个元素,也可称为*循环*。

![action](./images/2022-11-17_184608.png ':size=90%')
![For](./images/2022-11-17_184608.png ':size=90%')

## 子流程

Expand Down
Loading