parent
6bc86a9fa5
commit
ddc735f288
@ -1,15 +0,0 @@
|
|||||||
**/*.html
|
|
||||||
**/*.pyc
|
|
||||||
**/*.yaml
|
|
||||||
**/*.log
|
|
||||||
**/*~
|
|
||||||
**/.DS_Store
|
|
||||||
**/Thumbs.db
|
|
||||||
*.png
|
|
||||||
.idea/
|
|
||||||
.git/
|
|
||||||
.github/
|
|
||||||
*.md
|
|
||||||
UnitTest/
|
|
||||||
uml/
|
|
||||||
*.h5
|
|
@ -1,6 +0,0 @@
|
|||||||
*.html
|
|
||||||
*.pyc
|
|
||||||
*.yaml
|
|
||||||
*.log
|
|
||||||
.idea/
|
|
||||||
tkcode.png
|
|
Binary file not shown.
@ -1,24 +0,0 @@
|
|||||||
FROM python:2.7.15
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
ADD . /usr/src/app
|
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND noninteractive
|
|
||||||
ENV TZ Asia/Shanghai
|
|
||||||
|
|
||||||
|
|
||||||
## install python requirements
|
|
||||||
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider --no-cache-dir -r requirements.txt
|
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
||||||
|
|
||||||
## install ntpdate, not accept but saving code
|
|
||||||
#RUN echo 'deb http://mirrors.163.com/debian/ jessie main non-free contrib \
|
|
||||||
# deb http://mirrors.163.com/debian/ jessie-updates main non-free contrib \
|
|
||||||
# deb http://mirrors.163.com/debian-security/ jessie/updates main non-free contrib' > /etc/apt/sources.list \
|
|
||||||
# && apt-get update\
|
|
||||||
# && apt-get install ntpdate -y \
|
|
||||||
|
|
||||||
|
|
||||||
#EXPOSE 5010
|
|
||||||
|
|
||||||
CMD [ "python", "run.py" ]
|
|
||||||
#ENTRYPOINT [ "python", "run.py" ]
|
|
@ -1,51 +0,0 @@
|
|||||||
FROM python:3.7-slim-buster
|
|
||||||
|
|
||||||
ARG CDV=77.0.3865.40
|
|
||||||
|
|
||||||
RUN sed -i 's/deb.debian.org/ftp.cn.debian.org/g' /etc/apt/sources.list
|
|
||||||
|
|
||||||
RUN apt-get -y update && apt-get install -y \
|
|
||||||
fonts-liberation \
|
|
||||||
libappindicator3-1 \
|
|
||||||
libasound2 \
|
|
||||||
libatk-bridge2.0-0 \
|
|
||||||
libatk1.0-0 \
|
|
||||||
libatspi2.0-0 \
|
|
||||||
libcups2 \
|
|
||||||
libdbus-1-3 \
|
|
||||||
libgtk-3-0 \
|
|
||||||
libnspr4 \
|
|
||||||
libnss3 \
|
|
||||||
libx11-xcb1 \
|
|
||||||
libxcomposite1 \
|
|
||||||
libxcursor1 \
|
|
||||||
libxdamage1 \
|
|
||||||
libxfixes3 \
|
|
||||||
libxi6 \
|
|
||||||
libxrandr2 \
|
|
||||||
libxss1 \
|
|
||||||
libxtst6 \
|
|
||||||
lsb-release \
|
|
||||||
unzip \
|
|
||||||
wget \
|
|
||||||
xdg-utils \
|
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
ENV TZ Asia/Shanghai
|
|
||||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
RUN wget -q https://dl.lancdn.com/landian/soft/chrome/m/77.0.3865.120_amd64.deb && \
|
|
||||||
dpkg -i 77.0.3865.120_amd64.deb && rm -f 77.0.3865.120_amd64.deb
|
|
||||||
|
|
||||||
RUN wget -q https://npm.taobao.org/mirrors/chromedriver/$CDV/chromedriver_linux64.zip && \
|
|
||||||
unzip chromedriver_linux64.zip && rm -f chromedriver_linux64.zip
|
|
||||||
|
|
||||||
## install python requirements
|
|
||||||
COPY requirements-docker37.txt ./
|
|
||||||
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir -r requirements-docker37.txt
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
CMD [ "sh", "-c", "python run.py c && python run.py r" ]
|
|
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2017
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
119.101.114.196:9999
|
|
File diff suppressed because it is too large
Load Diff
@ -1,61 +0,0 @@
|
|||||||
#coding: utf-8
|
|
||||||
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from config import configCommon
|
|
||||||
|
|
||||||
logger = None
|
|
||||||
loggerHandler = None
|
|
||||||
dateStr = '' #默认拥有日期后缀
|
|
||||||
suffix = '' #除了日期外的后缀
|
|
||||||
|
|
||||||
def setSuffix(s):
|
|
||||||
global suffix
|
|
||||||
suffix = s
|
|
||||||
|
|
||||||
def getTodayDateStr():
|
|
||||||
return time.strftime("%Y-%m-%d", time.localtime(configCommon.getNowTimestamp()))
|
|
||||||
|
|
||||||
def setDateStr(s):
|
|
||||||
global dateStr
|
|
||||||
dateStr = s
|
|
||||||
|
|
||||||
def isAnotherDay(s):
|
|
||||||
global dateStr
|
|
||||||
return dateStr != s
|
|
||||||
|
|
||||||
def getLogFile():
|
|
||||||
global dateStr, suffix
|
|
||||||
rtn = os.path.join(configCommon.getLogDir(), dateStr)
|
|
||||||
if suffix:
|
|
||||||
rtn += "_" + suffix
|
|
||||||
return rtn + ".log"
|
|
||||||
|
|
||||||
def log(msg, func = "info"):
|
|
||||||
global logger
|
|
||||||
if not logger:
|
|
||||||
logger = logging.getLogger()
|
|
||||||
logger.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
todayStr = getTodayDateStr()
|
|
||||||
if isAnotherDay(todayStr):
|
|
||||||
setDateStr(todayStr)
|
|
||||||
logger.removeHandler(loggerHandler)
|
|
||||||
|
|
||||||
fh = logging.FileHandler(getLogFile())
|
|
||||||
fm = logging.Formatter(u'[%(asctime)s][%(levelname)8s] --- %(message)s (%(filename)s:%(lineno)s)')
|
|
||||||
fh.setFormatter(fm)
|
|
||||||
|
|
||||||
logger.addHandler(fh)
|
|
||||||
|
|
||||||
levels = {
|
|
||||||
"debug": logger.debug,
|
|
||||||
"info": logger.info,
|
|
||||||
"warning": logger.warning,
|
|
||||||
"error": logger.error,
|
|
||||||
"critical": logger.critical
|
|
||||||
}
|
|
||||||
|
|
||||||
levels[func](msg)
|
|
@ -1,36 +0,0 @@
|
|||||||
# -*- coding: utf8 -*-
|
|
||||||
import TickerConfig
|
|
||||||
from config.urlConf import urls
|
|
||||||
from myUrllib.httpUtils import HTTPClient
|
|
||||||
|
|
||||||
PUSH_BEAR_API_PATH = "https://pushbear.ftqq.com/sub"
|
|
||||||
|
|
||||||
|
|
||||||
def sendPushBear(msg):
|
|
||||||
"""
|
|
||||||
pushBear微信通知
|
|
||||||
:param str: 通知内容 content
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if TickerConfig.PUSHBEAR_CONF["is_pushbear"] and TickerConfig.PUSHBEAR_CONF["send_key"].strip() != "":
|
|
||||||
try:
|
|
||||||
sendPushBearUrls = urls.get("Pushbear")
|
|
||||||
data = {
|
|
||||||
"sendkey": TickerConfig.PUSHBEAR_CONF["send_key"].strip(),
|
|
||||||
"text": "易行购票成功通知",
|
|
||||||
"desp": msg
|
|
||||||
}
|
|
||||||
httpClint = HTTPClient(0)
|
|
||||||
sendPushBeaRsp = httpClint.send(sendPushBearUrls, data=data)
|
|
||||||
if sendPushBeaRsp.get("code") is 0:
|
|
||||||
print(u"已下发 pushbear 微信通知, 请查收")
|
|
||||||
else:
|
|
||||||
print(sendPushBeaRsp)
|
|
||||||
except Exception as e:
|
|
||||||
print(u"pushbear 配置有误 {}".format(e))
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
sendPushBear(1)
|
|
@ -1,36 +0,0 @@
|
|||||||
# -*- coding: utf8 -*-
|
|
||||||
import TickerConfig
|
|
||||||
from config.urlConf import urls
|
|
||||||
from myUrllib.httpUtils import HTTPClient
|
|
||||||
|
|
||||||
PUSH_SERVER_CHAN_PATH = "https://sc.ftqq.com"
|
|
||||||
|
|
||||||
|
|
||||||
def sendServerChan(msg):
|
|
||||||
"""
|
|
||||||
pushBear微信通知
|
|
||||||
:param str: 通知内容 content
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if (
|
|
||||||
TickerConfig.SERVER_CHAN_CONF["is_server_chan"]
|
|
||||||
and TickerConfig.SERVER_CHAN_CONF["secret"].strip() != ""
|
|
||||||
):
|
|
||||||
try:
|
|
||||||
secret = TickerConfig.SERVER_CHAN_CONF["secret"].strip()
|
|
||||||
sendServerChanUrls = urls.get("ServerChan")
|
|
||||||
sendServerChanUrls["req_url"] += f'{secret}.send'
|
|
||||||
|
|
||||||
params = {"text": "易行购票成功通知", "desp": msg}
|
|
||||||
httpClint = HTTPClient(0)
|
|
||||||
sendServerChanRsp = httpClint.send(sendServerChanUrls, params=params)
|
|
||||||
if sendServerChanRsp.get("errno") == 0:
|
|
||||||
print(u"已下发 Server酱 微信通知, 请查收")
|
|
||||||
else:
|
|
||||||
print(sendServerChanRsp)
|
|
||||||
except Exception as e:
|
|
||||||
print(u"Server酱 配置有误 {}".format(e))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
sendServerChan(1)
|
|
@ -1,582 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
import random
|
|
||||||
import TickerConfig
|
|
||||||
import time
|
|
||||||
|
|
||||||
urls = {
|
|
||||||
"auth": { # 登录接口
|
|
||||||
"req_url": "/passport/web/auth/uamtk",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/resources/login.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
},
|
|
||||||
"uamtk-static": { # 登录接口
|
|
||||||
"req_url": "/passport/web/auth/uamtk-static",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/resources/login.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 3,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
},
|
|
||||||
"login": { # 登录接口
|
|
||||||
"req_url": "/passport/web/login",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/resources/login.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.5,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
|
|
||||||
},
|
|
||||||
"left_ticket_init": { # 登录接口
|
|
||||||
"req_url": "/otn/leftTicket/init",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/resources/login.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
|
|
||||||
},
|
|
||||||
"getCodeImg": { # 登录验证码
|
|
||||||
"req_url": "/passport/captcha/captcha-image?login_site=E&module=login&rand=sjrand&{0}",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/resources/login.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_json": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"not_decode": True,
|
|
||||||
},
|
|
||||||
"getCodeImg1": { # 登录验证码
|
|
||||||
"req_url": "/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand&{0}&callback=jQuery19108016482864806321_1554298927290&_=1554298927293",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/resources/login.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"codeCheck": { # 验证码校验
|
|
||||||
"req_url": "/passport/captcha/captcha-check",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/resources/login.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"codeCheck1": { # 验证码校验
|
|
||||||
"req_url": "/passport/captcha/captcha-check?callback=jQuery19108016482864806321_1554298927290&answer={0}&rand=sjrand&login_site=E&_={1}",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/resources/login.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"loginInit": { # 登录页面
|
|
||||||
"req_url": "/otn/login/init",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/index/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 1,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"loginInitCdn": { # 登录页面
|
|
||||||
"req_url": "/otn/login/init",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/index/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 1,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_test_cdn": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"loginInitCdn1": { # 登录页面
|
|
||||||
"req_url": "/otn/resources/login.html",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/view/index.html",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 1,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_test_cdn": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"getDevicesId": { # 获取用户信息
|
|
||||||
"req_url": "/otn/HttpZF/logdevice",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/passport?redirect=/otn/",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"getUserInfo": { # 获取用户信息
|
|
||||||
"req_url": "/otn/index/initMy12306",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/passport?redirect=/otn/login/userLogin",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"userLogin": { # 用户登录
|
|
||||||
"req_url": "/otn/login/userLogin",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/passport?redirect=/otn/login/userLogin",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"uamauthclient": { # 登录
|
|
||||||
"req_url": "/otn/uamauthclient",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/passport?redirect=/otn/login/userLogin",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"initdc_url": { # 生成订单页面
|
|
||||||
"req_url": "/otn/confirmPassenger/initDc",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.1,
|
|
||||||
"s_time": 1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"GetJS": { # 订单页面js
|
|
||||||
"req_url": "/otn/HttpZF/GetJS",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"odxmfwg": { # 订单页面js
|
|
||||||
"req_url": "/otn/dynamicJs/odxmfwg",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"get_passengerDTOs": { # 获取乘车人
|
|
||||||
"req_url": "/otn/confirmPassenger/getPassengerDTOs",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.1,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"select_url": { # 查询余票
|
|
||||||
"req_url": "/otn/{3}?leftTicketDTO.train_date={0}&leftTicketDTO.from_station={1}&leftTicketDTO.to_station={2}&purpose_codes=ADULT",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 1,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_json": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
},
|
|
||||||
"check_user_url": { # 检查用户登录
|
|
||||||
"req_url": "/otn/login/checkUser",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 1,
|
|
||||||
"re_time": 1,
|
|
||||||
"s_time": 1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"submit_station_url": { # 提交订单
|
|
||||||
"req_url": "/otn/leftTicket/submitOrderRequest",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"checkOrderInfoUrl": { # 检查订单信息规范
|
|
||||||
"req_url": "/otn/confirmPassenger/checkOrderInfo",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"getQueueCountUrl": { # 剩余余票数
|
|
||||||
"req_url": "/otn/confirmPassenger/getQueueCount",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"checkQueueOrderUrl": { # 订单队列排队
|
|
||||||
"req_url": "/otn/confirmPassenger/confirmSingleForQueue",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"checkRandCodeAnsyn": { # 暂时没用到
|
|
||||||
"req_url": "/otn/passcodeNew/checkRandCodeAnsyn",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"codeImgByOrder": { # 订单页面验证码
|
|
||||||
"req_url": "/otn/passcodeNew/getPassCodeNew?module=passenger&rand=randp&{}",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"queryOrderWaitTimeUrl": { # 订单等待页面
|
|
||||||
"req_url": "/otn/confirmPassenger/queryOrderWaitTime?random={0}&tourFlag=dc&_json_att=",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/confirmPassenger/initDc",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"queryMyOrderNoCompleteUrl": { # 订单查询页面
|
|
||||||
"req_url": "/otn/queryOrder/queryMyOrderNoComplete",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/queryOrder/initNoComplete",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"initNoCompleteUrl": { # 获取订单列表
|
|
||||||
"req_url": "/otn/queryOrder/initNoComplete",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/queryOrder/initNoComplete",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": False,
|
|
||||||
},
|
|
||||||
"cancelNoCompleteMyOrder": { # 取消订单
|
|
||||||
"req_url": "/otn/queryOrder/cancelNoCompleteMyOrder",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/queryOrder/initNoComplete",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"autoSubmitOrderRequest": { # 快速自动提交订单
|
|
||||||
"req_url": "/otn/confirmPassenger/autoSubmitOrderRequest",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"getQueueCountAsync": { # 快速获取订单数据
|
|
||||||
"req_url": "/otn/confirmPassenger/getQueueCountAsync",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"confirmSingleForQueueAsys": { # 快速订单排队
|
|
||||||
"req_url": "/otn/confirmPassenger/confirmSingleForQueueAsys",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"Pushbear": { # push通知
|
|
||||||
"req_url": "/sub",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"Host": "pushbear.ftqq.com",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": False,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"ServerChan": { # Server酱 push通知
|
|
||||||
"req_url": "/",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "",
|
|
||||||
"Content-Type": 1,
|
|
||||||
"Host": "sc.ftqq.com",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"loginHtml": { # 登录接口2
|
|
||||||
"req_url": "/otn/resources/login.html",
|
|
||||||
"req_type": "get",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.3,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"loginConf": { # 登录接口2
|
|
||||||
"req_url": "/otn/login/conf",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.3,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"loginAysnSuggest": { # 登录接口2
|
|
||||||
"req_url": "/otn/login/loginAysnSuggest",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.3,
|
|
||||||
"is_cdn": True,
|
|
||||||
"s_time": 0.1,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 候补订单接口
|
|
||||||
|
|
||||||
"chechFace": { # 人脸识别
|
|
||||||
"req_url": "/otn/afterNate/chechFace",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"getSuccessRate": { # 成功信息
|
|
||||||
"req_url": "/otn/afterNate/getSuccessRate",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"SubmitOrderRequestRsp": { # 提交候补订单准备
|
|
||||||
"req_url": "/otn/afterNate/submitOrderRequest",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"confirmHB": { # 设置订单信息
|
|
||||||
"req_url": "/otn/afterNate/confirmHB",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"queryQueue": { # 排队
|
|
||||||
"req_url": "/otn/afterNate/queryQueue",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
"passengerInitApi": { # 排队
|
|
||||||
"req_url": "/otn/afterNate/passengerInitApi",
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "https://kyfw.12306.cn/otn/leftTicket/init",
|
|
||||||
"Host": "kyfw.12306.cn",
|
|
||||||
"re_try": 10,
|
|
||||||
"re_time": 0.01,
|
|
||||||
"s_time": 0.01,
|
|
||||||
"is_cdn": True,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
},
|
|
||||||
|
|
||||||
"autoVerifyImage": { # 云打码接口
|
|
||||||
"req_url": TickerConfig.REQ_URL,
|
|
||||||
"req_type": "post",
|
|
||||||
"Referer": "",
|
|
||||||
"Host": TickerConfig.HOST,
|
|
||||||
"re_try": 6,
|
|
||||||
"re_time": 10,
|
|
||||||
"s_time": 0.001,
|
|
||||||
"is_logger": True,
|
|
||||||
"is_json": True,
|
|
||||||
"httpType": TickerConfig.HTTP_TYPE
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
services:
|
|
||||||
#抢票服务
|
|
||||||
ticket:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: ./Dockerfile37
|
|
||||||
image: ticket:v1.2.004
|
|
||||||
environment:
|
|
||||||
- PYTHONUNBUFFERED=1
|
|
||||||
- CAPTCHALOCAL=1
|
|
||||||
container_name: ticket
|
|
||||||
depends_on:
|
|
||||||
- captcha
|
|
||||||
networks:
|
|
||||||
- 12306network
|
|
||||||
restart: on-failure
|
|
||||||
#打码服务器
|
|
||||||
captcha:
|
|
||||||
image: yinaoxiong/12306_code_server:amd64 #请根据需要修改image
|
|
||||||
environment:
|
|
||||||
- WORKERS=1 #gunicorn works 默认为1可以根据服务器配置自行调整
|
|
||||||
- PYTHONUNBUFFERED=1
|
|
||||||
container_name: captcha
|
|
||||||
networks:
|
|
||||||
- 12306network
|
|
||||||
restart: unless-stopped
|
|
||||||
networks:
|
|
||||||
12306network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#author: MonsterTan
|
|
||||||
#date: 2019-01-15
|
|
||||||
#this is a script that can install automatically docker software by centos7
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function checkSudo (){
|
|
||||||
if [ $UID -ne 0 ];then
|
|
||||||
echo -e 'it must be root!'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
checkSudo
|
|
||||||
|
|
||||||
## something required system utils
|
|
||||||
yum install -y yum-utils device-mapper-persistent-data lvm2
|
|
||||||
|
|
||||||
|
|
||||||
## add repo source info
|
|
||||||
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
|
|
||||||
|
|
||||||
|
|
||||||
sudo yum mackecache fast
|
|
||||||
sudo yum -y install docker-ce
|
|
||||||
sudo systemctl start docker
|
|
||||||
|
|
||||||
|
|
||||||
str=successed!
|
|
||||||
if [ $? -eq 0 ];then
|
|
||||||
echo -e "\033[32msuccessed!\033[0m"
|
|
||||||
else
|
|
||||||
echo -e "\033[31msomething wrong, please check!\033[0m"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "\033[31mstart to install docker-compose\033[0m"
|
|
||||||
|
|
||||||
result=`ls /usr/bin/ | grep ^pip$`
|
|
||||||
if [ ${#result} -eq 0 ];then
|
|
||||||
echo -e "\033[31mpip must be necessary, it should be installed firstly\033[0m"
|
|
||||||
fi
|
|
||||||
|
|
||||||
sudo pip install docker-compose
|
|
||||||
|
|
@ -1,559 +0,0 @@
|
|||||||
111.161.122.240
|
|
||||||
112.90.135.96
|
|
||||||
60.9.0.19
|
|
||||||
61.162.100.102
|
|
||||||
222.186.141.146
|
|
||||||
221.235.187.129
|
|
||||||
58.221.78.231
|
|
||||||
113.16.212.251
|
|
||||||
112.47.27.131
|
|
||||||
112.123.33.18
|
|
||||||
183.134.42.18
|
|
||||||
116.77.75.133
|
|
||||||
112.90.135.97
|
|
||||||
58.221.78.42
|
|
||||||
61.162.100.103
|
|
||||||
111.161.122.67
|
|
||||||
60.9.0.20
|
|
||||||
113.16.212.48
|
|
||||||
112.47.56.174
|
|
||||||
112.28.196.75
|
|
||||||
183.134.42.19
|
|
||||||
116.77.75.137
|
|
||||||
112.90.135.98
|
|
||||||
113.16.212.49
|
|
||||||
36.250.248.220
|
|
||||||
60.9.0.21
|
|
||||||
116.199.127.56
|
|
||||||
221.235.187.130
|
|
||||||
112.47.27.172
|
|
||||||
112.90.135.99
|
|
||||||
183.134.42.190
|
|
||||||
60.9.0.22
|
|
||||||
222.186.141.165
|
|
||||||
116.77.75.138
|
|
||||||
36.102.230.136
|
|
||||||
112.47.56.117
|
|
||||||
183.134.42.191
|
|
||||||
60.9.0.23
|
|
||||||
116.77.75.145
|
|
||||||
36.102.230.137
|
|
||||||
222.186.141.166
|
|
||||||
58.221.78.46
|
|
||||||
61.162.100.107
|
|
||||||
116.77.75.144
|
|
||||||
113.207.77.252
|
|
||||||
60.9.0.252
|
|
||||||
222.186.141.178
|
|
||||||
183.134.42.20
|
|
||||||
61.167.54.55
|
|
||||||
58.221.78.47
|
|
||||||
221.180.208.54
|
|
||||||
116.77.75.169
|
|
||||||
61.162.100.252
|
|
||||||
222.186.141.186
|
|
||||||
60.9.0.254
|
|
||||||
113.207.79.17
|
|
||||||
183.134.42.247
|
|
||||||
61.167.54.57
|
|
||||||
111.161.22.17
|
|
||||||
116.77.75.146
|
|
||||||
58.221.78.48
|
|
||||||
61.162.100.41
|
|
||||||
111.6.176.208
|
|
||||||
113.207.79.34
|
|
||||||
36.250.248.222
|
|
||||||
36.102.230.19
|
|
||||||
183.134.53.153
|
|
||||||
116.77.75.147
|
|
||||||
61.162.100.44
|
|
||||||
111.6.176.209
|
|
||||||
113.207.79.42
|
|
||||||
183.134.53.155
|
|
||||||
116.77.75.170
|
|
||||||
36.102.230.20
|
|
||||||
120.221.64.161
|
|
||||||
222.218.87.252
|
|
||||||
111.6.176.248
|
|
||||||
113.207.79.37
|
|
||||||
120.221.64.169
|
|
||||||
112.47.56.118
|
|
||||||
111.6.176.25
|
|
||||||
113.194.59.80
|
|
||||||
124.236.28.100
|
|
||||||
113.207.81.126
|
|
||||||
111.6.176.94
|
|
||||||
111.6.176.95
|
|
||||||
113.194.59.199
|
|
||||||
221.235.187.220
|
|
||||||
124.236.28.252
|
|
||||||
221.235.187.244
|
|
||||||
111.6.176.97
|
|
||||||
124.236.28.67
|
|
||||||
113.194.59.81
|
|
||||||
120.221.64.53
|
|
||||||
36.250.248.252
|
|
||||||
120.221.64.54
|
|
||||||
124.236.28.247
|
|
||||||
36.250.248.254
|
|
||||||
120.221.64.55
|
|
||||||
124.236.28.69
|
|
||||||
116.77.75.183
|
|
||||||
36.250.248.27
|
|
||||||
221.235.187.66
|
|
||||||
183.134.53.223
|
|
||||||
124.236.28.68
|
|
||||||
113.207.81.78
|
|
||||||
58.20.179.253
|
|
||||||
27.195.145.121
|
|
||||||
221.235.187.90
|
|
||||||
113.207.81.81
|
|
||||||
27.195.145.123
|
|
||||||
221.235.187.98
|
|
||||||
123.128.14.254
|
|
||||||
183.134.53.248
|
|
||||||
111.161.22.62
|
|
||||||
123.128.14.69
|
|
||||||
124.236.28.93
|
|
||||||
117.169.93.249
|
|
||||||
183.146.22.135
|
|
||||||
125.39.1.134
|
|
||||||
36.102.230.254
|
|
||||||
124.236.28.92
|
|
||||||
117.169.93.85
|
|
||||||
27.195.145.249
|
|
||||||
125.39.1.191
|
|
||||||
124.236.28.94
|
|
||||||
42.81.144.179
|
|
||||||
222.218.87.28
|
|
||||||
27.195.145.52
|
|
||||||
124.236.28.95
|
|
||||||
36.250.248.56
|
|
||||||
222.218.87.29
|
|
||||||
42.81.144.180
|
|
||||||
27.195.145.62
|
|
||||||
36.159.115.250
|
|
||||||
36.159.115.88
|
|
||||||
36.159.115.89
|
|
||||||
183.146.22.137
|
|
||||||
110.242.21.24
|
|
||||||
124.236.28.98
|
|
||||||
117.169.93.86
|
|
||||||
123.128.14.70
|
|
||||||
110.242.21.23
|
|
||||||
124.236.28.99
|
|
||||||
117.23.2.252
|
|
||||||
123.128.14.72
|
|
||||||
112.28.196.54
|
|
||||||
110.242.21.254
|
|
||||||
117.149.154.185
|
|
||||||
58.20.179.74
|
|
||||||
150.138.111.251
|
|
||||||
117.23.2.28
|
|
||||||
110.242.21.243
|
|
||||||
117.149.154.186
|
|
||||||
58.20.179.73
|
|
||||||
150.138.111.31
|
|
||||||
110.242.21.41
|
|
||||||
117.23.2.29
|
|
||||||
111.47.220.251
|
|
||||||
150.138.111.32
|
|
||||||
110.242.21.71
|
|
||||||
106.41.0.37
|
|
||||||
111.47.220.66
|
|
||||||
110.242.21.70
|
|
||||||
150.138.111.33
|
|
||||||
111.47.220.67
|
|
||||||
106.41.0.44
|
|
||||||
150.138.167.234
|
|
||||||
150.138.167.50
|
|
||||||
106.41.0.45
|
|
||||||
222.186.145.51
|
|
||||||
150.138.167.52
|
|
||||||
111.62.194.30
|
|
||||||
106.41.0.46
|
|
||||||
122.228.237.248
|
|
||||||
42.81.144.31
|
|
||||||
150.138.169.120
|
|
||||||
222.186.145.54
|
|
||||||
59.56.30.51
|
|
||||||
106.41.0.47
|
|
||||||
42.81.144.39
|
|
||||||
111.62.194.31
|
|
||||||
222.44.151.24
|
|
||||||
150.138.169.121
|
|
||||||
112.28.196.251
|
|
||||||
106.41.0.61
|
|
||||||
111.62.194.254
|
|
||||||
123.138.157.85
|
|
||||||
106.120.178.19
|
|
||||||
150.138.167.51
|
|
||||||
150.138.169.123
|
|
||||||
112.28.196.249
|
|
||||||
106.41.0.62
|
|
||||||
120.253.100.20
|
|
||||||
114.112.172.58
|
|
||||||
123.138.157.122
|
|
||||||
150.138.169.124
|
|
||||||
183.146.22.145
|
|
||||||
112.28.196.53
|
|
||||||
120.253.100.21
|
|
||||||
222.44.151.191
|
|
||||||
183.146.22.146
|
|
||||||
125.77.147.254
|
|
||||||
112.28.196.74
|
|
||||||
120.253.100.22
|
|
||||||
222.44.151.25
|
|
||||||
222.186.145.52
|
|
||||||
120.253.100.23
|
|
||||||
61.151.238.197
|
|
||||||
120.253.100.30
|
|
||||||
61.151.238.222
|
|
||||||
61.151.238.229
|
|
||||||
117.149.155.148
|
|
||||||
117.149.155.147
|
|
||||||
183.146.22.171
|
|
||||||
150.138.169.238
|
|
||||||
60.210.23.26
|
|
||||||
125.77.147.68
|
|
||||||
221.235.187.119
|
|
||||||
125.77.147.69
|
|
||||||
115.157.63.19
|
|
||||||
117.149.155.76
|
|
||||||
115.157.63.49
|
|
||||||
122.224.186.221
|
|
||||||
183.201.225.249
|
|
||||||
119.52.120.138
|
|
||||||
60.28.100.155
|
|
||||||
125.77.147.80
|
|
||||||
122.70.142.148
|
|
||||||
122.224.186.222
|
|
||||||
119.52.120.139
|
|
||||||
60.28.100.156
|
|
||||||
122.70.142.147
|
|
||||||
125.77.147.82
|
|
||||||
122.224.186.225
|
|
||||||
60.28.100.157
|
|
||||||
119.52.120.140
|
|
||||||
125.77.147.88
|
|
||||||
114.112.172.57
|
|
||||||
122.224.186.226
|
|
||||||
60.28.100.158
|
|
||||||
150.138.214.84
|
|
||||||
119.52.120.144
|
|
||||||
58.216.21.250
|
|
||||||
60.28.100.248
|
|
||||||
119.52.120.145
|
|
||||||
150.138.214.124
|
|
||||||
60.210.23.116
|
|
||||||
183.66.109.254
|
|
||||||
117.180.229.254
|
|
||||||
150.138.214.85
|
|
||||||
119.52.120.146
|
|
||||||
61.147.226.46
|
|
||||||
115.157.63.50
|
|
||||||
122.224.186.253
|
|
||||||
58.216.22.17
|
|
||||||
150.138.214.86
|
|
||||||
222.186.145.53
|
|
||||||
117.180.229.142
|
|
||||||
58.216.22.20
|
|
||||||
183.222.97.164
|
|
||||||
61.147.226.48
|
|
||||||
58.216.22.22
|
|
||||||
183.222.97.165
|
|
||||||
122.224.186.223
|
|
||||||
183.66.109.44
|
|
||||||
58.216.22.56
|
|
||||||
183.222.97.166
|
|
||||||
60.210.23.29
|
|
||||||
221.235.187.67
|
|
||||||
183.66.109.45
|
|
||||||
115.157.63.51
|
|
||||||
183.222.97.254
|
|
||||||
183.146.22.142
|
|
||||||
183.146.22.139
|
|
||||||
120.226.55.144
|
|
||||||
221.235.187.121
|
|
||||||
153.99.235.112
|
|
||||||
120.226.55.151
|
|
||||||
120.226.55.254
|
|
||||||
112.240.60.213
|
|
||||||
36.25.241.75
|
|
||||||
122.225.83.25
|
|
||||||
153.99.235.91
|
|
||||||
112.240.60.214
|
|
||||||
122.225.83.28
|
|
||||||
115.157.63.52
|
|
||||||
36.25.241.76
|
|
||||||
121.22.247.202
|
|
||||||
114.112.172.59
|
|
||||||
122.228.237.74
|
|
||||||
36.25.241.77
|
|
||||||
112.240.60.215
|
|
||||||
121.22.247.204
|
|
||||||
223.111.18.161
|
|
||||||
122.228.237.75
|
|
||||||
112.240.60.216
|
|
||||||
121.22.247.254
|
|
||||||
218.26.75.149
|
|
||||||
223.111.18.162
|
|
||||||
122.228.237.76
|
|
||||||
112.240.60.217
|
|
||||||
115.157.63.62
|
|
||||||
218.26.75.150
|
|
||||||
223.111.18.163
|
|
||||||
122.225.83.26
|
|
||||||
122.228.239.233
|
|
||||||
112.240.60.222
|
|
||||||
223.111.18.217
|
|
||||||
218.26.75.151
|
|
||||||
222.186.145.251
|
|
||||||
122.228.239.234
|
|
||||||
112.240.60.236
|
|
||||||
218.26.75.152
|
|
||||||
116.207.132.183
|
|
||||||
122.228.239.235
|
|
||||||
61.147.227.53
|
|
||||||
159.226.225.149
|
|
||||||
218.26.75.153
|
|
||||||
116.207.132.184
|
|
||||||
122.228.239.236
|
|
||||||
116.207.132.253
|
|
||||||
218.26.75.206
|
|
||||||
113.207.10.204
|
|
||||||
122.228.239.238
|
|
||||||
218.26.75.236
|
|
||||||
113.207.10.218
|
|
||||||
122.228.239.243
|
|
||||||
122.228.239.244
|
|
||||||
122.228.239.246
|
|
||||||
139.209.49.140
|
|
||||||
183.131.124.38
|
|
||||||
159.226.225.154
|
|
||||||
139.209.49.138
|
|
||||||
121.22.247.203
|
|
||||||
139.209.49.144
|
|
||||||
123.53.139.253
|
|
||||||
139.209.49.151
|
|
||||||
125.74.58.134
|
|
||||||
139.209.49.152
|
|
||||||
123.53.139.36
|
|
||||||
125.74.58.135
|
|
||||||
125.74.58.136
|
|
||||||
139.209.49.153
|
|
||||||
123.184.108.251
|
|
||||||
210.38.3.23
|
|
||||||
183.131.124.40
|
|
||||||
123.184.108.60
|
|
||||||
123.184.108.61
|
|
||||||
210.38.3.24
|
|
||||||
159.226.225.139
|
|
||||||
183.131.124.58
|
|
||||||
125.74.58.254
|
|
||||||
210.38.3.42
|
|
||||||
159.226.225.140
|
|
||||||
61.54.7.158
|
|
||||||
124.95.148.254
|
|
||||||
183.131.124.59
|
|
||||||
61.54.7.174
|
|
||||||
210.38.3.49
|
|
||||||
124.95.148.30
|
|
||||||
101.69.146.234
|
|
||||||
210.38.3.50
|
|
||||||
61.54.7.179
|
|
||||||
124.95.148.29
|
|
||||||
14.204.185.100
|
|
||||||
210.38.3.60
|
|
||||||
61.54.7.243
|
|
||||||
60.220.196.220
|
|
||||||
124.95.148.31
|
|
||||||
14.204.185.101
|
|
||||||
60.220.196.221
|
|
||||||
59.83.232.18
|
|
||||||
14.204.185.102
|
|
||||||
59.83.232.50
|
|
||||||
61.147.210.193
|
|
||||||
122.70.142.252
|
|
||||||
14.204.185.123
|
|
||||||
61.147.210.195
|
|
||||||
14.204.185.254
|
|
||||||
223.111.198.252
|
|
||||||
61.147.226.185
|
|
||||||
101.69.146.33
|
|
||||||
223.111.198.65
|
|
||||||
113.207.70.194
|
|
||||||
61.147.210.242
|
|
||||||
113.207.70.207
|
|
||||||
101.69.146.35
|
|
||||||
60.210.23.23
|
|
||||||
61.147.226.47
|
|
||||||
113.207.70.208
|
|
||||||
101.69.146.34
|
|
||||||
60.210.23.25
|
|
||||||
61.147.226.49
|
|
||||||
183.131.168.148
|
|
||||||
60.210.23.27
|
|
||||||
61.147.227.102
|
|
||||||
113.207.72.102
|
|
||||||
60.213.21.117
|
|
||||||
58.220.71.253
|
|
||||||
61.147.227.126
|
|
||||||
58.220.71.51
|
|
||||||
60.213.21.118
|
|
||||||
14.204.185.91
|
|
||||||
58.220.71.52
|
|
||||||
113.207.70.209
|
|
||||||
60.213.21.156
|
|
||||||
113.207.77.117
|
|
||||||
60.213.21.214
|
|
||||||
60.220.196.250
|
|
||||||
58.220.71.62
|
|
||||||
116.199.127.50
|
|
||||||
60.213.21.244
|
|
||||||
58.220.71.63
|
|
||||||
118.123.233.254
|
|
||||||
116.199.127.54
|
|
||||||
218.29.198.43
|
|
||||||
58.220.71.64
|
|
||||||
60.213.21.243
|
|
||||||
118.123.233.30
|
|
||||||
218.29.198.62
|
|
||||||
116.77.73.164
|
|
||||||
103.254.189.230
|
|
||||||
58.220.71.65
|
|
||||||
60.213.21.245
|
|
||||||
118.123.233.31
|
|
||||||
223.86.219.254
|
|
||||||
183.214.132.120
|
|
||||||
60.213.21.252
|
|
||||||
223.86.219.65
|
|
||||||
183.214.132.16
|
|
||||||
116.199.127.55
|
|
||||||
223.86.219.66
|
|
||||||
183.214.132.17
|
|
||||||
60.255.143.93
|
|
||||||
61.149.9.150
|
|
||||||
60.255.143.94
|
|
||||||
60.255.143.95
|
|
||||||
60.255.143.96
|
|
||||||
36.250.233.185
|
|
||||||
106.40.140.224
|
|
||||||
36.250.233.208
|
|
||||||
61.147.228.201
|
|
||||||
36.250.233.209
|
|
||||||
183.214.140.204
|
|
||||||
123.53.139.37
|
|
||||||
222.24.122.86
|
|
||||||
61.147.228.60
|
|
||||||
36.250.233.210
|
|
||||||
106.40.140.254
|
|
||||||
183.214.140.238
|
|
||||||
36.250.233.214
|
|
||||||
36.250.233.228
|
|
||||||
58.221.78.186
|
|
||||||
36.250.248.218
|
|
||||||
218.12.228.246
|
|
||||||
112.90.135.244
|
|
||||||
222.24.122.89
|
|
||||||
36.250.248.217
|
|
||||||
221.235.187.106
|
|
||||||
218.12.228.38
|
|
||||||
36.250.233.254
|
|
||||||
112.47.20.250
|
|
||||||
218.12.228.39
|
|
||||||
112.90.135.92
|
|
||||||
117.27.245.227
|
|
||||||
112.90.135.93
|
|
||||||
117.27.245.254
|
|
||||||
117.27.245.52
|
|
||||||
112.90.135.94
|
|
||||||
117.27.245.97
|
|
||||||
112.90.135.95
|
|
||||||
117.27.245.54
|
|
||||||
218.60.185.251
|
|
||||||
113.5.80.33
|
|
||||||
125.77.130.247
|
|
||||||
218.60.185.46
|
|
||||||
125.77.130.251
|
|
||||||
118.203.202.206
|
|
||||||
118.203.202.207
|
|
||||||
218.60.185.47
|
|
||||||
218.60.185.48
|
|
||||||
118.203.202.208
|
|
||||||
118.203.202.209
|
|
||||||
118.203.202.222
|
|
||||||
221.180.192.100
|
|
||||||
125.77.130.46
|
|
||||||
125.77.130.47
|
|
||||||
112.47.20.68
|
|
||||||
125.77.130.48
|
|
||||||
163.177.132.27
|
|
||||||
112.47.27.132
|
|
||||||
125.77.130.49
|
|
||||||
112.47.20.89
|
|
||||||
61.147.228.89
|
|
||||||
112.47.20.79
|
|
||||||
106.120.178.253
|
|
||||||
221.180.192.254
|
|
||||||
221.230.141.170
|
|
||||||
221.180.192.61
|
|
||||||
106.120.178.20
|
|
||||||
163.177.132.30
|
|
||||||
183.216.176.74
|
|
||||||
221.230.141.172
|
|
||||||
183.216.176.75
|
|
||||||
221.230.141.174
|
|
||||||
110.19.204.219
|
|
||||||
110.19.204.220
|
|
||||||
219.138.27.108
|
|
||||||
110.19.204.221
|
|
||||||
219.138.27.249
|
|
||||||
103.254.189.229
|
|
||||||
106.120.178.22
|
|
||||||
219.138.27.30
|
|
||||||
219.138.27.31
|
|
||||||
113.16.208.251
|
|
||||||
222.186.141.132
|
|
||||||
113.16.208.77
|
|
||||||
113.16.208.78
|
|
||||||
222.186.141.141
|
|
||||||
110.19.204.254
|
|
||||||
222.186.141.142
|
|
||||||
221.180.208.252
|
|
||||||
222.186.141.143
|
|
||||||
117.161.19.126
|
|
||||||
221.180.208.46
|
|
||||||
222.186.141.145
|
|
||||||
60.9.0.18
|
|
||||||
117.161.19.19
|
|
||||||
221.180.208.47
|
|
||||||
117.161.19.22
|
|
||||||
113.142.80.223
|
|
||||||
183.134.42.153
|
|
||||||
183.134.42.154
|
|
||||||
183.134.42.155
|
|
||||||
115.223.24.254
|
|
||||||
183.134.42.156
|
|
||||||
111.161.122.100
|
|
||||||
183.134.42.157
|
|
||||||
61.136.167.17
|
|
||||||
183.134.42.158
|
|
||||||
61.136.167.18
|
|
||||||
183.134.42.159
|
|
||||||
113.142.80.69
|
|
||||||
183.134.42.17
|
|
||||||
113.142.80.71
|
|
||||||
61.136.167.19
|
|
||||||
113.142.80.72
|
|
||||||
115.223.24.80
|
|
||||||
111.161.122.133
|
|
||||||
115.223.24.81
|
|
||||||
111.161.122.134
|
|
||||||
115.223.24.82
|
|
||||||
111.161.122.135
|
|
||||||
114.112.172.56
|
|
||||||
222.74.113.196
|
|
||||||
222.74.113.219
|
|
||||||
61.167.54.236
|
|
||||||
61.167.54.242
|
|
@ -1,136 +0,0 @@
|
|||||||
# -*- coding=utf-8 -*-
|
|
||||||
import copy
|
|
||||||
import time
|
|
||||||
from collections import OrderedDict
|
|
||||||
from time import sleep
|
|
||||||
import TickerConfig
|
|
||||||
from inter.GetPassCodeNewOrderAndLogin import getPassCodeNewOrderAndLogin1
|
|
||||||
from inter.GetRandCode import getRandCode
|
|
||||||
from inter.LoginAysnSuggest import loginAysnSuggest
|
|
||||||
from inter.LoginConf import loginConf
|
|
||||||
from myException.UserPasswordException import UserPasswordException
|
|
||||||
|
|
||||||
|
|
||||||
class GoLogin:
|
|
||||||
def __init__(self, session, is_auto_code, auto_code_type):
|
|
||||||
self.session = session
|
|
||||||
self.randCode = ""
|
|
||||||
self.is_auto_code = is_auto_code
|
|
||||||
self.auto_code_type = auto_code_type
|
|
||||||
|
|
||||||
def auth(self):
|
|
||||||
"""
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
self.session.httpClint.send(self.session.urls["loginInitCdn1"])
|
|
||||||
uamtkStaticUrl = self.session.urls["uamtk-static"]
|
|
||||||
uamtkStaticData = {"appid": "otn"}
|
|
||||||
return self.session.httpClint.send(uamtkStaticUrl, uamtkStaticData)
|
|
||||||
|
|
||||||
def codeCheck(self):
|
|
||||||
"""
|
|
||||||
验证码校验
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
codeCheckUrl = copy.deepcopy(self.session.urls["codeCheck1"])
|
|
||||||
codeCheckUrl["req_url"] = codeCheckUrl["req_url"].format(self.randCode, int(time.time() * 1000))
|
|
||||||
fresult = self.session.httpClint.send(codeCheckUrl)
|
|
||||||
if not isinstance(fresult, str):
|
|
||||||
print("登录失败")
|
|
||||||
return
|
|
||||||
fresult = eval(fresult.split("(")[1].split(")")[0])
|
|
||||||
if "result_code" in fresult and fresult["result_code"] == "4":
|
|
||||||
print(u"验证码通过,开始登录..")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
if "result_message" in fresult:
|
|
||||||
print(fresult["result_message"])
|
|
||||||
sleep(1)
|
|
||||||
self.session.httpClint.del_cookies()
|
|
||||||
|
|
||||||
def baseLogin(self, user, passwd):
|
|
||||||
"""
|
|
||||||
登录过程
|
|
||||||
:param user:
|
|
||||||
:param passwd:
|
|
||||||
:return: 权限校验码
|
|
||||||
"""
|
|
||||||
logurl = self.session.urls["login"]
|
|
||||||
|
|
||||||
loginData = OrderedDict()
|
|
||||||
loginData["username"] = user,
|
|
||||||
loginData["password"] = passwd,
|
|
||||||
loginData["appid"] = "otn",
|
|
||||||
loginData["answer"] = self.randCode,
|
|
||||||
|
|
||||||
tresult = self.session.httpClint.send(logurl, loginData)
|
|
||||||
if 'result_code' in tresult and tresult["result_code"] == 0:
|
|
||||||
print(u"登录成功")
|
|
||||||
tk = self.auth()
|
|
||||||
if "newapptk" in tk and tk["newapptk"]:
|
|
||||||
return tk["newapptk"]
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
elif 'result_message' in tresult and tresult['result_message']:
|
|
||||||
messages = tresult['result_message']
|
|
||||||
if messages.find(u"密码输入错误") is not -1:
|
|
||||||
raise UserPasswordException("{0}".format(messages))
|
|
||||||
else:
|
|
||||||
print(u"登录失败: {0}".format(messages))
|
|
||||||
print(u"尝试重新登陆")
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def getUserName(self, uamtk):
|
|
||||||
"""
|
|
||||||
登录成功后,显示用户名
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if not uamtk:
|
|
||||||
return u"权限校验码不能为空"
|
|
||||||
else:
|
|
||||||
uamauthclientUrl = self.session.urls["uamauthclient"]
|
|
||||||
data = {"tk": uamtk}
|
|
||||||
uamauthclientResult = self.session.httpClint.send(uamauthclientUrl, data)
|
|
||||||
if uamauthclientResult:
|
|
||||||
if "result_code" in uamauthclientResult and uamauthclientResult["result_code"] == 0:
|
|
||||||
print(u"欢迎 {} 登录".format(uamauthclientResult["username"]))
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
self.session.httpClint.send(uamauthclientUrl, data)
|
|
||||||
url = self.session.urls["getUserInfo"]
|
|
||||||
self.session.httpClint.send(url)
|
|
||||||
|
|
||||||
def go_login(self):
|
|
||||||
"""
|
|
||||||
登陆
|
|
||||||
:param user: 账户名
|
|
||||||
:param passwd: 密码
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
user, passwd = TickerConfig.USER, TickerConfig.PWD
|
|
||||||
if not user or not passwd:
|
|
||||||
raise UserPasswordException(u"温馨提示: 用户名或者密码为空,请仔细检查")
|
|
||||||
login_num = 0
|
|
||||||
while True:
|
|
||||||
if loginConf(self.session):
|
|
||||||
|
|
||||||
result = getPassCodeNewOrderAndLogin1(session=self.session, imgType="login")
|
|
||||||
if not result:
|
|
||||||
continue
|
|
||||||
self.randCode = getRandCode(self.is_auto_code, self.auto_code_type, result)
|
|
||||||
print(self.randCode)
|
|
||||||
login_num += 1
|
|
||||||
self.auth()
|
|
||||||
if self.codeCheck():
|
|
||||||
uamtk = self.baseLogin(user, passwd)
|
|
||||||
if uamtk:
|
|
||||||
self.getUserName(uamtk)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
loginAysnSuggest(self.session, username=user, password=passwd)
|
|
||||||
login_num += 1
|
|
||||||
break
|
|
@ -1,27 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
class checkRandCodeAnsyn:
|
|
||||||
def __init__(self, session, randCode, token):
|
|
||||||
self.session = session
|
|
||||||
self.randCode = randCode
|
|
||||||
self.token = token
|
|
||||||
|
|
||||||
def data_par(self):
|
|
||||||
"""
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
data = {
|
|
||||||
"randCode": self.randCode,
|
|
||||||
"rand": "randp",
|
|
||||||
"_json_att": "",
|
|
||||||
"REPEAT_SUBMIT_TOKEN": self.token
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
|
|
||||||
def sendCheckRandCodeAnsyn(self):
|
|
||||||
"""
|
|
||||||
下单验证码识别
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
checkRandCodeAnsynUrl = self.session.urls["checkRandCodeAnsyn"]
|
|
||||||
fresult = self.session.httpClint.send(checkRandCodeAnsynUrl, self.data_par()) # 校验验证码是否正确
|
|
||||||
return fresult['data']['msg']
|
|
@ -1,39 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
import datetime
|
|
||||||
import random
|
|
||||||
import time
|
|
||||||
import wrapcache
|
|
||||||
from config import configCommon
|
|
||||||
from config.TicketEnmu import ticket
|
|
||||||
|
|
||||||
|
|
||||||
class checkUser:
|
|
||||||
def __init__(self, session):
|
|
||||||
self.session = session
|
|
||||||
|
|
||||||
def sendCheckUser(self):
|
|
||||||
"""
|
|
||||||
检查用户登录, 检查间隔为2分钟
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
CHENK_TIME = 1
|
|
||||||
while 1:
|
|
||||||
time.sleep(3) # 防止cpu占用过高
|
|
||||||
configCommon.checkSleepTime(self.session) # 修复晚上查询线程休眠时,检查登录线程为休眠,造成快豆迅速消耗
|
|
||||||
if wrapcache.get("user_time") is None:
|
|
||||||
check_user_url = self.session.urls["check_user_url"]
|
|
||||||
data = {"_json_att": ""}
|
|
||||||
check_user = self.session.httpClint.send(check_user_url, data)
|
|
||||||
if check_user.get("data", False):
|
|
||||||
check_user_flag = check_user["data"]["flag"]
|
|
||||||
if check_user_flag is True:
|
|
||||||
wrapcache.set("user_time", datetime.datetime.now(), timeout=random.randint(60, 80) * CHENK_TIME)
|
|
||||||
else:
|
|
||||||
if check_user['messages']:
|
|
||||||
print(ticket.LOGIN_SESSION_FAIL.format(check_user['messages']))
|
|
||||||
self.session.call_login()
|
|
||||||
wrapcache.set("user_time", datetime.datetime.now(), timeout=random.randint(60, 80) * CHENK_TIME)
|
|
||||||
else:
|
|
||||||
print(ticket.LOGIN_SESSION_FAIL.format(check_user['messages']))
|
|
||||||
self.session.call_login()
|
|
||||||
wrapcache.set("user_time", datetime.datetime.now(), timeout=random.randint(60, 80) * CHENK_TIME)
|
|
@ -1,48 +0,0 @@
|
|||||||
from collections import OrderedDict
|
|
||||||
from config.urlConf import urls
|
|
||||||
import TickerConfig
|
|
||||||
from inter.GetQueueCount import queryQueueByAfterNate
|
|
||||||
|
|
||||||
|
|
||||||
class confirmHB:
|
|
||||||
def __init__(self, secretList, session, tickerNo, jzdhDate):
|
|
||||||
"""
|
|
||||||
人脸识别
|
|
||||||
"""
|
|
||||||
self.secretList = secretList
|
|
||||||
self.session = session
|
|
||||||
self.passengerTicketStrByAfterLate = session.passengerTicketStrByAfterLate
|
|
||||||
self.tickerNo = tickerNo
|
|
||||||
self.jzdhDate = jzdhDate
|
|
||||||
|
|
||||||
def data_apr(self):
|
|
||||||
"""
|
|
||||||
passengerInfo 1#XXXX#1#***************77X#bf6ae40d3655ae7eff005ee21d95876b38ab97a8031b464bc2f74a067e3ec957;
|
|
||||||
jzParam 2019-08-31#19#00
|
|
||||||
hbTrain 5l000G177230,O#
|
|
||||||
lkParam
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
ticker = TickerConfig.PASSENGER_TICKER_STR.get(TickerConfig.SET_TYPE[0])
|
|
||||||
data = OrderedDict()
|
|
||||||
data["passengerInfo"] = self.passengerTicketStrByAfterLate
|
|
||||||
data["jzParam"] = self.jzdhDate
|
|
||||||
data["hbTrain"] = f"{self.tickerNo},{ticker}#"
|
|
||||||
data["lkParam"] = ""
|
|
||||||
return data
|
|
||||||
|
|
||||||
def sendChechFace(self):
|
|
||||||
ChechFaceRsp = self.session.httpClint.send(urls.get("confirmHB"), self.data_apr())
|
|
||||||
if not ChechFaceRsp.get("status"):
|
|
||||||
print("".join(ChechFaceRsp.get("messages")) or ChechFaceRsp.get("validateMessages"))
|
|
||||||
return
|
|
||||||
data = ChechFaceRsp.get("data")
|
|
||||||
if not data.get("flag"):
|
|
||||||
print(f"错误信息:{data.get('msg')}")
|
|
||||||
return
|
|
||||||
queue = queryQueueByAfterNate(self.session)
|
|
||||||
queue.sendQueryQueueByAfterNate()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
import json
|
|
||||||
import urllib
|
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
from inter.QueryOrderWaitTime import queryOrderWaitTime
|
|
||||||
|
|
||||||
|
|
||||||
class confirmSingleForQueueAsys:
|
|
||||||
"""
|
|
||||||
订单快读排队
|
|
||||||
"""
|
|
||||||
def __init__(self,
|
|
||||||
session,
|
|
||||||
passengerTicketStr,
|
|
||||||
oldPassengerStr,
|
|
||||||
result,
|
|
||||||
randCode="",
|
|
||||||
):
|
|
||||||
self.session = session
|
|
||||||
self.passengerTicketStr = passengerTicketStr
|
|
||||||
self.oldPassengerStr = oldPassengerStr
|
|
||||||
self.result = result if isinstance(result, str) else str(result)
|
|
||||||
self.randCode = randCode
|
|
||||||
|
|
||||||
def data_par(self):
|
|
||||||
"""
|
|
||||||
字段说明
|
|
||||||
passengerTicketStr 乘客乘车代码
|
|
||||||
oldPassengerStr 乘客编号代码
|
|
||||||
randCode 填空
|
|
||||||
purpose_codes 学生还是成人
|
|
||||||
key_check_isChange autoSubmitOrderRequest返回的result字段做切割即可
|
|
||||||
leftTicketStr autoSubmitOrderRequest返回的result字段做切割即可
|
|
||||||
train_location autoSubmitOrderRequest返回的result字段做切割即可
|
|
||||||
choose_seats
|
|
||||||
seatDetailType
|
|
||||||
_json_att
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
results = self.result.split("#")
|
|
||||||
key_check_isChange = results[1]
|
|
||||||
leftTicketStr = results[2]
|
|
||||||
train_location = results[0]
|
|
||||||
data = OrderedDict()
|
|
||||||
data["passengerTicketStr"] = self.passengerTicketStr
|
|
||||||
data["oldPassengerStr"] = self.oldPassengerStr
|
|
||||||
data["randCode"] = self.randCode
|
|
||||||
data["purpose_codes"] = "ADULT"
|
|
||||||
data["key_check_isChange"] = key_check_isChange
|
|
||||||
data["leftTicketStr"] = leftTicketStr
|
|
||||||
data["train_location"] = train_location
|
|
||||||
data["choose_seats"] = ""
|
|
||||||
data["seatDetailType"] = ""
|
|
||||||
data["_json_att"] = ""
|
|
||||||
return data
|
|
||||||
|
|
||||||
def sendConfirmSingleForQueueAsys(self):
|
|
||||||
"""
|
|
||||||
请求订单快读排队接口
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
urls = self.session.urls["confirmSingleForQueueAsys"]
|
|
||||||
data = self.data_par()
|
|
||||||
confirmSingleForQueueAsysResult = self.session.httpClint.send(urls, data)
|
|
||||||
if confirmSingleForQueueAsysResult.get("status", False) and confirmSingleForQueueAsysResult.get("data", False):
|
|
||||||
queueData = confirmSingleForQueueAsysResult.get("data", {})
|
|
||||||
if queueData.get("submitStatus", False):
|
|
||||||
qwt = queryOrderWaitTime(session=self.session)
|
|
||||||
qwt.sendQueryOrderWaitTime()
|
|
||||||
else:
|
|
||||||
print(queueData.get("errMsg", ""))
|
|
@ -1,36 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
import json
|
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class getRepeatSubmitToken:
|
|
||||||
def __init__(self, session):
|
|
||||||
self.session = session
|
|
||||||
|
|
||||||
def sendGetRepeatSubmitToken(self):
|
|
||||||
"""
|
|
||||||
获取提交车票请求token
|
|
||||||
:return: token
|
|
||||||
"""
|
|
||||||
initdc_url = self.session.urls["initdc_url"]
|
|
||||||
initdc_result = self.session.httpClint.send(initdc_url, )
|
|
||||||
token_name = re.compile(r"var globalRepeatSubmitToken = '(\S+)'")
|
|
||||||
ticketInfoForPassengerForm_name = re.compile(r'var ticketInfoForPassengerForm=(\{.+\})?')
|
|
||||||
order_request_params_name = re.compile(r'var orderRequestDTO=(\{.+\})?')
|
|
||||||
token = re.search(token_name, initdc_result).group(1)
|
|
||||||
re_tfpf = re.findall(ticketInfoForPassengerForm_name, initdc_result)
|
|
||||||
re_orp = re.findall(order_request_params_name, initdc_result)
|
|
||||||
if re_tfpf:
|
|
||||||
ticketInfoForPassengerForm = json.loads(re_tfpf[0].replace("'", '"'))
|
|
||||||
else:
|
|
||||||
ticketInfoForPassengerForm = ""
|
|
||||||
if re_orp:
|
|
||||||
order_request_params = json.loads(re_orp[0].replace("'", '"'))
|
|
||||||
else:
|
|
||||||
order_request_params = ""
|
|
||||||
return {
|
|
||||||
"token": token,
|
|
||||||
"ticketInfoForPassengerForm": ticketInfoForPassengerForm,
|
|
||||||
"order_request_params": order_request_params,
|
|
||||||
"session": self.session
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
from config.urlConf import urls
|
|
||||||
|
|
||||||
|
|
||||||
def loginAysnSuggest(session, username, password):
|
|
||||||
"""
|
|
||||||
登录接口
|
|
||||||
ps: 不需要验证码
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
loginAysnSuggestUrls = urls.get("loginAysnSuggest")
|
|
||||||
data = {
|
|
||||||
"loginUserDTO.user_name": username,
|
|
||||||
"userDTO.password": password
|
|
||||||
}
|
|
||||||
loginAysnSuggestRsp = session.httpClint.send(urls=loginAysnSuggestUrls, data=data)
|
|
||||||
if loginAysnSuggestRsp and loginAysnSuggestRsp.get("httpstatus") is 200 and loginAysnSuggestRsp.get("data", {}).get("loginCheck") == "Y":
|
|
||||||
print(u"登录成功")
|
|
||||||
else:
|
|
||||||
print(u"登录失败, {0} {1}".format("".join(loginAysnSuggestRsp.get("messages")), loginAysnSuggestRsp.get("validateMessages")))
|
|
@ -1,22 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
from config.urlConf import urls
|
|
||||||
|
|
||||||
|
|
||||||
def loginConf(session):
|
|
||||||
"""
|
|
||||||
判断登录是否需要验证码
|
|
||||||
:param session:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
loginConfUrl = urls.get("loginConf")
|
|
||||||
loginConfRsp = session.httpClint.send(urls=loginConfUrl, data={})
|
|
||||||
if loginConfRsp and loginConfRsp.get("data", {}).get("is_login_passCode") == "N":
|
|
||||||
print(u"不需要验证码")
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
print(u"需要验证码")
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
pass
|
|
@ -1,37 +0,0 @@
|
|||||||
import datetime
|
|
||||||
import wrapcache
|
|
||||||
import TickerConfig
|
|
||||||
from config.urlConf import urls
|
|
||||||
from inter.ConfirmHB import confirmHB
|
|
||||||
|
|
||||||
|
|
||||||
class passengerInitApi:
|
|
||||||
def __init__(self, session, secretList, tickerNo):
|
|
||||||
"""
|
|
||||||
获取候补信息
|
|
||||||
"""
|
|
||||||
self.secretList = secretList
|
|
||||||
self.tickerNo = tickerNo
|
|
||||||
self.session = session
|
|
||||||
|
|
||||||
def sendPassengerInitApi(self):
|
|
||||||
passengerInitApiRsp = self.session.httpClint.send(urls.get("passengerInitApi"))
|
|
||||||
if not passengerInitApiRsp.get("status"):
|
|
||||||
print("".join(passengerInitApiRsp.get("messages")) or passengerInitApiRsp.get("validateMessages"))
|
|
||||||
return
|
|
||||||
data = passengerInitApiRsp.get("data", {})
|
|
||||||
jzdhDateE = data.get("jzdhDateE")
|
|
||||||
if not data.get("jzdhHourE"):
|
|
||||||
wrapcache.set(key=f"hb{self.tickerNo}", value=datetime.datetime.now(),
|
|
||||||
timeout=TickerConfig.TICKET_BLACK_LIST_TIME * 60)
|
|
||||||
print(f"获取当前候补日期失败,原因: {data.get('jzdhHourE')}")
|
|
||||||
return
|
|
||||||
jzdhHourE = data.get("jzdhHourE").replace(":", "#")
|
|
||||||
jzdhDate = f"{jzdhDateE}#{jzdhHourE}"
|
|
||||||
print(f"当前候补日期为:{jzdhDateE} {jzdhHourE}")
|
|
||||||
confirm = confirmHB(self.secretList, self.session, self.tickerNo, jzdhDate)
|
|
||||||
confirm.sendChechFace()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
@ -1,2 +0,0 @@
|
|||||||
class PassengerUserException(Exception):
|
|
||||||
pass
|
|
@ -1,2 +0,0 @@
|
|||||||
class UserPasswordException(Exception):
|
|
||||||
pass
|
|
@ -1,2 +0,0 @@
|
|||||||
class balanceException(Exception):
|
|
||||||
pass
|
|
@ -1,2 +0,0 @@
|
|||||||
class ticketConfigException(Exception):
|
|
||||||
pass
|
|
@ -1,2 +0,0 @@
|
|||||||
class ticketIsExitsException(Exception):
|
|
||||||
pass
|
|
@ -1,2 +0,0 @@
|
|||||||
class ticketNumOutException(Exception):
|
|
||||||
pass
|
|
@ -1,202 +0,0 @@
|
|||||||
# coding=utf-8
|
|
||||||
import json
|
|
||||||
import socket
|
|
||||||
import re
|
|
||||||
# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
||||||
# s.connect(('183.232.189.31', 80))
|
|
||||||
# get_str = 'GET {0} HTTP/1.1\r\nConnection: close\r\n' \
|
|
||||||
# 'Host: %s\r\n' \
|
|
||||||
# 'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36' \
|
|
||||||
# '\r\nAccept: */*\r\n' \
|
|
||||||
# '\r\n'
|
|
||||||
# post_str = "POST {0} HTTP/1.1\r\n" \
|
|
||||||
# "Host: kyfw.12306.cn\r\n" \
|
|
||||||
# "Connection: close\r\n"\
|
|
||||||
# "Origin: https://kyfw.12306.cn\r\n" \
|
|
||||||
# "X-Requested-With: XMLHttpRequest\r\n" \
|
|
||||||
# "Referer: https://kyfw.12306.cn/otn/leftTicket/init\r\n" \
|
|
||||||
# "Accept-Language: zh-CN,zh;q=0.9,en;q=0.8\r\n" \
|
|
||||||
# "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" \
|
|
||||||
# "Accept: application/json, text/javascript, */*; q=0.01\r\n" \
|
|
||||||
# "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5\r\n" \
|
|
||||||
# "Content-Length: 9\r\n"\
|
|
||||||
# "Cookie: _passport_session=a459aba69761497eb31de76c27795e999613; _passport_ct=9116b2cb0bf443e1a01d22ac8c1ae449t5007; route=9036359bb8a8a461c164a04f8f50b252; BIGipServerpool_passport=200081930.50215.0000; BIGipServerotn=484704778.64545.0000\r\n\n"\
|
|
||||||
# "appid=otn\r\n"
|
|
||||||
# # s.sendall(get_str.format("https://kyfw.12306.cn/otn/resources/login.html"))
|
|
||||||
# s.sendall(post_str.format("https://kyfw.12306.cn/passport/web/auth/uamtk"))
|
|
||||||
from config.urlConf import urls
|
|
||||||
|
|
||||||
|
|
||||||
def default_get_data():
|
|
||||||
"""
|
|
||||||
get请求默认组装字符串
|
|
||||||
需要拼接的字符串
|
|
||||||
-- url 发送请求的全连接
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return 'GET {0} HTTP/1.1\r\nConnection: close\r\n' \
|
|
||||||
'Host: kyfw.12306.cn\r\n' \
|
|
||||||
"Referer: {1}\r\n" \
|
|
||||||
'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36' \
|
|
||||||
'\r\nAccept: */*\r\n' \
|
|
||||||
"Cookie: {2}\r\n\n"\
|
|
||||||
'\r\n'
|
|
||||||
# return 'GET {0} HTTP/1.1\r\nConnection: close\r\n' \
|
|
||||||
# 'Host: kyfw.12306.cn\r\n' \
|
|
||||||
# 'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36' \
|
|
||||||
# '\r\nAccept: */*\r\n' \
|
|
||||||
# '\r\n'
|
|
||||||
|
|
||||||
|
|
||||||
def default_post_data():
|
|
||||||
"""
|
|
||||||
post请求默认组装字符串
|
|
||||||
需要拼接的字符串
|
|
||||||
-- url 发送请求的全连接
|
|
||||||
-- Referer 请求页面来源
|
|
||||||
-- Content-Length: body 长度
|
|
||||||
-- Cookie 页面请求的身份认证
|
|
||||||
-- appid 接口请求报文
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return "POST https://kyfw.12306.cn{0} HTTP/1.1\r\n" \
|
|
||||||
"Host: kyfw.12306.cn\r\n" \
|
|
||||||
"Connection: close\r\n"\
|
|
||||||
"Origin: https://kyfw.12306.cn\r\n" \
|
|
||||||
"X-Requested-With: XMLHttpRequest\r\n" \
|
|
||||||
"Referer: {3}\r\n" \
|
|
||||||
"Accept-Language: zh-CN,zh;q=0.9,en;q=0.8\r\n" \
|
|
||||||
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n" \
|
|
||||||
"Accept: application/json, text/javascript, */*; q=0.01\r\n" \
|
|
||||||
"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5\r\n" \
|
|
||||||
"Content-Length: {2}\r\n"\
|
|
||||||
"Cookie: {4}\r\n\n"\
|
|
||||||
"{1}\r\n"\
|
|
||||||
# "\r\n"
|
|
||||||
|
|
||||||
|
|
||||||
class socketUtils:
|
|
||||||
def __init__(self, host, port=80):
|
|
||||||
self.host = host
|
|
||||||
self.port = port
|
|
||||||
self.s = self.connect_socket(self.host, self.port)
|
|
||||||
|
|
||||||
def connect_socket(self, host, port):
|
|
||||||
"""
|
|
||||||
连接socket
|
|
||||||
:param host:
|
|
||||||
:param port:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
||||||
s.connect((host if isinstance(host, str) else str(host),
|
|
||||||
port if isinstance(port, int) else int(port)))
|
|
||||||
return s
|
|
||||||
|
|
||||||
def close_s(self):
|
|
||||||
self.s.close()
|
|
||||||
|
|
||||||
# def send(self, urls, Cookie=None, data=None):
|
|
||||||
# """
|
|
||||||
# 发送请求
|
|
||||||
# :param urls:
|
|
||||||
# :param data:
|
|
||||||
# :param cookie:
|
|
||||||
# :return:
|
|
||||||
# """
|
|
||||||
# url = urls.get("req_url", "")
|
|
||||||
# Referer = urls.get("Referer", "")
|
|
||||||
# if urls.get("req_type", "get") == "post":
|
|
||||||
# Content_Length = len(data)
|
|
||||||
# Cookie = "tk=pnidlCoFy2B7wxO_X_pESbrkZFSq3OtVA_xzXwuba2a0; JSESSIONID=C6144324BFCE36AC5082E543E934E8B3; current_captcha_type=Z; _jc_save_fromDate=2018-08-03; _jc_save_fromStation=%u6DF1%u5733%2CSZQ; _jc_save_toDate=2018-08-03; _jc_save_toStation=%u957F%u6C99%2CCSQ; _jc_save_wfdc_flag=dc; ten_key=b5L6aMWfnzBm8CgQe8pcAKQsmVBS2PYH; BIGipServerpool_passport=166527498.50215.0000; BIGipServerotn=165937674.50210.0000; route=c5c62a339e7744272a54643b3be5bf64; RAIL_DEVICEID=fC-yepiUqNjsBiRvtLBXW4JqQmabCfB9QxI3FifJZK9YDRsImhJLSz4sAQ4HiGF7uQAFdFyISg6jA7KAhtpEldJV9ZMNsn6Dzm_psA5CBDwSNfiORf42w-LIRvkeGvdKFtegZwWGlkA2fVuEWKu-1xAYdCXRnsMD; RAIL_EXPIRATION=1533420302032; _jc_save_detail=true"
|
|
||||||
# if data:
|
|
||||||
# send_value = default_post_data().format(url,
|
|
||||||
# data,
|
|
||||||
# Content_Length,
|
|
||||||
# Referer,
|
|
||||||
# Cookie
|
|
||||||
# )
|
|
||||||
# print("send_value: " + send_value)
|
|
||||||
# self.s.sendall(send_value)
|
|
||||||
# else:
|
|
||||||
# self.s.sendall(default_get_data().format(url,
|
|
||||||
# Referer,
|
|
||||||
# Cookie))
|
|
||||||
# total_data = ""
|
|
||||||
# while 1:
|
|
||||||
# data = self.s.recv(1024)
|
|
||||||
# total_data += data
|
|
||||||
# if not data:
|
|
||||||
# break
|
|
||||||
# self.close_s()
|
|
||||||
# print(total_data)
|
|
||||||
# return self.recv_data(total_data)
|
|
||||||
|
|
||||||
def recv_data(self, r_data):
|
|
||||||
cookie = self.get_cookie(r_data)
|
|
||||||
status_code = self.get_status_code(r_data)
|
|
||||||
r_body = self.get_rep_body(r_data)
|
|
||||||
return {
|
|
||||||
"cookie": cookie,
|
|
||||||
"status_code": status_code,
|
|
||||||
"r_body": r_body
|
|
||||||
}
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_cookie(recv_data):
|
|
||||||
"""
|
|
||||||
提取cookie
|
|
||||||
:param recv_data:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if not isinstance(recv_data, str):
|
|
||||||
recv_data = str(recv_data)
|
|
||||||
cookies_re = re.compile(r"Set-Cookie: (\S+);")
|
|
||||||
cookies = re.findall(cookies_re, recv_data)
|
|
||||||
return "; ".join(cookies)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_status_code(recv_data):
|
|
||||||
"""
|
|
||||||
获取状态码
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if not isinstance(recv_data, str):
|
|
||||||
recv_data = str(recv_data)
|
|
||||||
http_code_re = re.compile(r"HTTP/1.1 (\S+) ")
|
|
||||||
status_code = re.search(http_code_re, recv_data).group(1)
|
|
||||||
return status_code
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_rep_body(recv_data):
|
|
||||||
"""
|
|
||||||
获取返回值
|
|
||||||
:param recv_data:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if not isinstance(recv_data, str):
|
|
||||||
recv_data = str(recv_data)
|
|
||||||
if recv_data.find("{") != -1 and recv_data.find("}") != -1:
|
|
||||||
data = json.loads(recv_data.split("\n")[-1])
|
|
||||||
return data
|
|
||||||
else:
|
|
||||||
print(recv_data)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
so = socketUtils('183.232.189.31', 80)
|
|
||||||
train_date = "2018-08-03"
|
|
||||||
from_station = "SZQ"
|
|
||||||
to_station = "CSQ"
|
|
||||||
urls["select_url"]["req_url"] = "https://kyfw.12306.cn" + urls["select_url"]["req_url"].format(train_date, from_station, to_station)
|
|
||||||
result = so.send(urls=urls["select_url"])
|
|
||||||
print(result)
|
|
||||||
|
|
||||||
so = socketUtils('183.232.189.31', 80)
|
|
||||||
|
|
||||||
data = "secretStr=Vgo534nDZiCH8NCvyEPcGepzJoRCjvYr34gKFv5CW1K1XtM6mtKHoiFPjUYvaVKoe06SMhUUpT%2FK%0AxIEIsBD4zHgJPpVyKiTPx80y6OCWhNgcKjib2LLMXMJfgTgh0RKPISjkDjVFmO9p905O%2FegDeKjp%0A1fhIeqCuYraHjNhI0PjQY39BAY4AHLzW0iGgDq8b%2FtpyOY8Td2XfIWNZJCWzgyPkNXOk0HUguB2G%0AKh2T8nlko6zb5ra%2B%2BA%3D%3D&train_date=2018-08-03&back_train_date=2018-08-03&tour_flag=dc&purpose_codes=ADULT&query_from_station_name=深圳&query_to_station_name=长沙&undefined"
|
|
||||||
result1 = so.send(urls=urls["submit_station_url"], data=data)
|
|
||||||
print(result1)
|
|
||||||
# so = socketUtils('183.232.189.31', 80)
|
|
||||||
# result = so.send(url="https://kyfw.12306.cn/passport/web/login", s_data="")
|
|
||||||
# print(result)
|
|
@ -1,7 +0,0 @@
|
|||||||
bs4==0.0.1
|
|
||||||
requests==2.18.4
|
|
||||||
Pillow
|
|
||||||
wrapcache==1.0.8
|
|
||||||
ntplib==0.3.3
|
|
||||||
selenium==3.11.0
|
|
||||||
fake-useragent==0.1.11
|
|
@ -1,15 +0,0 @@
|
|||||||
beautifulsoup4==4.5.3
|
|
||||||
bs4==0.0.1
|
|
||||||
requests==2.18.4
|
|
||||||
Pillow
|
|
||||||
wrapcache==1.0.8
|
|
||||||
ntplib==0.3.3
|
|
||||||
sklearn
|
|
||||||
opencv-python
|
|
||||||
keras==2.2.4
|
|
||||||
tensorflow==1.14.0
|
|
||||||
matplotlib>=3.0.2
|
|
||||||
numpy>=1.14.6
|
|
||||||
scipy>=1.1.0
|
|
||||||
selenium==3.11.0
|
|
||||||
fake-useragent==0.1.11
|
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 380 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 223 KiB |
@ -1,115 +0,0 @@
|
|||||||
# coding: utf-8
|
|
||||||
import TickerConfig
|
|
||||||
|
|
||||||
if TickerConfig.AUTO_CODE_TYPE == 2:
|
|
||||||
import base64
|
|
||||||
import os
|
|
||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
from keras import models, backend
|
|
||||||
import tensorflow as tf
|
|
||||||
from verify import pretreatment
|
|
||||||
from verify.mlearn_for_image import preprocess_input
|
|
||||||
|
|
||||||
graph = tf.get_default_graph()
|
|
||||||
|
|
||||||
PATH = lambda p: os.path.abspath(
|
|
||||||
os.path.join(os.path.dirname(__file__), p)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
TEXT_MODEL = ""
|
|
||||||
IMG_MODEL = ""
|
|
||||||
|
|
||||||
|
|
||||||
def get_text(img, offset=0):
|
|
||||||
text = pretreatment.get_text(img, offset)
|
|
||||||
text = cv2.cvtColor(text, cv2.COLOR_BGR2GRAY)
|
|
||||||
text = text / 255.0
|
|
||||||
h, w = text.shape
|
|
||||||
text.shape = (1, h, w, 1)
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
def base64_to_image(base64_code):
|
|
||||||
# base64解码
|
|
||||||
img_data = base64.b64decode(base64_code)
|
|
||||||
# 转换为np数组
|
|
||||||
img_array = np.fromstring(img_data, np.uint8)
|
|
||||||
# 转换成opencv可用格式
|
|
||||||
img = cv2.imdecode(img_array, cv2.COLOR_RGB2BGR)
|
|
||||||
|
|
||||||
return img
|
|
||||||
|
|
||||||
|
|
||||||
class Verify:
|
|
||||||
def __init__(self):
|
|
||||||
self.textModel = ""
|
|
||||||
self.imgModel = ""
|
|
||||||
self.loadImgModel()
|
|
||||||
self.loadTextModel()
|
|
||||||
|
|
||||||
def loadTextModel(self):
|
|
||||||
if not self.textModel:
|
|
||||||
self.textModel = models.load_model(PATH('../model.v2.0.h5'))
|
|
||||||
else:
|
|
||||||
print("无需加载模型model.v2.0.h5")
|
|
||||||
|
|
||||||
def loadImgModel(self):
|
|
||||||
if not self.imgModel:
|
|
||||||
self.imgModel = models.load_model(PATH('../12306.image.model.h5'))
|
|
||||||
|
|
||||||
def verify(self, fn):
|
|
||||||
verify_titles = ['打字机', '调色板', '跑步机', '毛线', '老虎', '安全帽', '沙包', '盘子', '本子', '药片', '双面胶', '龙舟', '红酒', '拖把', '卷尺',
|
|
||||||
'海苔', '红豆', '黑板', '热水袋', '烛台', '钟表', '路灯', '沙拉', '海报', '公交卡', '樱桃', '创可贴', '牌坊', '苍蝇拍', '高压锅',
|
|
||||||
'电线', '网球拍', '海鸥', '风铃', '订书机', '冰箱', '话梅', '排风机', '锅铲', '绿豆', '航母', '电子秤', '红枣', '金字塔', '鞭炮',
|
|
||||||
'菠萝', '开瓶器', '电饭煲', '仪表盘', '棉棒', '篮球', '狮子', '蚂蚁', '蜡烛', '茶盅', '印章', '茶几', '啤酒', '档案袋', '挂钟', '刺绣',
|
|
||||||
'铃铛', '护腕', '手掌印', '锦旗', '文具盒', '辣椒酱', '耳塞', '中国结', '蜥蜴', '剪纸', '漏斗', '锣', '蒸笼', '珊瑚', '雨靴', '薯条',
|
|
||||||
'蜜蜂', '日历', '口哨']
|
|
||||||
# 读取并预处理验证码
|
|
||||||
img = base64_to_image(fn)
|
|
||||||
text = get_text(img)
|
|
||||||
imgs = np.array(list(pretreatment._get_imgs(img)))
|
|
||||||
imgs = preprocess_input(imgs)
|
|
||||||
text_list = []
|
|
||||||
# 识别文字
|
|
||||||
self.loadTextModel()
|
|
||||||
global graph
|
|
||||||
with graph.as_default():
|
|
||||||
label = self.textModel.predict(text)
|
|
||||||
label = label.argmax()
|
|
||||||
text = verify_titles[label]
|
|
||||||
text_list.append(text)
|
|
||||||
# 获取下一个词
|
|
||||||
# 根据第一个词的长度来定位第二个词的位置
|
|
||||||
if len(text) == 1:
|
|
||||||
offset = 27
|
|
||||||
elif len(text) == 2:
|
|
||||||
offset = 47
|
|
||||||
else:
|
|
||||||
offset = 60
|
|
||||||
text = get_text(img, offset=offset)
|
|
||||||
if text.mean() < 0.95:
|
|
||||||
with graph.as_default():
|
|
||||||
label = self.textModel.predict(text)
|
|
||||||
label = label.argmax()
|
|
||||||
text = verify_titles[label]
|
|
||||||
text_list.append(text)
|
|
||||||
print("题目为{}".format(text_list))
|
|
||||||
# 加载图片分类器
|
|
||||||
self.loadImgModel()
|
|
||||||
with graph.as_default():
|
|
||||||
labels = self.imgModel.predict(imgs)
|
|
||||||
labels = labels.argmax(axis=1)
|
|
||||||
results = []
|
|
||||||
for pos, label in enumerate(labels):
|
|
||||||
l = verify_titles[label]
|
|
||||||
print(pos + 1, l)
|
|
||||||
if l in text_list:
|
|
||||||
results.append(str(pos + 1))
|
|
||||||
return results
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
pass
|
|
||||||
# verify("verify-img1.jpeg")
|
|
@ -1,102 +0,0 @@
|
|||||||
#! env python
|
|
||||||
# coding: utf-8
|
|
||||||
# 功能:对图像进行预处理,将文字部分单独提取出来
|
|
||||||
# 并存放到ocr目录下
|
|
||||||
# 文件名为原验证码文件的文件名
|
|
||||||
import TickerConfig
|
|
||||||
if TickerConfig.AUTO_CODE_TYPE == 2:
|
|
||||||
import hashlib
|
|
||||||
import os
|
|
||||||
import pathlib
|
|
||||||
|
|
||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
import requests
|
|
||||||
import scipy.fftpack
|
|
||||||
|
|
||||||
|
|
||||||
PATH = 'imgs'
|
|
||||||
|
|
||||||
|
|
||||||
def download_image():
|
|
||||||
# 抓取验证码
|
|
||||||
# 存放到指定path下
|
|
||||||
# 文件名为图像的MD5
|
|
||||||
url = 'https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew?module=login&rand=sjrand'
|
|
||||||
r = requests.get(url)
|
|
||||||
fn = hashlib.md5(r.content).hexdigest()
|
|
||||||
with open(f'{PATH}/{fn}.jpg', 'wb') as fp:
|
|
||||||
fp.write(r.content)
|
|
||||||
|
|
||||||
|
|
||||||
def download_images():
|
|
||||||
pathlib.Path(PATH).mkdir(exist_ok=True)
|
|
||||||
for idx in range(40000):
|
|
||||||
download_image()
|
|
||||||
print(idx)
|
|
||||||
|
|
||||||
|
|
||||||
def get_text(img, offset=0):
|
|
||||||
# 得到图像中的文本部分
|
|
||||||
return img[3:22, 120 + offset:177 + offset]
|
|
||||||
|
|
||||||
|
|
||||||
def avhash(im):
|
|
||||||
im = cv2.resize(im, (8, 8), interpolation=cv2.INTER_CUBIC)
|
|
||||||
avg = im.mean()
|
|
||||||
im = im > avg
|
|
||||||
im = np.packbits(im)
|
|
||||||
return im
|
|
||||||
|
|
||||||
|
|
||||||
def phash(im):
|
|
||||||
im = cv2.resize(im, (32, 32), interpolation=cv2.INTER_CUBIC)
|
|
||||||
im = scipy.fftpack.dct(scipy.fftpack.dct(im, axis=0), axis=1)
|
|
||||||
im = im[:8, :8]
|
|
||||||
med = np.median(im)
|
|
||||||
im = im > med
|
|
||||||
im = np.packbits(im)
|
|
||||||
return im
|
|
||||||
|
|
||||||
|
|
||||||
def _get_imgs(img):
|
|
||||||
interval = 5
|
|
||||||
length = 67
|
|
||||||
for x in range(40, img.shape[0] - length, interval + length):
|
|
||||||
for y in range(interval, img.shape[1] - length, interval + length):
|
|
||||||
yield img[x:x + length, y:y + length]
|
|
||||||
|
|
||||||
|
|
||||||
def get_imgs(img):
|
|
||||||
imgs = []
|
|
||||||
for img in _get_imgs(img):
|
|
||||||
imgs.append(phash(img))
|
|
||||||
return imgs
|
|
||||||
|
|
||||||
|
|
||||||
def pretreat():
|
|
||||||
if not os.path.isdir(PATH):
|
|
||||||
download_images()
|
|
||||||
texts, imgs = [], []
|
|
||||||
for img in os.listdir(PATH):
|
|
||||||
img = os.path.join(PATH, img)
|
|
||||||
img = cv2.imread(img, cv2.IMREAD_GRAYSCALE)
|
|
||||||
texts.append(get_text(img))
|
|
||||||
imgs.append(get_imgs(img))
|
|
||||||
return texts, imgs
|
|
||||||
|
|
||||||
|
|
||||||
def load_data(path='data.npz'):
|
|
||||||
if not os.path.isfile(path):
|
|
||||||
texts, imgs = pretreat()
|
|
||||||
np.savez(path, texts=texts, images=imgs)
|
|
||||||
f = np.load(path)
|
|
||||||
return f['texts'], f['images']
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
texts, imgs = load_data()
|
|
||||||
print(texts.shape)
|
|
||||||
print(imgs.shape)
|
|
||||||
imgs = imgs.reshape(-1, 8)
|
|
||||||
print(np.unique(imgs, axis=0).shape)
|
|
@ -1,679 +0,0 @@
|
|||||||
/******************************************************************************
|
|
||||||
* FileName : CatchScreenDlg.cpp
|
|
||||||
* Author : Unknown
|
|
||||||
* Mender : sudami
|
|
||||||
* Time : 2007/09/09
|
|
||||||
*
|
|
||||||
* Comment :
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "Screenshot.h"
|
|
||||||
#include "CatchScreenDlg.h"
|
|
||||||
|
|
||||||
#include <GdiPlus.h>
|
|
||||||
using namespace Gdiplus;
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define new DEBUG_NEW
|
|
||||||
#undef THIS_FILE
|
|
||||||
static char THIS_FILE[] = __FILE__;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// CCatchScreenDlg dialog
|
|
||||||
|
|
||||||
CCatchScreenDlg::CCatchScreenDlg(CWnd* pParent /*=NULL*/)
|
|
||||||
: CDialog(CCatchScreenDlg::IDD, pParent)
|
|
||||||
{
|
|
||||||
m_bLBtnDown = FALSE;
|
|
||||||
//初始化像皮筋类,新增的resizeMiddle 类型
|
|
||||||
m_rectTracker.m_nStyle = CMyTracker::resizeMiddle | CMyTracker::solidLine;
|
|
||||||
m_rectTracker.m_rect.SetRect(-1, -2, -3, -4);
|
|
||||||
//设置矩形颜色
|
|
||||||
m_rectTracker.SetRectColor(RGB(10, 100, 130));
|
|
||||||
|
|
||||||
m_hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR1);
|
|
||||||
|
|
||||||
m_bDraw = FALSE;
|
|
||||||
m_bFirstDraw = FALSE;
|
|
||||||
m_bQuit = FALSE;
|
|
||||||
m_bNeedShowMsg = FALSE;
|
|
||||||
m_startPt = 0;
|
|
||||||
|
|
||||||
//获取屏幕分辩率
|
|
||||||
m_xScreen = GetSystemMetrics(SM_CXSCREEN);
|
|
||||||
m_yScreen = GetSystemMetrics(SM_CYSCREEN);
|
|
||||||
|
|
||||||
//截取屏幕到位图中
|
|
||||||
CRect rect(0, 0, m_xScreen, m_yScreen);
|
|
||||||
m_hBitmap = CopyScreenToBitmap(&rect);
|
|
||||||
m_pBitmap = CBitmap::FromHandle(m_hBitmap);
|
|
||||||
|
|
||||||
//初始化刷新窗口区域 m_rgn
|
|
||||||
m_rgn.CreateRectRgn(0, 0, 50, 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::DoDataExchange(CDataExchange* pDX)
|
|
||||||
{
|
|
||||||
CDialog::DoDataExchange(pDX);
|
|
||||||
DDX_Control(pDX, IDC_EDIT1, m_tipEdit);
|
|
||||||
}
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(CCatchScreenDlg, CDialog)
|
|
||||||
ON_WM_PAINT()
|
|
||||||
ON_WM_MOUSEMOVE()
|
|
||||||
ON_WM_LBUTTONDOWN()
|
|
||||||
ON_WM_LBUTTONUP()
|
|
||||||
ON_WM_LBUTTONDBLCLK()
|
|
||||||
ON_WM_ERASEBKGND()
|
|
||||||
ON_WM_SETCURSOR()
|
|
||||||
ON_WM_RBUTTONUP()
|
|
||||||
ON_WM_CTLCOLOR()
|
|
||||||
ON_WM_RBUTTONDOWN()
|
|
||||||
END_MESSAGE_MAP()
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CCatchScreenDlg message handlers
|
|
||||||
|
|
||||||
BOOL CCatchScreenDlg::OnInitDialog()
|
|
||||||
{
|
|
||||||
CDialog::OnInitDialog();
|
|
||||||
//把对化框设置成全屏顶层窗口
|
|
||||||
SetWindowPos(&wndTopMost, 0, 0, m_xScreen, m_yScreen, SWP_SHOWWINDOW);
|
|
||||||
|
|
||||||
//移动操作提示窗口
|
|
||||||
CRect rect;
|
|
||||||
m_tipEdit.GetWindowRect(&rect);
|
|
||||||
m_tipEdit.MoveWindow(10, 10, rect.Width(), rect.Height());
|
|
||||||
|
|
||||||
|
|
||||||
m_toolBar.CreateToolBar(m_hWnd);
|
|
||||||
m_toolBar.RemoveChildStyle();
|
|
||||||
::MoveWindow(m_toolBar.GetHWND(),300,300,230,30,FALSE);
|
|
||||||
|
|
||||||
|
|
||||||
UpdateTipString();
|
|
||||||
SetEidtWndText();
|
|
||||||
|
|
||||||
((CScreenshotApp *)AfxGetApp())->m_hwndDlg = AfxGetMainWnd()->GetSafeHwnd();
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::OnPaint()
|
|
||||||
{
|
|
||||||
// 如果窗口是最小化状态
|
|
||||||
if (IsIconic())
|
|
||||||
{
|
|
||||||
CPaintDC dc(this);
|
|
||||||
|
|
||||||
SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0);
|
|
||||||
|
|
||||||
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
||||||
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
||||||
CRect rect;
|
|
||||||
GetClientRect(&rect);
|
|
||||||
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
||||||
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
||||||
|
|
||||||
}
|
|
||||||
else // 如果窗口正常显示
|
|
||||||
{
|
|
||||||
CPaintDC dc(this);
|
|
||||||
|
|
||||||
CDC dcCompatible;
|
|
||||||
|
|
||||||
dcCompatible.CreateCompatibleDC(&dc);
|
|
||||||
RECT rect;
|
|
||||||
::GetClientRect(m_hWnd, &rect);
|
|
||||||
HBITMAP hBitmap = ::CreateCompatibleBitmap(dc.m_hDC,rect.right-rect.left,rect.bottom-rect.top);
|
|
||||||
::SelectObject(dcCompatible.m_hDC,hBitmap);
|
|
||||||
|
|
||||||
HBRUSH s_hBitmapBrush = CreatePatternBrush(m_hBitmap);
|
|
||||||
::FillRect(dcCompatible.m_hDC,&rect,s_hBitmapBrush);
|
|
||||||
|
|
||||||
//显示截取矩形大小信息
|
|
||||||
if (m_bNeedShowMsg && m_bFirstDraw)
|
|
||||||
{
|
|
||||||
CRect rect = m_rectTracker.m_rect;
|
|
||||||
DrawMessage(rect, &dcCompatible);
|
|
||||||
}
|
|
||||||
|
|
||||||
//画出像皮筋矩形
|
|
||||||
if (m_bFirstDraw)
|
|
||||||
{
|
|
||||||
m_rectTracker.Draw(&dcCompatible);
|
|
||||||
}
|
|
||||||
Gdiplus::Graphics graphics(dcCompatible);
|
|
||||||
|
|
||||||
HRGN hgn1 = CreateRectRgn(m_rectTracker.m_rect.left,m_rectTracker.m_rect.top,
|
|
||||||
m_rectTracker.m_rect.right,m_rectTracker.m_rect.bottom);
|
|
||||||
Region region1(hgn1);
|
|
||||||
|
|
||||||
HRGN hgn2 = CreateRectRgn(rect.left,rect.top,
|
|
||||||
rect.right,rect.bottom);
|
|
||||||
Region region2(hgn2);
|
|
||||||
|
|
||||||
region2.Exclude(®ion1);
|
|
||||||
|
|
||||||
SolidBrush solidBrush(Color(100, 128, 128, 128));
|
|
||||||
graphics.FillRegion(&solidBrush,®ion2);
|
|
||||||
|
|
||||||
DeleteObject(hgn1);
|
|
||||||
DeleteObject(hgn2);
|
|
||||||
|
|
||||||
dc.BitBlt(0,0,rect.right, rect.bottom,&dcCompatible,0,0,SRCCOPY);
|
|
||||||
DeleteObject(hBitmap);
|
|
||||||
DeleteObject(s_hBitmapBrush);
|
|
||||||
|
|
||||||
//CDialog::OnPaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::OnCancel()
|
|
||||||
{
|
|
||||||
if (m_bFirstDraw)
|
|
||||||
{
|
|
||||||
//取消已画矩形变量
|
|
||||||
m_bFirstDraw = FALSE;
|
|
||||||
m_bDraw = FALSE;
|
|
||||||
m_rectTracker.m_rect.SetRect(-1, -1, -1, -1);
|
|
||||||
InvalidateRgnWindow();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CDialog::OnCancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::OnMouseMove(UINT nFlags, CPoint point)
|
|
||||||
{
|
|
||||||
if(m_bLBtnDown)
|
|
||||||
m_toolBar.HideToolBar();
|
|
||||||
else
|
|
||||||
m_toolBar.ShowToolBar();
|
|
||||||
if (m_bDraw)
|
|
||||||
{
|
|
||||||
//动态调整矩形大小,并刷新画出
|
|
||||||
m_rectTracker.m_rect.SetRect(m_startPt.x + 4, m_startPt.y + 4, point.x, point.y);
|
|
||||||
InvalidateRgnWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
//弥补调整大小和位置时,接收不到MouseMove消息
|
|
||||||
CRect rect;
|
|
||||||
m_tipEdit.GetWindowRect(&rect);
|
|
||||||
if (rect.PtInRect(point))
|
|
||||||
m_tipEdit.SendMessage(WM_MOUSEMOVE);
|
|
||||||
|
|
||||||
UpdateMousePointRGBString();
|
|
||||||
SetEidtWndText();
|
|
||||||
|
|
||||||
CDialog::OnMouseMove(nFlags, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::OnLButtonDown(UINT nFlags, CPoint point)
|
|
||||||
{
|
|
||||||
m_bLBtnDown = TRUE;
|
|
||||||
int nHitTest;
|
|
||||||
nHitTest = m_rectTracker.HitTest(point);
|
|
||||||
//判断击中位置
|
|
||||||
if (nHitTest < 0)
|
|
||||||
{
|
|
||||||
if (!m_bFirstDraw)
|
|
||||||
{
|
|
||||||
//第一次画矩形
|
|
||||||
m_startPt = point;
|
|
||||||
m_bDraw = TRUE;
|
|
||||||
m_bFirstDraw = TRUE;
|
|
||||||
//设置当鼠标按下时最小的矩形大小
|
|
||||||
m_rectTracker.m_rect.SetRect(point.x, point.y, point.x + 4, point.y + 4);
|
|
||||||
|
|
||||||
//保证当鼠标当下时立刻显示信息
|
|
||||||
if (m_bFirstDraw)
|
|
||||||
m_bNeedShowMsg = TRUE;
|
|
||||||
UpdateTipString();
|
|
||||||
SetEidtWndText();
|
|
||||||
InvalidateRgnWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//保证当鼠标当下时立刻显示信息
|
|
||||||
m_bNeedShowMsg = TRUE;
|
|
||||||
if (m_bFirstDraw)
|
|
||||||
{
|
|
||||||
//调束大小时,Track会自动调整矩形大小,在些期间,消息归CRectTracker内部处理
|
|
||||||
m_rectTracker.Track(this, point, TRUE);
|
|
||||||
InvalidateRgnWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CDialog::OnLButtonDown(nFlags, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::OnLButtonUp(UINT nFlags, CPoint point)
|
|
||||||
{
|
|
||||||
m_bLBtnDown = FALSE;
|
|
||||||
m_bNeedShowMsg = FALSE;
|
|
||||||
m_bDraw = FALSE;
|
|
||||||
UpdateTipString();
|
|
||||||
SetEidtWndText();
|
|
||||||
m_toolBar.SetShowPlace(m_rectTracker.m_rect.right,m_rectTracker.m_rect.bottom);
|
|
||||||
|
|
||||||
InvalidateRgnWindow();
|
|
||||||
CDialog::OnLButtonUp(nFlags, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::OnLButtonDblClk(UINT nFlags, CPoint point)
|
|
||||||
{
|
|
||||||
int nHitTest;
|
|
||||||
nHitTest = m_rectTracker.HitTest(point);
|
|
||||||
|
|
||||||
//如果在是矩形内部双击
|
|
||||||
if (nHitTest == 8)
|
|
||||||
{
|
|
||||||
//保存位图到粘贴板中,bSave 为TRUE,
|
|
||||||
CopyScreenToBitmap(m_rectTracker.m_rect, TRUE);
|
|
||||||
PostQuitMessage(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
CDialog::OnLButtonDblClk(nFlags, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::OnRButtonDown(UINT nFlags, CPoint point)
|
|
||||||
{
|
|
||||||
m_toolBar.HideToolBar();
|
|
||||||
//InvalidateRgnWindow();
|
|
||||||
CDialog::OnRButtonDown(nFlags, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::OnRButtonUp(UINT nFlags, CPoint point)
|
|
||||||
{
|
|
||||||
m_bLBtnDown = FALSE;
|
|
||||||
if (m_bFirstDraw)
|
|
||||||
{
|
|
||||||
//如果已经截取矩则清除截取矩形
|
|
||||||
m_bFirstDraw = FALSE;
|
|
||||||
//清除矩形大小
|
|
||||||
m_rectTracker.m_rect.SetRect(-1, -1, -1, -1);
|
|
||||||
UpdateTipString();
|
|
||||||
SetEidtWndText();
|
|
||||||
InvalidateRgnWindow();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//关闭程序
|
|
||||||
PostQuitMessage(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
CDialog::OnRButtonUp(nFlags, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
HBRUSH CCatchScreenDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
|
||||||
{
|
|
||||||
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
||||||
|
|
||||||
//设置操作提示窗口文本颜色
|
|
||||||
if (pWnd->GetDlgCtrlID() == IDC_EDIT1)
|
|
||||||
{
|
|
||||||
pDC->SetTextColor(RGB(247,76,128));
|
|
||||||
}
|
|
||||||
|
|
||||||
return hbr;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CCatchScreenDlg::OnEraseBkgnd(CDC* pDC)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
//用整个桌面填充全屏对话框背景
|
|
||||||
BITMAP bmp;
|
|
||||||
m_pBitmap->GetBitmap(&bmp);
|
|
||||||
|
|
||||||
CDC dcCompatible;
|
|
||||||
dcCompatible.CreateCompatibleDC(pDC);
|
|
||||||
|
|
||||||
dcCompatible.SelectObject(m_pBitmap);
|
|
||||||
|
|
||||||
CRect rect;
|
|
||||||
GetClientRect(&rect);
|
|
||||||
pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &dcCompatible, 0, 0, SRCCOPY);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CCatchScreenDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
|
||||||
{
|
|
||||||
//设置改变截取矩形大小时光标
|
|
||||||
if (pWnd == this &&m_rectTracker.SetCursor(this, nHitTest)
|
|
||||||
&& !m_bDraw &&m_bFirstDraw) //此处判断保截取时当标始中为彩色光标
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置彩色光标
|
|
||||||
SetCursor(m_hCursor);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拷贝屏幕, 这段源码源自CSDN
|
|
||||||
// lpRect 代表选定区域
|
|
||||||
HBITMAP CCatchScreenDlg::CopyScreenToBitmap(LPRECT lpRect, BOOL bSave)
|
|
||||||
|
|
||||||
{
|
|
||||||
HDC hScrDC, hMemDC;
|
|
||||||
// 屏幕和内存设备描述表
|
|
||||||
HBITMAP hBitmap, hOldBitmap;
|
|
||||||
// 位图句柄
|
|
||||||
int nX, nY, nX2, nY2;
|
|
||||||
// 选定区域坐标
|
|
||||||
int nWidth, nHeight;
|
|
||||||
|
|
||||||
// 确保选定区域不为空矩形
|
|
||||||
if (IsRectEmpty(lpRect))
|
|
||||||
return NULL;
|
|
||||||
//为屏幕创建设备描述表
|
|
||||||
hScrDC = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
|
|
||||||
|
|
||||||
//为屏幕设备描述表创建兼容的内存设备描述表
|
|
||||||
hMemDC = CreateCompatibleDC(hScrDC);
|
|
||||||
// 获得选定区域坐标
|
|
||||||
nX = lpRect->left;
|
|
||||||
nY = lpRect->top;
|
|
||||||
nX2 = lpRect->right;
|
|
||||||
nY2 = lpRect->bottom;
|
|
||||||
|
|
||||||
//确保选定区域是可见的
|
|
||||||
if (nX < 0)
|
|
||||||
nX = 0;
|
|
||||||
if (nY < 0)
|
|
||||||
nY = 0;
|
|
||||||
if (nX2 > m_xScreen)
|
|
||||||
nX2 = m_xScreen;
|
|
||||||
if (nY2 > m_yScreen)
|
|
||||||
nY2 = m_yScreen;
|
|
||||||
nWidth = nX2 - nX;
|
|
||||||
nHeight = nY2 - nY;
|
|
||||||
// 创建一个与屏幕设备描述表兼容的位图
|
|
||||||
hBitmap = CreateCompatibleBitmap
|
|
||||||
(hScrDC, nWidth, nHeight);
|
|
||||||
// 把新位图选到内存设备描述表中
|
|
||||||
hOldBitmap = (HBITMAP)SelectObject(hMemDC, hBitmap);
|
|
||||||
// 把屏幕设备描述表拷贝到内存设备描述表中
|
|
||||||
if (bSave)
|
|
||||||
{
|
|
||||||
//创建兼容DC,当bSave为中时把开始保存的全屏位图,按截取矩形大小保存
|
|
||||||
CDC dcCompatible;
|
|
||||||
dcCompatible.CreateCompatibleDC(CDC::FromHandle(hMemDC));
|
|
||||||
dcCompatible.SelectObject(m_pBitmap);
|
|
||||||
|
|
||||||
BitBlt(hMemDC, 0, 0, nWidth, nHeight,
|
|
||||||
dcCompatible, nX, nY, SRCCOPY);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BitBlt(hMemDC, 0, 0, nWidth, nHeight,
|
|
||||||
hScrDC, nX, nY, SRCCOPY);
|
|
||||||
}
|
|
||||||
|
|
||||||
hBitmap = (HBITMAP)SelectObject(hMemDC, hOldBitmap);
|
|
||||||
//得到屏幕位图的句柄
|
|
||||||
//清除
|
|
||||||
DeleteDC(hScrDC);
|
|
||||||
DeleteDC(hMemDC);
|
|
||||||
|
|
||||||
if (bSave)
|
|
||||||
{
|
|
||||||
if (OpenClipboard())
|
|
||||||
{
|
|
||||||
//清空剪贴板
|
|
||||||
EmptyClipboard();
|
|
||||||
//把屏幕内容粘贴到剪贴板上,
|
|
||||||
//hBitmap 为刚才的屏幕位图句柄
|
|
||||||
SetClipboardData(CF_BITMAP, hBitmap);
|
|
||||||
//关闭剪贴板
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 返回位图句柄
|
|
||||||
return hBitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 显示操作提示信息
|
|
||||||
void CCatchScreenDlg::UpdateTipString()
|
|
||||||
{
|
|
||||||
CString strTemp;
|
|
||||||
if (!m_bDraw && !m_bFirstDraw)
|
|
||||||
{
|
|
||||||
strTemp = _T("\r\n\r\n·按下鼠标左键不放选择截取\r\n\r\n·ESC键、鼠标右键退出");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (m_bDraw && m_bFirstDraw)
|
|
||||||
{
|
|
||||||
strTemp = _T("\r\n\r\n·松开鼠标左键确定截取范围\r\n\r\n·ESC键退出");
|
|
||||||
}
|
|
||||||
else if (!m_bDraw && m_bFirstDraw)
|
|
||||||
{
|
|
||||||
CString sudami(_T("\r\n\r\n·矩形内双击鼠标左键保存\r\n\r\n·点击鼠标右键重新选择"));
|
|
||||||
strTemp = _T("\r\n\r\n·鼠标在矩形边缘调整大小");
|
|
||||||
|
|
||||||
strTemp += sudami;
|
|
||||||
}
|
|
||||||
m_strEditTip = strTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 显示截取矩形信息
|
|
||||||
void CCatchScreenDlg::DrawMessage(CRect &inRect, CDC * pDC)
|
|
||||||
{
|
|
||||||
//截取矩形大小信息离鼠标间隔
|
|
||||||
const int space = 3;
|
|
||||||
|
|
||||||
//设置字体颜色大小
|
|
||||||
CPoint pt;
|
|
||||||
CPen pen(PS_SOLID, 1, RGB(47, 79, 79));
|
|
||||||
CPen *pOldPen;
|
|
||||||
pOldPen = pDC->SelectObject(&pen);
|
|
||||||
|
|
||||||
//pDC->SetTextColor(RGB(147,147,147));
|
|
||||||
CFont font;
|
|
||||||
CFont * pOldFont;
|
|
||||||
font.CreatePointFont(90, _T("宋体"));
|
|
||||||
pOldFont = pDC->SelectObject(&font);
|
|
||||||
|
|
||||||
//得到字体宽度和高度
|
|
||||||
GetCursorPos(&pt);
|
|
||||||
int OldBkMode;
|
|
||||||
OldBkMode = pDC->SetBkMode(TRANSPARENT);
|
|
||||||
|
|
||||||
TEXTMETRIC tm;
|
|
||||||
int charHeight;
|
|
||||||
CSize size;
|
|
||||||
int lineLength;
|
|
||||||
pDC->GetTextMetrics(&tm);
|
|
||||||
charHeight = tm.tmHeight + tm.tmExternalLeading;
|
|
||||||
size = pDC->GetTextExtent(_T("顶点位置 "), _tcslen(_T("顶点位置 ")));
|
|
||||||
lineLength = size.cx;
|
|
||||||
|
|
||||||
//初始化矩形, 以保证写下六行文字
|
|
||||||
CRect rect(pt.x + space, pt.y - charHeight * 6 - space, pt.x + lineLength + space, pt.y - space);
|
|
||||||
|
|
||||||
//创建临时矩形
|
|
||||||
CRect rectTemp;
|
|
||||||
//当矩形到达桌面边缘时调整方向和大小
|
|
||||||
if ((pt.x + rect.Width()) >= m_xScreen)
|
|
||||||
{
|
|
||||||
//桌面上方显示不下矩形
|
|
||||||
rectTemp = rect;
|
|
||||||
rectTemp.left = rect.left - rect.Width() - space * 2;
|
|
||||||
rectTemp.right = rect.right - rect.Width() - space * 2;;
|
|
||||||
rect = rectTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((pt.y - rect.Height()) <= 0)
|
|
||||||
{
|
|
||||||
//桌面右方显示不下矩形
|
|
||||||
rectTemp = rect;
|
|
||||||
rectTemp.top = rect.top + rect.Height() + space * 2;;
|
|
||||||
rectTemp.bottom = rect.bottom + rect.Height() + space * 2;;
|
|
||||||
rect = rectTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建空画刷画矩形
|
|
||||||
CBrush * pOldBrush;
|
|
||||||
pOldBrush = pDC->SelectObject(CBrush::FromHandle((HBRUSH)GetStockObject(NULL_BRUSH)));
|
|
||||||
|
|
||||||
pDC->Rectangle(rect);
|
|
||||||
rect.top += 2;
|
|
||||||
//在矩形中显示文字
|
|
||||||
CRect outRect(rect.left, rect.top, rect.left + lineLength, rect.top + charHeight);
|
|
||||||
CString string(_T("顶点位置"));
|
|
||||||
pDC->DrawText(string, outRect, DT_CENTER);
|
|
||||||
|
|
||||||
outRect.SetRect(rect.left, rect.top + charHeight, rect.left + lineLength, charHeight + rect.top + charHeight);
|
|
||||||
string.Format(_T("(%d,%d)"), inRect.left, inRect.top);
|
|
||||||
pDC->DrawText(string, outRect, DT_CENTER);
|
|
||||||
|
|
||||||
|
|
||||||
outRect.SetRect(rect.left, rect.top + charHeight * 2, rect.left + lineLength, charHeight + rect.top + charHeight * 2);
|
|
||||||
string = _T("矩形大小");
|
|
||||||
pDC->DrawText(string, outRect, DT_CENTER);
|
|
||||||
|
|
||||||
outRect.SetRect(rect.left, rect.top + charHeight * 3, rect.left + lineLength, charHeight + rect.top + charHeight * 3);
|
|
||||||
string.Format(_T("(%d,%d)"), inRect.Width(), inRect.Height());
|
|
||||||
pDC->DrawText(string, outRect, DT_CENTER);
|
|
||||||
|
|
||||||
outRect.SetRect(rect.left, rect.top + charHeight * 4, rect.left + lineLength, charHeight + rect.top + charHeight * 4);
|
|
||||||
string = _T("光标坐标");
|
|
||||||
pDC->DrawText(string, outRect, DT_CENTER);
|
|
||||||
|
|
||||||
outRect.SetRect(rect.left, rect.top + charHeight * 5, rect.left + lineLength, charHeight + rect.top + charHeight * 5);
|
|
||||||
string.Format(_T("(%d,%d)"), pt.x, pt.y);
|
|
||||||
pDC->DrawText(string, outRect, DT_CENTER);
|
|
||||||
|
|
||||||
pDC->SetBkMode(OldBkMode);
|
|
||||||
pDC->SelectObject(pOldFont);
|
|
||||||
pDC->SelectObject(pOldBrush);
|
|
||||||
pDC->SelectObject(pOldPen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 刷新局部窗口
|
|
||||||
void CCatchScreenDlg::InvalidateRgnWindow()
|
|
||||||
{
|
|
||||||
//获取当全屏对话框窗口大小
|
|
||||||
CRect rect1;
|
|
||||||
GetWindowRect(rect1);
|
|
||||||
|
|
||||||
//获取编辑框窗口大小
|
|
||||||
CRect rect2;
|
|
||||||
m_tipEdit.GetWindowRect(rect2);
|
|
||||||
|
|
||||||
CRgn rgn1, rgn2;
|
|
||||||
rgn1.CreateRectRgnIndirect(rect1);
|
|
||||||
rgn2.CreateRectRgnIndirect(rect2);
|
|
||||||
|
|
||||||
//获取更新区域,就是除了编辑框窗口不更新
|
|
||||||
//m_rgn.CombineRgn(&rgn1, &rgn2, RGN_DIFF);
|
|
||||||
|
|
||||||
// 添加ToolBar不刷新
|
|
||||||
CRect rect3;
|
|
||||||
::GetWindowRect(m_toolBar.GetHWND(),&rect3);
|
|
||||||
CRgn rgn3;
|
|
||||||
rgn3.CreateRectRgnIndirect(rect3);
|
|
||||||
|
|
||||||
CRgn rgnTemp;
|
|
||||||
rgnTemp.CreateRectRgn(0, 0, 50, 50);
|
|
||||||
rgnTemp.CombineRgn(&rgn1, &rgn2, RGN_DIFF);
|
|
||||||
m_rgn.CombineRgn(&rgnTemp, &rgn3, RGN_DIFF);
|
|
||||||
|
|
||||||
InvalidateRgn(&m_rgn);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::UpdateMousePointRGBString()
|
|
||||||
{
|
|
||||||
static CString strOld("");
|
|
||||||
|
|
||||||
CPoint pt;
|
|
||||||
GetCursorPos(&pt);
|
|
||||||
|
|
||||||
COLORREF color;
|
|
||||||
CClientDC dc(this);
|
|
||||||
color = dc.GetPixel(pt);
|
|
||||||
BYTE rValue, gValue, bValue;
|
|
||||||
rValue = GetRValue(color);
|
|
||||||
gValue = GetGValue(color);
|
|
||||||
bValue = GetGValue(color);
|
|
||||||
|
|
||||||
//按格式排放字符串
|
|
||||||
CString string;
|
|
||||||
string.Format(_T("\r\n\r\n·当前像素RGB(%d,%d,%d)"), rValue, gValue, bValue);
|
|
||||||
|
|
||||||
//如果当前颜色没变则不刷新RGB值,以免窗口有更多闪烁
|
|
||||||
if (strOld != string)
|
|
||||||
{
|
|
||||||
m_strRgb = string;
|
|
||||||
}
|
|
||||||
strOld = string;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CCatchScreenDlg::SetEidtWndText()
|
|
||||||
{
|
|
||||||
m_tipEdit.SetWindowText(this->GetEditText());
|
|
||||||
}
|
|
||||||
|
|
||||||
CString CCatchScreenDlg::GetEditText()
|
|
||||||
{
|
|
||||||
CString str;
|
|
||||||
str.Append(m_strRgb);
|
|
||||||
str.Append(m_strEditTip);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CCatchScreenDlg::OnCommand(WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
bool bHandle = true;
|
|
||||||
HWND hWnd = m_toolBar.GetHWND();
|
|
||||||
if(lParam == (LPARAM)m_toolBar.GetHWND())
|
|
||||||
{
|
|
||||||
int wmId = LOWORD(wParam);
|
|
||||||
switch(wmId)
|
|
||||||
{
|
|
||||||
case MyToolBar_ID:
|
|
||||||
AfxMessageBox(_T("矩形"));
|
|
||||||
break;
|
|
||||||
case MyToolBar_ID+1:
|
|
||||||
AfxMessageBox(_T("圆形"));
|
|
||||||
break;
|
|
||||||
case MyToolBar_ID +2:
|
|
||||||
AfxMessageBox(_T("画笔"));
|
|
||||||
break;
|
|
||||||
case MyToolBar_ID +3:
|
|
||||||
AfxMessageBox(_T("马赛克"));
|
|
||||||
break;
|
|
||||||
case MyToolBar_ID +4:
|
|
||||||
AfxMessageBox(_T("文字"));
|
|
||||||
break;
|
|
||||||
case MyToolBar_ID +5:
|
|
||||||
AfxMessageBox(_T("撤销"));
|
|
||||||
break;
|
|
||||||
case MyToolBar_ID +6:
|
|
||||||
CopyScreenToBitmap(m_rectTracker.m_rect, TRUE);
|
|
||||||
PostQuitMessage(0);
|
|
||||||
break;
|
|
||||||
case MyToolBar_ID +7:
|
|
||||||
PostQuitMessage(0);
|
|
||||||
break;
|
|
||||||
case MyToolBar_ID +8:
|
|
||||||
CopyScreenToBitmap(m_rectTracker.m_rect, TRUE);
|
|
||||||
PostQuitMessage(0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
bHandle = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
::SetFocus(hWnd);
|
|
||||||
}
|
|
||||||
if (bHandle == false)
|
|
||||||
{
|
|
||||||
return CDialog::OnCommand(wParam,lParam);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////// END OF FILE ///////////////////////////////////////
|
|
@ -1,90 +0,0 @@
|
|||||||
#if !defined(AFX_CATCHSCREENDLG_H__536FDBC8_7DB2_4BEF_8943_70DBE8AD845F__INCLUDED_)
|
|
||||||
#define AFX_CATCHSCREENDLG_H__536FDBC8_7DB2_4BEF_8943_70DBE8AD845F__INCLUDED_
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
#include "Resource.h"
|
|
||||||
#include "MyEdit.h"
|
|
||||||
|
|
||||||
#ifndef MYTRACKER_
|
|
||||||
#include "MyTracker.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "MyToolBar.h"
|
|
||||||
//--------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
class CCatchScreenDlg : public CDialog
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
CCatchScreenDlg(CWnd* pParent = NULL);
|
|
||||||
|
|
||||||
enum { IDD = IDD_DIALOGFORIMG };
|
|
||||||
CMyEdit m_tipEdit;
|
|
||||||
CMyToolBar m_toolBar;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
int m_xScreen;
|
|
||||||
int m_yScreen;
|
|
||||||
|
|
||||||
|
|
||||||
BOOL m_bLBtnDown;
|
|
||||||
|
|
||||||
BOOL m_bNeedShowMsg; // 显示截取矩形大小信息
|
|
||||||
BOOL m_bDraw; // 是否为截取状态
|
|
||||||
BOOL m_bFirstDraw; // 是否为首次截取
|
|
||||||
BOOL m_bQuit; // 是否为退出
|
|
||||||
CPoint m_startPt; // 截取矩形左上角位置
|
|
||||||
|
|
||||||
CMyTracker m_rectTracker; // 像皮筋类
|
|
||||||
CBrush m_brush;
|
|
||||||
HCURSOR m_hCursor; // 光标
|
|
||||||
CBitmap* m_pBitmap; // Edit关联控件的背景位图
|
|
||||||
HBITMAP m_hBitmap;
|
|
||||||
|
|
||||||
CRgn m_rgn; // 背景擦除区域
|
|
||||||
|
|
||||||
public:
|
|
||||||
HBITMAP CopyScreenToBitmap(LPRECT lpRect,BOOL bSave=FALSE); /* 拷贝桌面到位图 */
|
|
||||||
void UpdateTipString(); //显示操作提示信息
|
|
||||||
void DrawMessage(CRect &inRect,CDC * pDC); //显示截取矩形信息
|
|
||||||
void InvalidateRgnWindow(); //重画窗口
|
|
||||||
void UpdateMousePointRGBString();
|
|
||||||
|
|
||||||
CString m_strRgb;
|
|
||||||
CString m_strEditTip;
|
|
||||||
|
|
||||||
void SetEidtWndText();
|
|
||||||
CString GetEditText();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void DoDataExchange(CDataExchange* pDX);
|
|
||||||
virtual BOOL OnInitDialog();
|
|
||||||
virtual void OnCancel();
|
|
||||||
|
|
||||||
afx_msg void OnPaint();
|
|
||||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
|
||||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
|
||||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
|
||||||
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
|
|
||||||
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
|
|
||||||
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
|
|
||||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
|
||||||
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
|
|
||||||
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
|
||||||
|
|
||||||
|
|
||||||
DECLARE_MESSAGE_MAP()
|
|
||||||
|
|
||||||
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,120 +0,0 @@
|
|||||||
/******************************************************************************
|
|
||||||
* FileName : MyEdit.CPP
|
|
||||||
* Author : Unknown
|
|
||||||
* Mender : sudami
|
|
||||||
* Time : 2007/09/09
|
|
||||||
*
|
|
||||||
* Comment :
|
|
||||||
*--------------------------------------------------------
|
|
||||||
* 截图程序中的一个控件封装类.
|
|
||||||
* 将控件和该类关联后,可以显示出当前截图的一些提示信息
|
|
||||||
*--------------------------------------------------------
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "MyEdit.h"
|
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 构造函数、析构函数
|
|
||||||
//
|
|
||||||
CMyEdit::CMyEdit()
|
|
||||||
{
|
|
||||||
m_bMove=TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMyEdit::~CMyEdit()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
|
|
||||||
/* 2个小消息 */
|
|
||||||
ON_WM_CREATE()
|
|
||||||
ON_WM_PAINT()
|
|
||||||
ON_WM_SETFOCUS()
|
|
||||||
/* 3个大消息 */
|
|
||||||
ON_WM_MOUSEMOVE()
|
|
||||||
ON_WM_ERASEBKGND()
|
|
||||||
END_MESSAGE_MAP()
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
int CMyEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
||||||
{
|
|
||||||
if (CEdit::OnCreate(lpCreateStruct) == -1)
|
|
||||||
return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CMyEdit::OnPaint()
|
|
||||||
{
|
|
||||||
CPaintDC dc(this);
|
|
||||||
|
|
||||||
CDC dcCompatible;
|
|
||||||
dcCompatible.CreateCompatibleDC(&dc);
|
|
||||||
|
|
||||||
dcCompatible.SetBkMode(TRANSPARENT);
|
|
||||||
CBitmap bitmap;
|
|
||||||
bitmap.LoadBitmap(IDB_BITMAP_BK);
|
|
||||||
dcCompatible.SelectObject(&bitmap);
|
|
||||||
|
|
||||||
RECT rt = {5,5,0,0};
|
|
||||||
RECT rtClient = {0};
|
|
||||||
GetClientRect(&rtClient);
|
|
||||||
rt.right = rtClient.right;
|
|
||||||
rt.bottom = rtClient.bottom;
|
|
||||||
|
|
||||||
CString str;
|
|
||||||
GetWindowText(str);
|
|
||||||
CFont font;
|
|
||||||
CFont * pOldFont;
|
|
||||||
font.CreatePointFont(90, _T("宋体"));
|
|
||||||
pOldFont = dcCompatible.SelectObject(&font);
|
|
||||||
dcCompatible.DrawText(str,&rt,DT_LEFT);
|
|
||||||
dcCompatible.SelectObject(pOldFont);
|
|
||||||
|
|
||||||
CRect rect;
|
|
||||||
GetClientRect(&rect);
|
|
||||||
dc.BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// <响应 WM_MOUSEMOVE 消息>
|
|
||||||
// 和QQ的截图差不多的效果,只要鼠标挪到该控件区域,该区域就变换位置
|
|
||||||
//
|
|
||||||
void CMyEdit::OnMouseMove(UINT nFlags, CPoint point)
|
|
||||||
{
|
|
||||||
CEdit::OnMouseMove(nFlags, point);
|
|
||||||
CRect rect;
|
|
||||||
GetWindowRect(&rect);
|
|
||||||
int xScreen = GetSystemMetrics(SM_CXSCREEN);
|
|
||||||
if(m_bMove)
|
|
||||||
{
|
|
||||||
//移动到左上角
|
|
||||||
MoveWindow(10,10,rect.Width(),rect.Height());
|
|
||||||
m_bMove=FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//移动到右上角
|
|
||||||
MoveWindow(xScreen-180,10,rect.Width(),rect.Height());
|
|
||||||
m_bMove=TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
void CMyEdit::OnSetFocus(CWnd* pOldWnd)
|
|
||||||
{
|
|
||||||
CEdit::OnSetFocus(pOldWnd);
|
|
||||||
|
|
||||||
// 隐藏光标提示符
|
|
||||||
this->HideCaret();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMyEdit::OnEraseBkgnd(CDC* pDC)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*****************************************************************************
|
|
||||||
* FileName : MyEdit.h
|
|
||||||
* Author : Unknown
|
|
||||||
* Mender : sudami
|
|
||||||
* Time : 2007/09/09
|
|
||||||
*
|
|
||||||
* Comment :
|
|
||||||
*--------------------------------------------------------
|
|
||||||
* 截图程序中的一个控件封装类.
|
|
||||||
* 将控件和该类关联后,可以显示出当前截图的一些提示信息
|
|
||||||
*--------------------------------------------------------
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
#if !defined(AFX_MYEDIT_H__A34EEA6D_E8FC_4D15_B03C_BAA42FDF6FCB__INCLUDED_)
|
|
||||||
#define AFX_MYEDIT_H__A34EEA6D_E8FC_4D15_B03C_BAA42FDF6FCB__INCLUDED_
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <afxwin.h>
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class CMyEdit : public CEdit
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMyEdit();
|
|
||||||
virtual ~CMyEdit();
|
|
||||||
|
|
||||||
BOOL m_bMove; // 类似"单刀双掷开关"
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
|
||||||
afx_msg void OnSetFocus(CWnd* pOldWnd);
|
|
||||||
|
|
||||||
afx_msg void OnPaint();
|
|
||||||
|
|
||||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
|
||||||
|
|
||||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
|
||||||
|
|
||||||
DECLARE_MESSAGE_MAP()
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,148 +0,0 @@
|
|||||||
#include "StdAfx.h"
|
|
||||||
#include "MyToolBar.h"
|
|
||||||
#include <GdiPlus.h>
|
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL ImageFromIDResource(UINT nID, LPCTSTR sTR, Gdiplus::Bitmap * & pImg)
|
|
||||||
{
|
|
||||||
HINSTANCE hInst = AfxGetResourceHandle();
|
|
||||||
HRSRC hRsrc = ::FindResource (hInst,MAKEINTRESOURCE(nID),sTR); // type
|
|
||||||
if (!hRsrc)
|
|
||||||
return FALSE;
|
|
||||||
// load resource into memory
|
|
||||||
DWORD len = SizeofResource(hInst, hRsrc);
|
|
||||||
BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc);
|
|
||||||
if (!lpRsrc)
|
|
||||||
return FALSE;
|
|
||||||
// Allocate global memory on which to create stream
|
|
||||||
HGLOBAL m_hMem = GlobalAlloc(GMEM_FIXED, len);
|
|
||||||
BYTE* pmem = (BYTE*)GlobalLock(m_hMem);
|
|
||||||
memcpy(pmem,lpRsrc,len);
|
|
||||||
IStream* pstm;
|
|
||||||
CreateStreamOnHGlobal(m_hMem,FALSE,&pstm);
|
|
||||||
// load from stream
|
|
||||||
pImg=Gdiplus::Bitmap::FromStream(pstm);
|
|
||||||
// free/release stuff
|
|
||||||
GlobalUnlock(m_hMem);
|
|
||||||
pstm->Release();
|
|
||||||
FreeResource(lpRsrc);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMyToolBar::CMyToolBar()
|
|
||||||
{
|
|
||||||
m_hImageList = NULL;
|
|
||||||
m_hWnd_toolbar = 0;
|
|
||||||
m_hWndParent = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMyToolBar::~CMyToolBar(void)
|
|
||||||
{
|
|
||||||
ImageList_Destroy(m_hImageList);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMyToolBar::CreateToolBar(HWND hWndParent)
|
|
||||||
{
|
|
||||||
if (m_hImageList)
|
|
||||||
return FALSE;
|
|
||||||
m_hWndParent = hWndParent;
|
|
||||||
|
|
||||||
m_hImageList= ImageList_Create(18,18,ILC_COLOR32,1,1);
|
|
||||||
Gdiplus::Bitmap * pImage = NULL;
|
|
||||||
for(int i=0;i< 9;i++)
|
|
||||||
{
|
|
||||||
ImageFromIDResource(IDB_RECTANGLE + i,_T("PNG"),pImage);
|
|
||||||
HBITMAP pHbitmap=0;;
|
|
||||||
if(pImage)
|
|
||||||
{
|
|
||||||
pImage->GetHBITMAP(Gdiplus::Color(0xff,0xff,0xff,0xff),&pHbitmap);
|
|
||||||
ImageList_Add(m_hImageList,pHbitmap,NULL);
|
|
||||||
delete pImage;
|
|
||||||
pImage = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_hWnd_toolbar = ::CreateWindowEx(0,TOOLBARCLASSNAME,0,WS_CHILD | WS_VISIBLE|WS_BORDER ,
|
|
||||||
0,0,0,0,hWndParent,NULL,GetModuleHandle(NULL),NULL);
|
|
||||||
|
|
||||||
if (m_hWnd_toolbar == NULL)
|
|
||||||
return FALSE;
|
|
||||||
::SendMessage(m_hWnd_toolbar,TB_SETIMAGELIST, 0, (LPARAM) m_hImageList);
|
|
||||||
::SendMessage(m_hWnd_toolbar,TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
|
||||||
|
|
||||||
|
|
||||||
::SendMessage(m_hWnd_toolbar,
|
|
||||||
(UINT) TB_SETBITMAPSIZE,(WPARAM) 0,//not used, must be zero
|
|
||||||
(LPARAM) MAKELONG (18, 18)// = (LPARAM) MAKELONG (dxBitmap, dyBitmap)
|
|
||||||
);
|
|
||||||
|
|
||||||
//TCHAR tooltips[16][30]={_T("AAAA"),_T("BBBB"),_T("CCCC"),_T("DDDD")};
|
|
||||||
for(int i = 0; i < 9; i++)
|
|
||||||
{
|
|
||||||
TBBUTTON tbbutton;
|
|
||||||
// 换行
|
|
||||||
int wrapnow = 0;
|
|
||||||
//if (i % 2 == 1)
|
|
||||||
// wrapnow = TBSTATE_WRAP;
|
|
||||||
|
|
||||||
ZeroMemory(&tbbutton, sizeof(TBBUTTON));
|
|
||||||
//tbbutton.iString = (INT_PTR) tooltips[i];
|
|
||||||
tbbutton.fsStyle = TBSTYLE_CHECKGROUP; // 单选属性
|
|
||||||
tbbutton.fsState = TBSTATE_ENABLED | wrapnow;
|
|
||||||
tbbutton.idCommand = MyToolBar_ID + i; // 定义控件的id
|
|
||||||
tbbutton.iBitmap = i;
|
|
||||||
|
|
||||||
::SendMessage(m_hWnd_toolbar,TB_ADDBUTTONS, 1, (LPARAM) &tbbutton);
|
|
||||||
}
|
|
||||||
::SendMessage(m_hWnd_toolbar, TB_AUTOSIZE, 0, 0);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
HWND CMyToolBar::GetHWND()
|
|
||||||
{
|
|
||||||
return m_hWnd_toolbar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyToolBar::AddChildStyle()
|
|
||||||
{
|
|
||||||
DWORD dwStyle = GetWindowLong(m_hWnd_toolbar, GWL_STYLE);
|
|
||||||
dwStyle &= WS_CHILD;
|
|
||||||
SetWindowLong(m_hWnd_toolbar,GWL_STYLE,dwStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyToolBar::RemoveChildStyle()
|
|
||||||
{
|
|
||||||
|
|
||||||
DWORD dwStyle = GetWindowLong(m_hWnd_toolbar, GWL_STYLE);
|
|
||||||
dwStyle &= ~WS_CHILD;
|
|
||||||
SetWindowLong(m_hWnd_toolbar,GWL_STYLE,dwStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyToolBar::ShowToolBar()
|
|
||||||
{
|
|
||||||
::ShowWindow(m_hWnd_toolbar,SW_SHOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyToolBar::HideToolBar()
|
|
||||||
{
|
|
||||||
::ShowWindow(m_hWnd_toolbar,SW_HIDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyToolBar::SetAtCurMousePlase()
|
|
||||||
{
|
|
||||||
RECT rtWin = {0};
|
|
||||||
::GetWindowRect(m_hWnd_toolbar,&rtWin);
|
|
||||||
POINT pt = {0};
|
|
||||||
::GetCursorPos(&pt);
|
|
||||||
this->SetShowPlace(pt.x,pt.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyToolBar::SetShowPlace(int nCurPointX,int nCurPointY)
|
|
||||||
{
|
|
||||||
|
|
||||||
RECT rtWin = {0};
|
|
||||||
::GetWindowRect(m_hWnd_toolbar,&rtWin);
|
|
||||||
::SetWindowPos(m_hWnd_toolbar,HWND_TOP,nCurPointX - (rtWin.right-rtWin.left),nCurPointY + 2,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
#define MyToolBar_ID 600
|
|
||||||
|
|
||||||
class CMyToolBar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMyToolBar();
|
|
||||||
~CMyToolBar(void);
|
|
||||||
|
|
||||||
BOOL CreateToolBar(HWND hWndParent);
|
|
||||||
void AddChildStyle();
|
|
||||||
void RemoveChildStyle();
|
|
||||||
void ShowToolBar();
|
|
||||||
void HideToolBar();
|
|
||||||
void SetAtCurMousePlase();
|
|
||||||
void SetShowPlace(int nCurPointX,int nCurPointY);
|
|
||||||
HWND GetHWND();
|
|
||||||
private:
|
|
||||||
HIMAGELIST m_hImageList;
|
|
||||||
HWND m_hWndParent;
|
|
||||||
HWND m_hWnd_toolbar;
|
|
||||||
};
|
|
@ -1,839 +0,0 @@
|
|||||||
// This is a part of the Microsoft Foundation Classes C++ library.
|
|
||||||
// Copyright (C) 1992-1998 Microsoft Corporation
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This source code is only intended as a supplement to the
|
|
||||||
// Microsoft Foundation Classes Reference and related
|
|
||||||
// electronic documentation provided with the library.
|
|
||||||
// See these sources for detailed information regarding the
|
|
||||||
// Microsoft Foundation Classes product.
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "MyTracker.h"
|
|
||||||
#include "Resource.h"
|
|
||||||
#include "CatchScreenDlg.h"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CMyTracker global state
|
|
||||||
|
|
||||||
// various GDI objects we need to draw
|
|
||||||
AFX_STATIC_DATA HCURSOR _afxCursors[10] = { 0,};
|
|
||||||
AFX_STATIC_DATA HBRUSH _afxHatchBrush = 0;
|
|
||||||
AFX_STATIC_DATA HPEN _afxBlackDottedPen = 0;
|
|
||||||
AFX_STATIC_DATA HPEN _afxBlackSolidPen = 0;
|
|
||||||
AFX_STATIC_DATA int _afxHandleSize = 0;
|
|
||||||
|
|
||||||
void AFX_CDECL AfxTrackerTerm()
|
|
||||||
{
|
|
||||||
AfxDeleteObject((HGDIOBJ*)&_afxHatchBrush);
|
|
||||||
AfxDeleteObject((HGDIOBJ*)&_afxBlackDottedPen);
|
|
||||||
}
|
|
||||||
char _afxTrackerTerm = (char)atexit(&AfxTrackerTerm);
|
|
||||||
|
|
||||||
// the struct below is used to determine the qualities of a particular handle
|
|
||||||
struct AFX_HANDLEINFO
|
|
||||||
{
|
|
||||||
size_t nOffsetX; // offset within RECT for X coordinate
|
|
||||||
size_t nOffsetY; // offset within RECT for Y coordinate
|
|
||||||
int nCenterX; // adjust X by Width()/2 * this number
|
|
||||||
int nCenterY; // adjust Y by Height()/2 * this number
|
|
||||||
int nHandleX; // adjust X by handle size * this number
|
|
||||||
int nHandleY; // adjust Y by handle size * this number
|
|
||||||
int nInvertX; // handle converts to this when X inverted
|
|
||||||
int nInvertY; // handle converts to this when Y inverted
|
|
||||||
};
|
|
||||||
|
|
||||||
// this array describes all 8 handles (clock-wise)
|
|
||||||
AFX_STATIC_DATA const AFX_HANDLEINFO _afxHandleInfo[] =
|
|
||||||
{
|
|
||||||
// corner handles (top-left, top-right, bottom-right, bottom-left
|
|
||||||
{ offsetof(RECT, left), offsetof(RECT, top), 0, 0, 0, 0, 1, 3 },
|
|
||||||
{ offsetof(RECT, right), offsetof(RECT, top), 0, 0, -1, 0, 0, 2 },
|
|
||||||
{ offsetof(RECT, right), offsetof(RECT, bottom), 0, 0, -1, -1, 3, 1 },
|
|
||||||
{ offsetof(RECT, left), offsetof(RECT, bottom), 0, 0, 0, -1, 2, 0 },
|
|
||||||
|
|
||||||
// side handles (top, right, bottom, left)
|
|
||||||
{ offsetof(RECT, left), offsetof(RECT, top), 1, 0, 0, 0, 4, 6 },
|
|
||||||
{ offsetof(RECT, right), offsetof(RECT, top), 0, 1, -1, 0, 7, 5 },
|
|
||||||
{ offsetof(RECT, left), offsetof(RECT, bottom), 1, 0, 0, -1, 6, 4 },
|
|
||||||
{ offsetof(RECT, left), offsetof(RECT, top), 0, 1, 0, 0, 5, 7 }
|
|
||||||
};
|
|
||||||
|
|
||||||
// the struct below gives us information on the layout of a RECT struct and
|
|
||||||
// the relationship between its members
|
|
||||||
struct AFX_RECTINFO
|
|
||||||
{
|
|
||||||
size_t nOffsetAcross; // offset of opposite point (ie. left->right)
|
|
||||||
int nSignAcross; // sign relative to that point (ie. add/subtract)
|
|
||||||
};
|
|
||||||
|
|
||||||
// this array is indexed by the offset of the RECT member / sizeof(int)
|
|
||||||
AFX_STATIC_DATA const AFX_RECTINFO _afxRectInfo[] =
|
|
||||||
{
|
|
||||||
{ offsetof(RECT, right), +1 },
|
|
||||||
{ offsetof(RECT, bottom), +1 },
|
|
||||||
{ offsetof(RECT, left), -1 },
|
|
||||||
{ offsetof(RECT, top), -1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CMyTracker intitialization
|
|
||||||
|
|
||||||
CMyTracker::CMyTracker(LPCRECT lpSrcRect, UINT nStyle)
|
|
||||||
{
|
|
||||||
ASSERT(AfxIsValidAddress(lpSrcRect, sizeof(RECT), FALSE));
|
|
||||||
|
|
||||||
Construct();
|
|
||||||
m_rect.CopyRect(lpSrcRect);
|
|
||||||
m_nStyle = nStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMyTracker::CMyTracker()
|
|
||||||
{
|
|
||||||
Construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyTracker::Construct()
|
|
||||||
{
|
|
||||||
// do one-time initialization if necessary
|
|
||||||
//********************************************************
|
|
||||||
m_rectColor=RGB(0,0,0);
|
|
||||||
//********************************************************
|
|
||||||
AfxLockGlobals(CRIT_RECTTRACKER);
|
|
||||||
static BOOL bInitialized;
|
|
||||||
if (!bInitialized)
|
|
||||||
{
|
|
||||||
// sanity checks for assumptions we make in the code
|
|
||||||
ASSERT(sizeof(((RECT*)NULL)->left) == sizeof(int));
|
|
||||||
ASSERT(offsetof(RECT, top) > offsetof(RECT, left));
|
|
||||||
ASSERT(offsetof(RECT, right) > offsetof(RECT, top));
|
|
||||||
ASSERT(offsetof(RECT, bottom) > offsetof(RECT, right));
|
|
||||||
|
|
||||||
if (_afxHatchBrush == NULL)
|
|
||||||
{
|
|
||||||
// create the hatch pattern + bitmap
|
|
||||||
WORD hatchPattern[8];
|
|
||||||
WORD wPattern = 0x1111;
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
hatchPattern[i] = wPattern;
|
|
||||||
hatchPattern[i+4] = wPattern;
|
|
||||||
wPattern <<= 1;
|
|
||||||
}
|
|
||||||
HBITMAP hatchBitmap = CreateBitmap(8, 8, 1, 1, &hatchPattern);
|
|
||||||
if (hatchBitmap == NULL)
|
|
||||||
{
|
|
||||||
AfxUnlockGlobals(CRIT_RECTTRACKER);
|
|
||||||
AfxThrowResourceException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// create black hatched brush
|
|
||||||
_afxHatchBrush = CreatePatternBrush(hatchBitmap);
|
|
||||||
DeleteObject(hatchBitmap);
|
|
||||||
if (_afxHatchBrush == NULL)
|
|
||||||
{
|
|
||||||
AfxUnlockGlobals(CRIT_RECTTRACKER);
|
|
||||||
AfxThrowResourceException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//CreatePen for DottedLine and SolidLine
|
|
||||||
CreatePen();
|
|
||||||
|
|
||||||
// Note: all track cursors must live in same module
|
|
||||||
HINSTANCE hInst = AfxFindResourceHandle(
|
|
||||||
MAKEINTRESOURCE(AFX_IDC_TRACK4WAY), RT_GROUP_CURSOR);
|
|
||||||
|
|
||||||
// initialize the cursor array
|
|
||||||
_afxCursors[0] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNWSE));
|
|
||||||
_afxCursors[1] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNESW));
|
|
||||||
_afxCursors[2] = _afxCursors[0];
|
|
||||||
_afxCursors[3] = _afxCursors[1];
|
|
||||||
_afxCursors[4] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKNS));
|
|
||||||
_afxCursors[5] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACKWE));
|
|
||||||
_afxCursors[6] = _afxCursors[4];
|
|
||||||
_afxCursors[7] = _afxCursors[5];
|
|
||||||
_afxCursors[8] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_TRACK4WAY));
|
|
||||||
_afxCursors[9] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_MOVE4WAY));
|
|
||||||
|
|
||||||
// get default handle size from Windows profile setting
|
|
||||||
static const TCHAR szWindows[] = _T("windows");
|
|
||||||
static const TCHAR szInplaceBorderWidth[] =
|
|
||||||
_T("oleinplaceborderwidth");
|
|
||||||
_afxHandleSize = GetProfileInt(szWindows, szInplaceBorderWidth, 4);
|
|
||||||
bInitialized = TRUE;
|
|
||||||
}
|
|
||||||
AfxUnlockGlobals(CRIT_RECTTRACKER);
|
|
||||||
|
|
||||||
m_nStyle = 0;
|
|
||||||
m_nHandleSize = _afxHandleSize;
|
|
||||||
m_sizeMin.cy = m_sizeMin.cx = m_nHandleSize*2;
|
|
||||||
|
|
||||||
m_rectLast.SetRectEmpty();
|
|
||||||
m_sizeLast.cx = m_sizeLast.cy = 0;
|
|
||||||
m_bErase = FALSE;
|
|
||||||
m_bFinalErase = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMyTracker::~CMyTracker()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CMyTracker operations
|
|
||||||
|
|
||||||
void CMyTracker::Draw(CDC* pDC) const
|
|
||||||
{
|
|
||||||
// set initial DC state
|
|
||||||
VERIFY(pDC->SaveDC() != 0);
|
|
||||||
pDC->SetMapMode(MM_TEXT);
|
|
||||||
pDC->SetViewportOrg(0, 0);
|
|
||||||
pDC->SetWindowOrg(0, 0);
|
|
||||||
|
|
||||||
// get normalized rectangle
|
|
||||||
CRect rect = m_rect;
|
|
||||||
rect.NormalizeRect();
|
|
||||||
|
|
||||||
CPen* pOldPen = NULL;
|
|
||||||
CBrush* pOldBrush = NULL;
|
|
||||||
CGdiObject* pTemp;
|
|
||||||
int nOldROP;
|
|
||||||
|
|
||||||
// draw lines
|
|
||||||
if ((m_nStyle & (dottedLine|solidLine)) != 0)
|
|
||||||
{
|
|
||||||
if (m_nStyle & dottedLine)
|
|
||||||
{
|
|
||||||
//改变当前矩形颜色
|
|
||||||
pOldPen = pDC->SelectObject(CPen::FromHandle(_afxBlackDottedPen));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//改变当前矩形颜色
|
|
||||||
//pOldPen = (CPen*)pDC->SelectStockObject(BLACK_PEN); //BLACK_PEN
|
|
||||||
pOldPen = pDC->SelectObject(CPen::FromHandle(_afxBlackSolidPen));
|
|
||||||
}
|
|
||||||
|
|
||||||
pOldBrush = (CBrush*)pDC->SelectStockObject(NULL_BRUSH);
|
|
||||||
nOldROP = pDC->SetROP2(R2_COPYPEN);
|
|
||||||
rect.InflateRect(+1, +1); // borders are one pixel outside
|
|
||||||
pDC->Rectangle(rect.left, rect.top, rect.right, rect.bottom);
|
|
||||||
pDC->SetROP2(nOldROP);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if hatchBrush is going to be used, need to unrealize it
|
|
||||||
if ((m_nStyle & (hatchInside|hatchedBorder)) != 0)
|
|
||||||
UnrealizeObject(_afxHatchBrush);
|
|
||||||
|
|
||||||
// hatch inside
|
|
||||||
if ((m_nStyle & hatchInside) != 0)
|
|
||||||
{
|
|
||||||
pTemp = pDC->SelectStockObject(NULL_PEN);
|
|
||||||
if (pOldPen == NULL)
|
|
||||||
pOldPen = (CPen*)pTemp;
|
|
||||||
pTemp = pDC->SelectObject(CBrush::FromHandle(_afxHatchBrush));
|
|
||||||
if (pOldBrush == NULL)
|
|
||||||
pOldBrush = (CBrush*)pTemp;
|
|
||||||
pDC->SetBkMode(TRANSPARENT);
|
|
||||||
nOldROP = pDC->SetROP2(R2_MASKNOTPEN);
|
|
||||||
pDC->Rectangle(rect.left+1, rect.top+1, rect.right, rect.bottom);
|
|
||||||
pDC->SetROP2(nOldROP);
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw hatched border
|
|
||||||
if ((m_nStyle & hatchedBorder) != 0)
|
|
||||||
{
|
|
||||||
pTemp = pDC->SelectObject(CBrush::FromHandle(_afxHatchBrush));
|
|
||||||
if (pOldBrush == NULL)
|
|
||||||
pOldBrush = (CBrush*)pTemp;
|
|
||||||
pDC->SetBkMode(OPAQUE);
|
|
||||||
CRect rectTrue;
|
|
||||||
GetTrueRect(&rectTrue);
|
|
||||||
pDC->PatBlt(rectTrue.left, rectTrue.top, rectTrue.Width(),
|
|
||||||
rect.top-rectTrue.top, 0x000F0001 /* Pn */);
|
|
||||||
pDC->PatBlt(rectTrue.left, rect.bottom,
|
|
||||||
rectTrue.Width(), rectTrue.bottom-rect.bottom, 0x000F0001 /* Pn */);
|
|
||||||
pDC->PatBlt(rectTrue.left, rect.top, rect.left-rectTrue.left,
|
|
||||||
rect.Height(), 0x000F0001 /* Pn */);
|
|
||||||
pDC->PatBlt(rect.right, rect.top, rectTrue.right-rect.right,
|
|
||||||
rect.Height(), 0x000F0001 /* Pn */);
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw resize handles
|
|
||||||
if ((m_nStyle & (resizeInside|resizeOutside)) != 0)
|
|
||||||
{
|
|
||||||
UINT mask = GetHandleMask();
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
{
|
|
||||||
if (mask & (1<<i))
|
|
||||||
{
|
|
||||||
GetHandleRect((TrackerHit)i, &rect);
|
|
||||||
//改变当前调整手柄矩形颜色,也就是那八个点
|
|
||||||
pDC->FillSolidRect(rect, m_rectColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// cleanup pDC state
|
|
||||||
if (pOldPen != NULL)
|
|
||||||
pDC->SelectObject(pOldPen);
|
|
||||||
if (pOldBrush != NULL)
|
|
||||||
pDC->SelectObject(pOldBrush);
|
|
||||||
VERIFY(pDC->RestoreDC(-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMyTracker::SetCursor(CWnd* pWnd, UINT nHitTest) const
|
|
||||||
{
|
|
||||||
// trackers should only be in client area
|
|
||||||
if (nHitTest != HTCLIENT)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
// convert cursor position to client co-ordinates
|
|
||||||
CPoint point;
|
|
||||||
GetCursorPos(&point);
|
|
||||||
pWnd->ScreenToClient(&point);
|
|
||||||
|
|
||||||
// do hittest and normalize hit
|
|
||||||
int nHandle = HitTestHandles(point);
|
|
||||||
if (nHandle < 0)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
// need to normalize the hittest such that we get proper cursors
|
|
||||||
nHandle = NormalizeHit(nHandle);
|
|
||||||
|
|
||||||
// handle special case of hitting area between handles
|
|
||||||
// (logically the same -- handled as a move -- but different cursor)
|
|
||||||
if (nHandle == hitMiddle && !m_rect.PtInRect(point))
|
|
||||||
{
|
|
||||||
// only for trackers with hatchedBorder (ie. in-place resizing)
|
|
||||||
if (m_nStyle & hatchedBorder)
|
|
||||||
nHandle = (TrackerHit)9;
|
|
||||||
}
|
|
||||||
|
|
||||||
//ASSERT(nHandle < _countof(_afxCursors));
|
|
||||||
::SetCursor(_afxCursors[nHandle]);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CMyTracker::HitTest(CPoint point) const
|
|
||||||
{
|
|
||||||
TrackerHit hitResult = hitNothing;
|
|
||||||
|
|
||||||
CRect rectTrue;
|
|
||||||
GetTrueRect(&rectTrue);
|
|
||||||
ASSERT(rectTrue.left <= rectTrue.right);
|
|
||||||
ASSERT(rectTrue.top <= rectTrue.bottom);
|
|
||||||
if (rectTrue.PtInRect(point))
|
|
||||||
{
|
|
||||||
if ((m_nStyle & (resizeInside|resizeOutside)) != 0)
|
|
||||||
hitResult = (TrackerHit)HitTestHandles(point);
|
|
||||||
else
|
|
||||||
hitResult = hitMiddle;
|
|
||||||
}
|
|
||||||
return hitResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CMyTracker::NormalizeHit(int nHandle) const
|
|
||||||
{
|
|
||||||
ASSERT(nHandle <= 8 && nHandle >= -1);
|
|
||||||
if (nHandle == hitMiddle || nHandle == hitNothing)
|
|
||||||
return nHandle;
|
|
||||||
const AFX_HANDLEINFO* pHandleInfo = &_afxHandleInfo[nHandle];
|
|
||||||
if (m_rect.Width() < 0)
|
|
||||||
{
|
|
||||||
nHandle = (TrackerHit)pHandleInfo->nInvertX;
|
|
||||||
pHandleInfo = &_afxHandleInfo[nHandle];
|
|
||||||
}
|
|
||||||
if (m_rect.Height() < 0)
|
|
||||||
nHandle = (TrackerHit)pHandleInfo->nInvertY;
|
|
||||||
return nHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMyTracker::Track(CWnd* pWnd, CPoint point, BOOL bAllowInvert,
|
|
||||||
CWnd* pWndClipTo)
|
|
||||||
{
|
|
||||||
// perform hit testing on the handles
|
|
||||||
int nHandle = HitTestHandles(point);
|
|
||||||
if (nHandle < 0)
|
|
||||||
{
|
|
||||||
// didn't hit a handle, so just return FALSE
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// otherwise, call helper function to do the tracking
|
|
||||||
m_bAllowInvert = bAllowInvert;
|
|
||||||
return TrackHandle(nHandle, pWnd, point, pWndClipTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMyTracker::TrackRubberBand(CWnd* pWnd, CPoint point, BOOL bAllowInvert)
|
|
||||||
{
|
|
||||||
// simply call helper function to track from bottom right handle
|
|
||||||
m_bAllowInvert = bAllowInvert;
|
|
||||||
m_rect.SetRect(point.x, point.y, point.x, point.y);
|
|
||||||
return TrackHandle(hitBottomRight, pWnd, point, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyTracker::DrawTrackerRect(
|
|
||||||
LPCRECT lpRect, CWnd* pWndClipTo, CDC* pDC, CWnd* pWnd)
|
|
||||||
{
|
|
||||||
// first, normalize the rectangle for drawing
|
|
||||||
|
|
||||||
/*CRect rect = *lpRect;
|
|
||||||
rect.NormalizeRect();
|
|
||||||
|
|
||||||
// convert to client coordinates
|
|
||||||
if (pWndClipTo != NULL)
|
|
||||||
{
|
|
||||||
pWnd->ClientToScreen(&rect);
|
|
||||||
pWndClipTo->ScreenToClient(&rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
CSize size(0, 0);
|
|
||||||
if (!m_bFinalErase)
|
|
||||||
{
|
|
||||||
// otherwise, size depends on the style
|
|
||||||
if (m_nStyle & hatchedBorder)
|
|
||||||
{
|
|
||||||
size.cx = size.cy = max(1, GetHandleSize(rect)-1);
|
|
||||||
rect.InflateRect(size);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
size.cx = CX_BORDER;
|
|
||||||
size.cy = CY_BORDER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// and draw it
|
|
||||||
if (m_bFinalErase || !m_bErase)
|
|
||||||
{
|
|
||||||
pDC->DrawDragRect(rect, size, m_rectLast, m_sizeLast);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remember last rectangles
|
|
||||||
m_rectLast = rect;
|
|
||||||
m_sizeLast = size;
|
|
||||||
*/
|
|
||||||
//此函数是画调整大小和位置时画虚线
|
|
||||||
//由于本程序不需要,如果要正常使作的话把上面注示去掉就行了!
|
|
||||||
((CCatchScreenDlg *)pWnd)->InvalidateRgnWindow();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyTracker::AdjustRect(int nHandle, LPRECT)
|
|
||||||
{
|
|
||||||
if (nHandle == hitMiddle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// convert the handle into locations within m_rect
|
|
||||||
int *px, *py;
|
|
||||||
GetModifyPointers(nHandle, &px, &py, NULL, NULL);
|
|
||||||
|
|
||||||
// enforce minimum width
|
|
||||||
int nNewWidth = m_rect.Width();
|
|
||||||
int nAbsWidth = m_bAllowInvert ? abs(nNewWidth) : nNewWidth;
|
|
||||||
if (px != NULL && nAbsWidth < m_sizeMin.cx)
|
|
||||||
{
|
|
||||||
nNewWidth = nAbsWidth != 0 ? nNewWidth / nAbsWidth : 1;
|
|
||||||
//ASSERT((int*)px - (int*)&m_rect < _countof(_afxRectInfo));
|
|
||||||
const AFX_RECTINFO* pRectInfo = &_afxRectInfo[(int*)px - (int*)&m_rect];
|
|
||||||
*px = *(int*)((BYTE*)&m_rect + pRectInfo->nOffsetAcross) +
|
|
||||||
nNewWidth * m_sizeMin.cx * -pRectInfo->nSignAcross;
|
|
||||||
}
|
|
||||||
|
|
||||||
// enforce minimum height
|
|
||||||
int nNewHeight = m_rect.Height();
|
|
||||||
int nAbsHeight = m_bAllowInvert ? abs(nNewHeight) : nNewHeight;
|
|
||||||
if (py != NULL && nAbsHeight < m_sizeMin.cy)
|
|
||||||
{
|
|
||||||
nNewHeight = nAbsHeight != 0 ? nNewHeight / nAbsHeight : 1;
|
|
||||||
//ASSERT((int*)py - (int*)&m_rect < _countof(_afxRectInfo));
|
|
||||||
const AFX_RECTINFO* pRectInfo = &_afxRectInfo[(int*)py - (int*)&m_rect];
|
|
||||||
*py = *(int*)((BYTE*)&m_rect + pRectInfo->nOffsetAcross) +
|
|
||||||
nNewHeight * m_sizeMin.cy * -pRectInfo->nSignAcross;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyTracker::GetTrueRect(LPRECT lpTrueRect) const
|
|
||||||
{
|
|
||||||
ASSERT(AfxIsValidAddress(lpTrueRect, sizeof(RECT)));
|
|
||||||
|
|
||||||
CRect rect = m_rect;
|
|
||||||
rect.NormalizeRect();
|
|
||||||
int nInflateBy = 0;
|
|
||||||
if ((m_nStyle & (resizeOutside|hatchedBorder)) != 0)
|
|
||||||
nInflateBy += GetHandleSize() - 1;
|
|
||||||
if ((m_nStyle & (solidLine|dottedLine)) != 0)
|
|
||||||
++nInflateBy;
|
|
||||||
rect.InflateRect(nInflateBy, nInflateBy);
|
|
||||||
*lpTrueRect = rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyTracker::OnChangedRect(const CRect& /*rectOld*/)
|
|
||||||
{
|
|
||||||
// no default implementation, useful for derived classes
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CMyTracker implementation helpers
|
|
||||||
|
|
||||||
void CMyTracker::GetHandleRect(int nHandle, CRect* pHandleRect) const
|
|
||||||
{
|
|
||||||
ASSERT(nHandle < 8);
|
|
||||||
|
|
||||||
// get normalized rectangle of the tracker
|
|
||||||
CRect rectT = m_rect;
|
|
||||||
rectT.NormalizeRect();
|
|
||||||
if ((m_nStyle & (solidLine|dottedLine)) != 0)
|
|
||||||
rectT.InflateRect(+1, +1);
|
|
||||||
|
|
||||||
// since the rectangle itself was normalized, we also have to invert the
|
|
||||||
// resize handles.
|
|
||||||
nHandle = NormalizeHit(nHandle);
|
|
||||||
|
|
||||||
// handle case of resize handles outside the tracker
|
|
||||||
int size = GetHandleSize();
|
|
||||||
|
|
||||||
if(m_nStyle & resizeOutside)
|
|
||||||
{
|
|
||||||
if(1000000 & m_nStyle)
|
|
||||||
{
|
|
||||||
rectT.InflateRect(size-size/2-1, size-size/2-1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rectT.InflateRect(size-1, size-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate position of the resize handle
|
|
||||||
int nWidth = rectT.Width();
|
|
||||||
int nHeight = rectT.Height();
|
|
||||||
CRect rect;
|
|
||||||
const AFX_HANDLEINFO* pHandleInfo = &_afxHandleInfo[nHandle];
|
|
||||||
rect.left = *(int*)((BYTE*)&rectT + pHandleInfo->nOffsetX);
|
|
||||||
rect.top = *(int*)((BYTE*)&rectT + pHandleInfo->nOffsetY);
|
|
||||||
rect.left += size * pHandleInfo->nHandleX;
|
|
||||||
rect.top += size * pHandleInfo->nHandleY;
|
|
||||||
rect.left += pHandleInfo->nCenterX * (nWidth - size) / 2;
|
|
||||||
rect.top += pHandleInfo->nCenterY * (nHeight - size) / 2;
|
|
||||||
rect.right = rect.left + size;
|
|
||||||
rect.bottom = rect.top + size;
|
|
||||||
|
|
||||||
*pHandleRect = rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CMyTracker::GetHandleSize(LPCRECT lpRect) const
|
|
||||||
{
|
|
||||||
if (lpRect == NULL)
|
|
||||||
lpRect = &m_rect;
|
|
||||||
|
|
||||||
int size = m_nHandleSize;
|
|
||||||
if (!(m_nStyle & resizeOutside))
|
|
||||||
{
|
|
||||||
// make sure size is small enough for the size of the rect
|
|
||||||
int sizeMax = min(abs(lpRect->right - lpRect->left),
|
|
||||||
abs(lpRect->bottom - lpRect->top));
|
|
||||||
if (size * 2 > sizeMax)
|
|
||||||
size = sizeMax / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CMyTracker::HitTestHandles(CPoint point) const
|
|
||||||
{
|
|
||||||
CRect rect;
|
|
||||||
UINT mask = GetHandleMask();
|
|
||||||
|
|
||||||
// see if hit anywhere inside the tracker
|
|
||||||
GetTrueRect(&rect);
|
|
||||||
if (!rect.PtInRect(point))
|
|
||||||
return hitNothing; // totally missed
|
|
||||||
|
|
||||||
// see if we hit a handle
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
{
|
|
||||||
if (mask & (1<<i))
|
|
||||||
{
|
|
||||||
GetHandleRect((TrackerHit)i, &rect);
|
|
||||||
if (rect.PtInRect(point))
|
|
||||||
return (TrackerHit)i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// last of all, check for non-hit outside of object, between resize handles
|
|
||||||
if ((m_nStyle & hatchedBorder) == 0)
|
|
||||||
{
|
|
||||||
CRect rect = m_rect;
|
|
||||||
rect.NormalizeRect();
|
|
||||||
if ((m_nStyle & dottedLine|solidLine) != 0)
|
|
||||||
rect.InflateRect(+1, +1);
|
|
||||||
if (!rect.PtInRect(point))
|
|
||||||
return hitNothing; // must have been between resize handles
|
|
||||||
}
|
|
||||||
return hitMiddle; // no handle hit, but hit object (or object border)
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMyTracker::TrackHandle(int nHandle, CWnd* pWnd, CPoint point,
|
|
||||||
CWnd* pWndClipTo)
|
|
||||||
{
|
|
||||||
ASSERT(nHandle >= 0);
|
|
||||||
ASSERT(nHandle <= 8); // handle 8 is inside the rect
|
|
||||||
|
|
||||||
// don't handle if capture already set
|
|
||||||
if (::GetCapture() != NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
AfxLockTempMaps(); // protect maps while looping
|
|
||||||
|
|
||||||
ASSERT(!m_bFinalErase);
|
|
||||||
|
|
||||||
// save original width & height in pixels
|
|
||||||
int nWidth = m_rect.Width();
|
|
||||||
int nHeight = m_rect.Height();
|
|
||||||
|
|
||||||
// set capture to the window which received this message
|
|
||||||
pWnd->SetCapture();
|
|
||||||
ASSERT(pWnd == CWnd::GetCapture());
|
|
||||||
pWnd->UpdateWindow();
|
|
||||||
if (pWndClipTo != NULL)
|
|
||||||
pWndClipTo->UpdateWindow();
|
|
||||||
CRect rectSave = m_rect;
|
|
||||||
|
|
||||||
// find out what x/y coords we are supposed to modify
|
|
||||||
int *px, *py;
|
|
||||||
int xDiff, yDiff;
|
|
||||||
GetModifyPointers(nHandle, &px, &py, &xDiff, &yDiff);
|
|
||||||
xDiff = point.x - xDiff;
|
|
||||||
yDiff = point.y - yDiff;
|
|
||||||
|
|
||||||
// get DC for drawing
|
|
||||||
CDC* pDrawDC;
|
|
||||||
if (pWndClipTo != NULL)
|
|
||||||
{
|
|
||||||
// clip to arbitrary window by using adjusted Window DC
|
|
||||||
pDrawDC = pWndClipTo->GetDCEx(NULL, DCX_CACHE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// otherwise, just use normal DC
|
|
||||||
pDrawDC = pWnd->GetDC();
|
|
||||||
}
|
|
||||||
ASSERT_VALID(pDrawDC);
|
|
||||||
|
|
||||||
CRect rectOld;
|
|
||||||
BOOL bMoved = FALSE;
|
|
||||||
|
|
||||||
// get messages until capture lost or cancelled/accepted
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
MSG msg;
|
|
||||||
VERIFY(::GetMessage(&msg, NULL, 0, 0));
|
|
||||||
|
|
||||||
if (CWnd::GetCapture() != pWnd)
|
|
||||||
break;
|
|
||||||
|
|
||||||
//增加的,把消息派送给窗口
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
|
|
||||||
switch (msg.message)
|
|
||||||
{
|
|
||||||
// handle movement/accept messages
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
case WM_MOUSEMOVE:
|
|
||||||
rectOld = m_rect;
|
|
||||||
// handle resize cases (and part of move)
|
|
||||||
if (px != NULL)
|
|
||||||
*px = (int)(short)LOWORD(msg.lParam) - xDiff;
|
|
||||||
if (py != NULL)
|
|
||||||
*py = (int)(short)HIWORD(msg.lParam) - yDiff;
|
|
||||||
|
|
||||||
// handle move case
|
|
||||||
if (nHandle == hitMiddle)
|
|
||||||
{
|
|
||||||
m_rect.right = m_rect.left + nWidth;
|
|
||||||
m_rect.bottom = m_rect.top + nHeight;
|
|
||||||
}
|
|
||||||
// allow caller to adjust the rectangle if necessary
|
|
||||||
AdjustRect(nHandle, &m_rect);
|
|
||||||
|
|
||||||
// only redraw and callback if the rect actually changed!
|
|
||||||
m_bFinalErase = (msg.message == WM_LBUTTONUP);
|
|
||||||
if (!rectOld.EqualRect(&m_rect) || m_bFinalErase)
|
|
||||||
{
|
|
||||||
if (bMoved)
|
|
||||||
{
|
|
||||||
m_bErase = TRUE;
|
|
||||||
DrawTrackerRect(&rectOld, pWndClipTo, pDrawDC, pWnd);
|
|
||||||
}
|
|
||||||
OnChangedRect(rectOld);
|
|
||||||
if (msg.message != WM_LBUTTONUP)
|
|
||||||
{
|
|
||||||
bMoved = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m_bFinalErase)
|
|
||||||
goto ExitLoop;
|
|
||||||
|
|
||||||
if (!rectOld.EqualRect(&m_rect))
|
|
||||||
{
|
|
||||||
m_bErase = FALSE;
|
|
||||||
DrawTrackerRect(&m_rect, pWndClipTo, pDrawDC, pWnd);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// handle cancel messages
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
if (msg.wParam != VK_ESCAPE)
|
|
||||||
break;
|
|
||||||
case WM_RBUTTONDOWN:
|
|
||||||
if (bMoved)
|
|
||||||
{
|
|
||||||
m_bErase = m_bFinalErase = TRUE;
|
|
||||||
//DrawTrackerRect(&m_rect, pWndClipTo, pDrawDC, pWnd);
|
|
||||||
}
|
|
||||||
m_rect = rectSave;
|
|
||||||
goto ExitLoop;
|
|
||||||
|
|
||||||
// just dispatch rest of the messages
|
|
||||||
default:
|
|
||||||
DispatchMessage(&msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ExitLoop:
|
|
||||||
if (pWndClipTo != NULL)
|
|
||||||
pWndClipTo->ReleaseDC(pDrawDC);
|
|
||||||
else
|
|
||||||
pWnd->ReleaseDC(pDrawDC);
|
|
||||||
ReleaseCapture();
|
|
||||||
|
|
||||||
AfxUnlockTempMaps(FALSE);
|
|
||||||
|
|
||||||
// restore rect in case bMoved is still FALSE
|
|
||||||
if (!bMoved)
|
|
||||||
m_rect = rectSave;
|
|
||||||
m_bFinalErase = FALSE;
|
|
||||||
m_bErase = FALSE;
|
|
||||||
|
|
||||||
// return TRUE only if rect has changed
|
|
||||||
return !rectSave.EqualRect(&m_rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyTracker::GetModifyPointers(
|
|
||||||
int nHandle, int** ppx, int** ppy, int* px, int* py)
|
|
||||||
{
|
|
||||||
ASSERT(nHandle >= 0);
|
|
||||||
ASSERT(nHandle <= 8);
|
|
||||||
|
|
||||||
if (nHandle == hitMiddle)
|
|
||||||
nHandle = hitTopLeft; // same as hitting top-left
|
|
||||||
|
|
||||||
*ppx = NULL;
|
|
||||||
*ppy = NULL;
|
|
||||||
|
|
||||||
// fill in the part of the rect that this handle modifies
|
|
||||||
// (Note: handles that map to themselves along a given axis when that
|
|
||||||
// axis is inverted don't modify the value on that axis)
|
|
||||||
|
|
||||||
const AFX_HANDLEINFO* pHandleInfo = &_afxHandleInfo[nHandle];
|
|
||||||
if (pHandleInfo->nInvertX != nHandle)
|
|
||||||
{
|
|
||||||
*ppx = (int*)((BYTE*)&m_rect + pHandleInfo->nOffsetX);
|
|
||||||
if (px != NULL)
|
|
||||||
*px = **ppx;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// middle handle on X axis
|
|
||||||
if (px != NULL)
|
|
||||||
*px = m_rect.left + abs(m_rect.Width()) / 2;
|
|
||||||
}
|
|
||||||
if (pHandleInfo->nInvertY != nHandle)
|
|
||||||
{
|
|
||||||
*ppy = (int*)((BYTE*)&m_rect + pHandleInfo->nOffsetY);
|
|
||||||
if (py != NULL)
|
|
||||||
*py = **ppy;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// middle handle on Y axis
|
|
||||||
if (py != NULL)
|
|
||||||
*py = m_rect.top + abs(m_rect.Height()) / 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT CMyTracker::GetHandleMask() const
|
|
||||||
{
|
|
||||||
UINT mask = 0x0F; // always have 4 corner handles
|
|
||||||
int size = m_nHandleSize*3;
|
|
||||||
if (abs(m_rect.Width()) - size > 4)
|
|
||||||
mask |= 0x50;
|
|
||||||
if (abs(m_rect.Height()) - size > 4)
|
|
||||||
mask |= 0xA0;
|
|
||||||
return mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////增加的函数/////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void CMyTracker::SetRectColor(COLORREF rectColor)
|
|
||||||
{
|
|
||||||
m_rectColor=rectColor;
|
|
||||||
CreatePen();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyTracker::CreatePen()
|
|
||||||
{
|
|
||||||
//if (_afxBlackDottedPen == NULL)
|
|
||||||
{
|
|
||||||
// create black dotted pen
|
|
||||||
_afxBlackDottedPen = ::CreatePen(PS_DOT, 0, m_rectColor);
|
|
||||||
if (_afxBlackDottedPen == NULL)
|
|
||||||
{
|
|
||||||
AfxUnlockGlobals(CRIT_RECTTRACKER);
|
|
||||||
AfxThrowResourceException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if (_afxBlackSolidPen == NULL)
|
|
||||||
{
|
|
||||||
// create black dotted pen
|
|
||||||
_afxBlackSolidPen = ::CreatePen(PS_SOLID, 0, m_rectColor);
|
|
||||||
if (_afxBlackSolidPen == NULL)
|
|
||||||
{
|
|
||||||
AfxUnlockGlobals(CRIT_RECTTRACKER);
|
|
||||||
AfxThrowResourceException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMyTracker::SetResizeCursor(UINT nID_N_S,UINT nID_W_E,UINT nID_NW_SE,UINT nID_NE_SW,UINT nIDMiddle)
|
|
||||||
{
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// N
|
|
||||||
// NW -----------|------------NE
|
|
||||||
// | |
|
|
||||||
// | |
|
|
||||||
// W | | E
|
|
||||||
// | Middle |
|
|
||||||
// | |
|
|
||||||
// | |
|
|
||||||
// SW-----------|------------SE
|
|
||||||
// S
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
_afxCursors[0] = AfxGetApp()->LoadCursor(nID_NW_SE); //nw
|
|
||||||
_afxCursors[1] = AfxGetApp()->LoadCursor(nID_NE_SW); //ne
|
|
||||||
_afxCursors[2] = _afxCursors[0]; //se
|
|
||||||
_afxCursors[3] = _afxCursors[1]; //sw
|
|
||||||
_afxCursors[4] = AfxGetApp()->LoadCursor(nID_N_S); //n
|
|
||||||
_afxCursors[5] = AfxGetApp()->LoadCursor(nID_W_E); //w
|
|
||||||
_afxCursors[6] = _afxCursors[4]; //s
|
|
||||||
_afxCursors[7] = _afxCursors[5]; //e
|
|
||||||
_afxCursors[8] = AfxGetApp()->LoadCursor(nIDMiddle); //m
|
|
||||||
// _afxCursors[9] = ::LoadCursor(hInst, MAKEINTRESOURCE(AFX_IDC_MOVE4WAY));
|
|
||||||
}
|
|
@ -1,102 +0,0 @@
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// CMyTracker - simple rectangular tracking rectangle w/resize handles
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
||||||
// Copy from MFC CRectTracker class
|
|
||||||
// Add Some member function
|
|
||||||
// Modify some place
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define MYTRACKER_
|
|
||||||
|
|
||||||
#define CX_BORDER 1
|
|
||||||
#define CY_BORDER 1
|
|
||||||
|
|
||||||
#define CRIT_RECTTRACKER 5
|
|
||||||
void AFXAPI AfxLockGlobals(int nLockType);
|
|
||||||
void AFXAPI AfxUnlockGlobals(int nLockType);
|
|
||||||
void AFXAPI AfxDeleteObject(HGDIOBJ* pObject);
|
|
||||||
|
|
||||||
class CMyTracker
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Constructors
|
|
||||||
CMyTracker();
|
|
||||||
CMyTracker(LPCRECT lpSrcRect, UINT nStyle);
|
|
||||||
|
|
||||||
// Style Flags
|
|
||||||
enum StyleFlags
|
|
||||||
{
|
|
||||||
solidLine = 1, dottedLine = 2, hatchedBorder = 4,
|
|
||||||
resizeInside = 8, resizeOutside = 16, hatchInside = 32,
|
|
||||||
resizeMiddle =80 //设置中间
|
|
||||||
};
|
|
||||||
|
|
||||||
// Hit-Test codes
|
|
||||||
enum TrackerHit
|
|
||||||
{
|
|
||||||
hitNothing = -1,
|
|
||||||
hitTopLeft = 0, hitTopRight = 1, hitBottomRight = 2, hitBottomLeft = 3,
|
|
||||||
hitTop = 4, hitRight = 5, hitBottom = 6, hitLeft = 7, hitMiddle = 8
|
|
||||||
};
|
|
||||||
|
|
||||||
// Attributes
|
|
||||||
UINT m_nStyle; // current state
|
|
||||||
CRect m_rect; // current position (always in pixels)
|
|
||||||
CSize m_sizeMin; // minimum X and Y size during track operation
|
|
||||||
int m_nHandleSize; // size of resize handles (default from WIN.INI)
|
|
||||||
|
|
||||||
// Operations
|
|
||||||
void Draw(CDC* pDC) const;
|
|
||||||
void GetTrueRect(LPRECT lpTrueRect) const;
|
|
||||||
BOOL SetCursor(CWnd* pWnd, UINT nHitTest) const;
|
|
||||||
BOOL Track(CWnd* pWnd, CPoint point, BOOL bAllowInvert =TRUE,
|
|
||||||
CWnd* pWndClipTo = NULL);
|
|
||||||
BOOL TrackRubberBand(CWnd* pWnd, CPoint point, BOOL bAllowInvert = TRUE);
|
|
||||||
int HitTest(CPoint point) const;
|
|
||||||
int NormalizeHit(int nHandle) const;
|
|
||||||
|
|
||||||
// Overridables
|
|
||||||
virtual void DrawTrackerRect(LPCRECT lpRect, CWnd* pWndClipTo,
|
|
||||||
CDC* pDC, CWnd* pWnd);
|
|
||||||
virtual void AdjustRect(int nHandle, LPRECT lpRect);
|
|
||||||
virtual void OnChangedRect(const CRect& rectOld);
|
|
||||||
virtual UINT GetHandleMask() const;
|
|
||||||
|
|
||||||
// Implementation
|
|
||||||
public:
|
|
||||||
virtual ~CMyTracker();
|
|
||||||
|
|
||||||
public:
|
|
||||||
//***********************************************************
|
|
||||||
//设置调整光标
|
|
||||||
void SetResizeCursor(UINT nID_N_S,UINT nID_W_E,UINT nID_NW_SE,
|
|
||||||
UINT nID_NE_SW,UINT nIDMiddle);
|
|
||||||
//创建军画刷,内部调用
|
|
||||||
void CreatePen();
|
|
||||||
//设置矩形颜色
|
|
||||||
void SetRectColor(COLORREF rectColor);
|
|
||||||
|
|
||||||
//**************************************************************
|
|
||||||
|
|
||||||
//**************************************************************
|
|
||||||
//当前矩形颜色
|
|
||||||
COLORREF m_rectColor;
|
|
||||||
//**************************************************************
|
|
||||||
BOOL m_bAllowInvert; // flag passed to Track or TrackRubberBand
|
|
||||||
CRect m_rectLast;
|
|
||||||
CSize m_sizeLast;
|
|
||||||
BOOL m_bErase; // TRUE if DrawTrackerRect is called for erasing
|
|
||||||
BOOL m_bFinalErase; // TRUE if DragTrackerRect called for final erase
|
|
||||||
|
|
||||||
// implementation helpers
|
|
||||||
int HitTestHandles(CPoint point) const;
|
|
||||||
void GetHandleRect(int nHandle, CRect* pHandleRect) const;
|
|
||||||
void GetModifyPointers(int nHandle, int**ppx, int**ppy, int* px, int*py);
|
|
||||||
virtual int GetHandleSize(LPCRECT lpRect = NULL) const;
|
|
||||||
BOOL TrackHandle(int nHandle, CWnd* pWnd, CPoint point, CWnd* pWndClipTo);
|
|
||||||
void Construct();
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////// END OF FILE /////////////////////////////////////////////////////////
|
|
File diff suppressed because it is too large
Load Diff
@ -1,117 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2004 Jacquelin POTIER <jacquelin.potier@free.fr>
|
|
||||||
Dynamic aspect ratio code Copyright (C) 2004 Jacquelin POTIER <jacquelin.potier@free.fr>
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; version 2 of the License.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Object: class helper for popupmenu control
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#ifndef _WIN32_WINNT
|
|
||||||
#define _WIN32_WINNT 0x0501 // for xp os
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#pragma warning (push)
|
|
||||||
#pragma warning(disable : 4005)// for '_stprintf' : macro redefinition in tchar.h
|
|
||||||
#include <TCHAR.h>
|
|
||||||
#pragma warning (pop)
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <commctrl.h>
|
|
||||||
#pragma comment (lib,"comctl32.lib")
|
|
||||||
|
|
||||||
class CPopUpMenu
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef void (*pfMessageCallback)(WPARAM wParam, LPARAM lParam,PVOID UserParam);
|
|
||||||
CPopUpMenu();
|
|
||||||
CPopUpMenu(CPopUpMenu* ParentPopUpMenu);
|
|
||||||
~CPopUpMenu();
|
|
||||||
|
|
||||||
HMENU GetControlHandle();
|
|
||||||
CPopUpMenu* GetParentPopUpMenu();
|
|
||||||
|
|
||||||
UINT Add(TCHAR* Name);
|
|
||||||
UINT Add(TCHAR* Name,UINT Index);
|
|
||||||
UINT Add(TCHAR* Name,HICON hIcon);
|
|
||||||
UINT Add(TCHAR* Name,HICON hIcon,UINT Index);
|
|
||||||
UINT Add(TCHAR* Name,int IdIcon,HINSTANCE hInstance);
|
|
||||||
UINT Add(TCHAR* Name,int IdIcon,HINSTANCE hInstance,UINT Index);
|
|
||||||
UINT Add(TCHAR* Name,int IdIcon,HINSTANCE hInstance,int Width,int Height,UINT Index);
|
|
||||||
|
|
||||||
UINT AddSeparator();
|
|
||||||
UINT AddSeparator(UINT Index);
|
|
||||||
|
|
||||||
UINT AddSubMenu(TCHAR* SubMenuName,CPopUpMenu* SubMenu,UINT Index);
|
|
||||||
UINT AddSubMenu(TCHAR* SubMenuName,CPopUpMenu* SubMenu);
|
|
||||||
UINT AddSubMenu(TCHAR* SubMenuName,CPopUpMenu* SubMenu,int IdIcon,HINSTANCE hInstance,UINT Index);
|
|
||||||
UINT AddSubMenu(TCHAR* SubMenuName,CPopUpMenu* SubMenu,int IdIcon,HINSTANCE hInstance);
|
|
||||||
UINT AddSubMenu(TCHAR* SubMenuName,CPopUpMenu* SubMenu,HICON hIcon,UINT Index);
|
|
||||||
UINT AddSubMenu(TCHAR* SubMenuName,CPopUpMenu* SubMenu,HICON hIcon);
|
|
||||||
|
|
||||||
void SetCheckedState(UINT MenuID,BOOL bChecked);
|
|
||||||
BOOL IsChecked(UINT MenuID);
|
|
||||||
void SetEnabledState(UINT MenuID,BOOL bEnabled);
|
|
||||||
BOOL IsEnabled(UINT MenuID);
|
|
||||||
BOOL SetText(UINT MenuID,TCHAR* pszText);
|
|
||||||
BOOL SetIcon(UINT MenuID,int IdIcon,HINSTANCE hInstance);
|
|
||||||
BOOL SetIcon(UINT MenuID,int IdIcon,HINSTANCE hInstance,int Width,int Height);
|
|
||||||
BOOL SetIcon(UINT MenuID,HICON hIcon);
|
|
||||||
int GetText(UINT MenuID,TCHAR* pszText,int pszTextMaxSize);
|
|
||||||
CPopUpMenu* GetSubMenu(UINT MenuID);
|
|
||||||
|
|
||||||
void Remove(UINT MenuID);
|
|
||||||
|
|
||||||
int GetItemCount();
|
|
||||||
int GetID(UINT MenuIndex);
|
|
||||||
int GetIndex(UINT MenuId);
|
|
||||||
|
|
||||||
UINT Show(int x,int y, HWND hOwner);
|
|
||||||
UINT Show(int x,int y, HWND hOwner,BOOL PositionRelativeToOwner);
|
|
||||||
UINT Show(int x,int y, HWND hOwner,BOOL PositionRelativeToOwner,BOOL ShowUpper);
|
|
||||||
|
|
||||||
UINT GetNextMenuId();
|
|
||||||
UINT GetMaxMenuId();
|
|
||||||
BOOL ReplaceMenuId(UINT OldMenuID,UINT NewMenuID);
|
|
||||||
|
|
||||||
BOOL SetMouseRightButtonUpCallback(pfMessageCallback Callback,PVOID UserParam);
|
|
||||||
BOOL SetMenuSelectCallback(pfMessageCallback Callback,PVOID UserParam);
|
|
||||||
|
|
||||||
BOOL bAllowIconsEffects;
|
|
||||||
private:
|
|
||||||
CPopUpMenu* ParentPopUpMenu;
|
|
||||||
HMENU hPopUpMenu;
|
|
||||||
int CurrentMenuId;
|
|
||||||
BOOL bThemingEnabledForVistaOrNewer;
|
|
||||||
std::vector<HBITMAP> ListLoadedBitmapToFree;
|
|
||||||
|
|
||||||
pfMessageCallback MouseRightButtonUpCallback;
|
|
||||||
PVOID MouseRightButtonUpUserParam;
|
|
||||||
pfMessageCallback MenuSelectCallback;
|
|
||||||
PVOID MenuSelectUserParam;
|
|
||||||
|
|
||||||
void CommonConstructor();
|
|
||||||
void SetMenuItemBitmapInfo(MENUITEMINFO* pMenuItem,HICON hIcon);
|
|
||||||
BOOL IsSubMenu(HMENU hMenu,HMENU hSubMenu);
|
|
||||||
BOOL OnMeasureItem(HWND hwnd, LPMEASUREITEMSTRUCT lpmis);
|
|
||||||
BOOL OnDrawItem(HWND hwnd, LPDRAWITEMSTRUCT lpdis);
|
|
||||||
void OnMouseRightButtonUp(WPARAM wParam, LPARAM lParam);
|
|
||||||
void OnMenuSelect(WPARAM wParam, LPARAM lParam);
|
|
||||||
void FreeItemMemory(UINT MenuID);
|
|
||||||
void FreeItemBitmap(UINT MenuID);
|
|
||||||
static LRESULT CALLBACK SubClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,UINT_PTR uIdSubclass,DWORD_PTR dwRefData);
|
|
||||||
};
|
|
Binary file not shown.
@ -1,174 +0,0 @@
|
|||||||
// Screenshot.cpp : 定义应用程序的类行为。
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
|
||||||
#include "Screenshot.h"
|
|
||||||
#include "ScreenshotDlg.h"
|
|
||||||
#include "CatchScreenDlg.h"
|
|
||||||
#include <GdiPlus.h>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace Gdiplus;
|
|
||||||
#pragma comment(lib,"GdiPlus.lib")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define new DEBUG_NEW
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SHIFTED 0x8000
|
|
||||||
|
|
||||||
|
|
||||||
// CScreenshotApp
|
|
||||||
|
|
||||||
BEGIN_MESSAGE_MAP(CScreenshotApp, CWinApp)
|
|
||||||
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
|
|
||||||
END_MESSAGE_MAP()
|
|
||||||
|
|
||||||
|
|
||||||
// CScreenshotApp 构造
|
|
||||||
|
|
||||||
CScreenshotApp::CScreenshotApp()
|
|
||||||
{
|
|
||||||
// TODO: 在此处添加构造代码,
|
|
||||||
// 将所有重要的初始化放置在 InitInstance 中
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 唯一的一个 CScreenshotApp 对象
|
|
||||||
|
|
||||||
CScreenshotApp theApp;
|
|
||||||
|
|
||||||
|
|
||||||
// CScreenshotApp 初始化
|
|
||||||
|
|
||||||
BOOL CScreenshotApp::InitInstance()
|
|
||||||
{
|
|
||||||
// 如果一个运行在 Windows XP 上的应用程序清单指定要
|
|
||||||
// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
|
|
||||||
//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
|
|
||||||
INITCOMMONCONTROLSEX InitCtrls;
|
|
||||||
InitCtrls.dwSize = sizeof(InitCtrls);
|
|
||||||
// 将它设置为包括所有要在应用程序中使用的
|
|
||||||
// 公共控件类。
|
|
||||||
InitCtrls.dwICC = ICC_WIN95_CLASSES;
|
|
||||||
InitCommonControlsEx(&InitCtrls);
|
|
||||||
|
|
||||||
CWinApp::InitInstance();
|
|
||||||
|
|
||||||
GdiplusStartupInput input;
|
|
||||||
GdiplusStartup(&m_gdiplusToken,&input,NULL);
|
|
||||||
|
|
||||||
AfxEnableControlContainer();
|
|
||||||
|
|
||||||
// 标准初始化
|
|
||||||
// 如果未使用这些功能并希望减小
|
|
||||||
// 最终可执行文件的大小,则应移除下列
|
|
||||||
// 不需要的特定初始化例程
|
|
||||||
// 更改用于存储设置的注册表项
|
|
||||||
// TODO: 应适当修改该字符串,
|
|
||||||
// 例如修改为公司或组织名
|
|
||||||
SetRegistryKey(_T("应用程序向导生成的本地应用程序"));
|
|
||||||
|
|
||||||
CScreenshotDlg dlg;
|
|
||||||
m_pMainWnd = &dlg;
|
|
||||||
INT_PTR nResponse = dlg.DoModal();
|
|
||||||
if (nResponse == IDOK)
|
|
||||||
{
|
|
||||||
// TODO: 在此放置处理何时用
|
|
||||||
// “确定”来关闭对话框的代码
|
|
||||||
}
|
|
||||||
else if (nResponse == IDCANCEL)
|
|
||||||
{
|
|
||||||
// TODO: 在此放置处理何时用
|
|
||||||
// “取消”来关闭对话框的代码
|
|
||||||
}
|
|
||||||
|
|
||||||
// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
|
|
||||||
// 而不是启动应用程序的消息泵。
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CScreenshotApp::ProcessMessageFilter(int code, LPMSG lpMsg)
|
|
||||||
{
|
|
||||||
if(m_hwndDlg != NULL)
|
|
||||||
{
|
|
||||||
// 如果消息是从对话框发出的或者其子控件发出的,就进行处理
|
|
||||||
if((lpMsg->hwnd == m_hwndDlg) || ::IsChild(m_hwndDlg, lpMsg->hwnd))
|
|
||||||
{
|
|
||||||
// 如果消息是WM_KEYDOWN,用方向键调整位置
|
|
||||||
if(lpMsg->message == WM_KEYDOWN)
|
|
||||||
{
|
|
||||||
CRect rect(0,0,0,0);
|
|
||||||
CCatchScreenDlg * pDlg=(CCatchScreenDlg *)AfxGetMainWnd();
|
|
||||||
|
|
||||||
rect = pDlg->m_rectTracker.m_rect;
|
|
||||||
|
|
||||||
if(pDlg->m_bFirstDraw)
|
|
||||||
{
|
|
||||||
//如果Shift键按下则方向键调整大小
|
|
||||||
BOOL bIsShiftDown = FALSE;
|
|
||||||
|
|
||||||
if (GetKeyState(VK_SHIFT) & SHIFTED)
|
|
||||||
bIsShiftDown = TRUE;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
switch(lpMsg->wParam)
|
|
||||||
{
|
|
||||||
case VK_UP:
|
|
||||||
|
|
||||||
//如果按下Shift,则只调整一边
|
|
||||||
if(!bIsShiftDown)
|
|
||||||
rect.top-=1;
|
|
||||||
|
|
||||||
rect.bottom-=1;
|
|
||||||
pDlg->m_rectTracker.m_rect = rect;
|
|
||||||
pDlg->InvalidateRgnWindow();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_DOWN:
|
|
||||||
rect.top+=1;
|
|
||||||
if(!bIsShiftDown)
|
|
||||||
rect.bottom+=1;
|
|
||||||
|
|
||||||
pDlg->m_rectTracker.m_rect=rect;
|
|
||||||
pDlg->InvalidateRgnWindow();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_LEFT:
|
|
||||||
if(!bIsShiftDown)
|
|
||||||
rect.left-=1;
|
|
||||||
rect.right-=1;
|
|
||||||
|
|
||||||
pDlg->m_rectTracker.m_rect=rect;
|
|
||||||
pDlg->InvalidateRgnWindow();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_RIGHT:
|
|
||||||
rect.left+=1;
|
|
||||||
if(!bIsShiftDown)
|
|
||||||
rect.right+=1;
|
|
||||||
|
|
||||||
pDlg->m_rectTracker.m_rect=rect;
|
|
||||||
pDlg->InvalidateRgnWindow();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CWinApp::ProcessMessageFilter(code, lpMsg);
|
|
||||||
}
|
|
||||||
int CScreenshotApp::ExitInstance()
|
|
||||||
{
|
|
||||||
GdiplusShutdown(m_gdiplusToken);
|
|
||||||
|
|
||||||
return CWinApp::ExitInstance();
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
// Screenshot.h : PROJECT_NAME 应用程序的主头文件
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef __AFXWIN_H__
|
|
||||||
#error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "resource.h" // 主符号
|
|
||||||
|
|
||||||
// CScreenshotApp:
|
|
||||||
// 有关此类的实现,请参阅 Screenshot.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
class CScreenshotApp : public CWinApp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CScreenshotApp();
|
|
||||||
|
|
||||||
// 重写
|
|
||||||
public:
|
|
||||||
virtual BOOL InitInstance();
|
|
||||||
|
|
||||||
|
|
||||||
HWND m_hwndDlg;
|
|
||||||
virtual BOOL ProcessMessageFilter(int code, LPMSG lpMsg);
|
|
||||||
|
|
||||||
// 实现
|
|
||||||
|
|
||||||
DECLARE_MESSAGE_MAP()
|
|
||||||
private:
|
|
||||||
ULONG_PTR m_gdiplusToken;
|
|
||||||
public:
|
|
||||||
virtual int ExitInstance();
|
|
||||||
};
|
|
||||||
|
|
||||||
extern CScreenshotApp theApp;
|
|
@ -1,217 +0,0 @@
|
|||||||
// Microsoft Visual C++ generated resource script.
|
|
||||||
//
|
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
#define APSTUDIO_READONLY_SYMBOLS
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generated from the TEXTINCLUDE 2 resource.
|
|
||||||
//
|
|
||||||
#ifndef APSTUDIO_INVOKED
|
|
||||||
#include "targetver.h"
|
|
||||||
#endif
|
|
||||||
#include "afxres.h"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
#undef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Chinese (P.R.C.) resources
|
|
||||||
|
|
||||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
|
||||||
#ifdef _WIN32
|
|
||||||
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
|
|
||||||
#pragma code_page(936)
|
|
||||||
#endif //_WIN32
|
|
||||||
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// TEXTINCLUDE
|
|
||||||
//
|
|
||||||
|
|
||||||
1 TEXTINCLUDE
|
|
||||||
BEGIN
|
|
||||||
"resource.h\0"
|
|
||||||
END
|
|
||||||
|
|
||||||
2 TEXTINCLUDE
|
|
||||||
BEGIN
|
|
||||||
"#ifndef APSTUDIO_INVOKED\r\n"
|
|
||||||
"#include ""targetver.h""\r\n"
|
|
||||||
"#endif\r\n"
|
|
||||||
"#include ""afxres.h""\r\n"
|
|
||||||
"\0"
|
|
||||||
END
|
|
||||||
|
|
||||||
3 TEXTINCLUDE
|
|
||||||
BEGIN
|
|
||||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
|
||||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
|
||||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
|
||||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
|
||||||
"\r\n"
|
|
||||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)\r\n"
|
|
||||||
"LANGUAGE 4, 2\r\n"
|
|
||||||
"#pragma code_page(936)\r\n"
|
|
||||||
"#include ""res\\Screenshot.rc2"" // 非 Microsoft Visual C++ 编辑的资源\r\n"
|
|
||||||
"#include ""l.CHS\\afxres.rc"" // 标准组件\r\n"
|
|
||||||
"#endif\r\n"
|
|
||||||
"\0"
|
|
||||||
END
|
|
||||||
|
|
||||||
#endif // APSTUDIO_INVOKED
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Icon
|
|
||||||
//
|
|
||||||
|
|
||||||
// Icon with lowest ID value placed first to ensure application icon
|
|
||||||
// remains consistent on all systems.
|
|
||||||
IDR_MAINFRAME ICON "res\\Screenshot.ico"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Dialog
|
|
||||||
//
|
|
||||||
|
|
||||||
IDD_SCREENSHOT_DIALOG DIALOGEX 0, 0, 181, 59
|
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
|
|
||||||
EXSTYLE WS_EX_APPWINDOW
|
|
||||||
CAPTION "Screenshot"
|
|
||||||
FONT 9, "MS Shell Dlg", 0, 0, 0x1
|
|
||||||
BEGIN
|
|
||||||
PUSHBUTTON "截图",IDC_BTN_START,65,22,50,14
|
|
||||||
END
|
|
||||||
|
|
||||||
IDD_DIALOGFORIMG DIALOGEX 0, 0, 169, 140
|
|
||||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP
|
|
||||||
EXSTYLE WS_EX_TRANSPARENT
|
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
|
||||||
BEGIN
|
|
||||||
EDITTEXT IDC_EDIT1,14,20,137,93,ES_MULTILINE | ES_READONLY | NOT WS_BORDER
|
|
||||||
END
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Version
|
|
||||||
//
|
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
|
||||||
FILEVERSION 1,0,0,1
|
|
||||||
PRODUCTVERSION 1,0,0,1
|
|
||||||
FILEFLAGSMASK 0x3fL
|
|
||||||
#ifdef _DEBUG
|
|
||||||
FILEFLAGS 0x1L
|
|
||||||
#else
|
|
||||||
FILEFLAGS 0x0L
|
|
||||||
#endif
|
|
||||||
FILEOS 0x4L
|
|
||||||
FILETYPE 0x1L
|
|
||||||
FILESUBTYPE 0x0L
|
|
||||||
BEGIN
|
|
||||||
BLOCK "StringFileInfo"
|
|
||||||
BEGIN
|
|
||||||
BLOCK "080403a8"
|
|
||||||
BEGIN
|
|
||||||
VALUE "CompanyName", "TODO: <公司名>"
|
|
||||||
VALUE "FileDescription", "TODO: <文件说明>"
|
|
||||||
VALUE "FileVersion", "1.0.0.1"
|
|
||||||
VALUE "InternalName", "Screenshot.exe"
|
|
||||||
VALUE "LegalCopyright", "TODO: (C) <公司名>。保留所有权利。"
|
|
||||||
VALUE "OriginalFilename", "Screenshot.exe"
|
|
||||||
VALUE "ProductName", "TODO: <产品名>"
|
|
||||||
VALUE "ProductVersion", "1.0.0.1"
|
|
||||||
END
|
|
||||||
END
|
|
||||||
BLOCK "VarFileInfo"
|
|
||||||
BEGIN
|
|
||||||
VALUE "Translation", 0x804, 936
|
|
||||||
END
|
|
||||||
END
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// DESIGNINFO
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
GUIDELINES DESIGNINFO
|
|
||||||
BEGIN
|
|
||||||
IDD_SCREENSHOT_DIALOG, DIALOG
|
|
||||||
BEGIN
|
|
||||||
LEFTMARGIN, 7
|
|
||||||
RIGHTMARGIN, 174
|
|
||||||
TOPMARGIN, 7
|
|
||||||
BOTTOMMARGIN, 52
|
|
||||||
END
|
|
||||||
|
|
||||||
IDD_DIALOGFORIMG, DIALOG
|
|
||||||
BEGIN
|
|
||||||
LEFTMARGIN, 7
|
|
||||||
RIGHTMARGIN, 162
|
|
||||||
TOPMARGIN, 7
|
|
||||||
BOTTOMMARGIN, 133
|
|
||||||
END
|
|
||||||
END
|
|
||||||
#endif // APSTUDIO_INVOKED
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Bitmap
|
|
||||||
//
|
|
||||||
|
|
||||||
IDB_BITMAP_BK BITMAP "res\\brackground.bmp"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// PNG
|
|
||||||
//
|
|
||||||
|
|
||||||
IDB_ARROW PNG "res\\Arrow.png"
|
|
||||||
IDB_RECTANGLE PNG "res\\Rectangle.png"
|
|
||||||
IDB_CIRCLE PNG "res\\Circle.png"
|
|
||||||
IDB_BRUSH PNG "res\\Brush.PNG"
|
|
||||||
IDB_MOSAIC PNG "res\\Mosaic.png"
|
|
||||||
IDB_TEXT PNG "res\\Text.png"
|
|
||||||
IDB_UNDO PNG "res\\Undo.png"
|
|
||||||
IDB_SAVE PNG "res\\Save.png"
|
|
||||||
IDB_EXIT PNG "res\\Exit.png"
|
|
||||||
IDB_FINISH PNG "res\\Finish.png"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Cursor
|
|
||||||
//
|
|
||||||
|
|
||||||
IDC_CURSOR1 CURSOR "res\\arrow_m.cur"
|
|
||||||
#endif // Chinese (P.R.C.) resources
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef APSTUDIO_INVOKED
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Generated from the TEXTINCLUDE 3 resource.
|
|
||||||
//
|
|
||||||
#define _AFX_NO_SPLITTER_RESOURCES
|
|
||||||
#define _AFX_NO_OLE_RESOURCES
|
|
||||||
#define _AFX_NO_TRACKER_RESOURCES
|
|
||||||
#define _AFX_NO_PROPERTY_RESOURCES
|
|
||||||
|
|
||||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
|
|
||||||
LANGUAGE 4, 2
|
|
||||||
#pragma code_page(936)
|
|
||||||
#include "res\Screenshot.rc2" // 非 Microsoft Visual C++ 编辑的资源
|
|
||||||
#include "l.CHS\afxres.rc" // 标准组件
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
#endif // not APSTUDIO_INVOKED
|
|
||||||
|
|
@ -1,368 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="gb2312"?>
|
|
||||||
<VisualStudioProject
|
|
||||||
ProjectType="Visual C++"
|
|
||||||
Version="9.00"
|
|
||||||
Name="Screenshot"
|
|
||||||
ProjectGUID="{24E39ACB-AB81-485D-8D36-749B3F5EC1E8}"
|
|
||||||
RootNamespace="Screenshot"
|
|
||||||
Keyword="MFCProj"
|
|
||||||
TargetFrameworkVersion="196613"
|
|
||||||
>
|
|
||||||
<Platforms>
|
|
||||||
<Platform
|
|
||||||
Name="Win32"
|
|
||||||
/>
|
|
||||||
</Platforms>
|
|
||||||
<ToolFiles>
|
|
||||||
</ToolFiles>
|
|
||||||
<Configurations>
|
|
||||||
<Configuration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
|
||||||
ConfigurationType="1"
|
|
||||||
UseOfMFC="2"
|
|
||||||
CharacterSet="1"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
PreprocessorDefinitions="_DEBUG"
|
|
||||||
MkTypLibCompatible="false"
|
|
||||||
ValidateParameters="true"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="0"
|
|
||||||
PreprocessorDefinitions="WIN32;_WINDOWS;_DEBUG"
|
|
||||||
MinimalRebuild="true"
|
|
||||||
BasicRuntimeChecks="3"
|
|
||||||
RuntimeLibrary="3"
|
|
||||||
UsePrecompiledHeader="2"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="4"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="_DEBUG"
|
|
||||||
Culture="2052"
|
|
||||||
AdditionalIncludeDirectories="$(IntDir)"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
LinkIncremental="1"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
SubSystem="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration
|
|
||||||
Name="Release|Win32"
|
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
|
||||||
ConfigurationType="1"
|
|
||||||
UseOfMFC="2"
|
|
||||||
CharacterSet="1"
|
|
||||||
WholeProgramOptimization="1"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreBuildEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXMLDataGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCWebServiceProxyGeneratorTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCMIDLTool"
|
|
||||||
PreprocessorDefinitions="NDEBUG"
|
|
||||||
MkTypLibCompatible="false"
|
|
||||||
ValidateParameters="true"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
Optimization="2"
|
|
||||||
EnableIntrinsicFunctions="true"
|
|
||||||
PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG"
|
|
||||||
MinimalRebuild="false"
|
|
||||||
RuntimeLibrary="2"
|
|
||||||
EnableFunctionLevelLinking="true"
|
|
||||||
UsePrecompiledHeader="2"
|
|
||||||
WarningLevel="3"
|
|
||||||
DebugInformationFormat="3"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManagedResourceCompilerTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCResourceCompilerTool"
|
|
||||||
PreprocessorDefinitions="NDEBUG"
|
|
||||||
Culture="2052"
|
|
||||||
AdditionalIncludeDirectories="$(IntDir)"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPreLinkEventTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCLinkerTool"
|
|
||||||
LinkIncremental="1"
|
|
||||||
GenerateDebugInformation="true"
|
|
||||||
SubSystem="2"
|
|
||||||
OptimizeReferences="2"
|
|
||||||
EnableCOMDATFolding="2"
|
|
||||||
TargetMachine="1"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCALinkTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCManifestTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCXDCMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCBscMakeTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCFxCopTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCAppVerifierTool"
|
|
||||||
/>
|
|
||||||
<Tool
|
|
||||||
Name="VCPostBuildEventTool"
|
|
||||||
/>
|
|
||||||
</Configuration>
|
|
||||||
</Configurations>
|
|
||||||
<References>
|
|
||||||
</References>
|
|
||||||
<Files>
|
|
||||||
<Filter
|
|
||||||
Name="Source Files"
|
|
||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\CatchScreenDlg.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\MyEdit.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\MyToolBar.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\MyTracker.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\PopUpMenu.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Screenshot.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ScreenshotDlg.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\stdafx.cpp"
|
|
||||||
>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
UsePrecompiledHeader="1"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
<FileConfiguration
|
|
||||||
Name="Release|Win32"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
UsePrecompiledHeader="1"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Header Files"
|
|
||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\CatchScreenDlg.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\MyEdit.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\MyToolBar.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\MyTracker.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\PopUpMenu.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Resource.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Screenshot.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ScreenshotDlg.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\stdafx.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\targetver.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<Filter
|
|
||||||
Name="Resource Files"
|
|
||||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
|
||||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Arrow.ico"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Arrow.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\arrow_m.cur"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\brackground.bmp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Brush.PNG"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Circle.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Exit.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Finish.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Mosaic.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Rectangle.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Save.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Screenshot.ico"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Screenshot.rc"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Screenshot.rc2"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Text.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\toolbar1.bmp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\res\Undo.png"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<File
|
|
||||||
RelativePath=".\ReadMe.txt"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
<Globals>
|
|
||||||
<Global
|
|
||||||
Name="RESOURCE_FILE"
|
|
||||||
Value="Screenshot.rc"
|
|
||||||
/>
|
|
||||||
</Globals>
|
|
||||||
</VisualStudioProject>
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue