Skip to content

Commit

Permalink
适配UI相应的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
linxinhong committed Dec 20, 2019
1 parent 71f7126 commit 41a3ed7
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 52 deletions.
21 changes: 13 additions & 8 deletions editor.ahk
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#Persistent
#SingleInstance, force
SetBatchLines, -1

FileEncoding, UTF-8
quickz.LoadPlugins()
quickz.GenerateInclude()

QZM.Listen(A_ScriptDir "\ui", 5210)
; The final parameter is the name of the ActiveX component.
Gui Add, ActiveX, x0 y0 w980 h640 vWB, Shell.Explorer
Gui Show, w980 h640, QuickZ 配置
;Gui Add, ActiveX, x0 y0 w980 h640 vWB, Shell.Explorer
;Gui Show, w980 h640, QuickZ 配置
; This is specific to the web browser control.
WB.Navigate("http://127.0.0.1:5210/")
;WB.Navigate("http://127.0.0.1:5210/")
!z::reload

return

Expand Down Expand Up @@ -152,17 +153,21 @@ Class QZM {
body := json.dump({})
FileAppend, % body , % QZM.self.config
}
else {
FileRead, body, % QZM.self.config
}
res.SetBodyText(body)
server.ServeFile(res, QZM.self.config)
; res.headers["Content-Type"] = "application/json; charset=utf-8"
res.status := 200
}
else if (req.method == "POST") {
FileDelete, % QZM.self.config
FileAppend, % req.body , % QZM.self.config
quickz.SendWMData("reload")
res.SetBodyText("ok")
res.status := 200
}
else {
res.SetBodyText("unknow request method")
res.status := 404
}
}

}
Expand Down
9 changes: 6 additions & 3 deletions lib/AHKhttp.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ HttpHandler(sEvent, iSocket = 0, sName = 0, sAddr = 0, sPort = 0, ByRef bData =
request.bytesLeft := length + 0

if (request.body) {
request.bytesLeft -= StrLen(request.body)
body := request.body
request.bytesLeft := StrLen(request.body) - request.bytesLeft
;request.bytesLeft -= StrLen(request.body)
}
}

Expand Down Expand Up @@ -255,7 +257,7 @@ class HttpResponse
length := this.headers["Content-Length"]

buffer := new Buffer((StrLen(headers) * 2) + length)
buffer.WriteStr(headers, "CP0")
buffer.WriteStr(headers, "UTF-8")

buffer.Append(this.body)
buffer.Done()
Expand Down Expand Up @@ -302,6 +304,7 @@ class Socket
p := this.data.GetPointer()
length := this.data.length


this.dataSent := 0
loop {
if ((i := AHKsock_Send(this.socket, p, length - this.dataSent)) < 0) {
Expand Down Expand Up @@ -336,7 +339,7 @@ class Buffer
FromString(str, encoding = "UTF-8") {
length := Buffer.GetStrSize(str, encoding)
buffer := new Buffer(length)
buffer.WriteStr(str, "CP0")
buffer.WriteStr(str, encoding)
return buffer
}

Expand Down
6 changes: 3 additions & 3 deletions lib/class_gesturez.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ class gesturez {
y_angle_start := y_init
Loop {
if (not GetKeyState("RButton", "P")) {
if (IsDrawLine and gesturez.self.ShowDraw) {
GUI, gesturez:Destroy
}
WinActive("ahk_id " win)
ElapsedTime := A_TickCount - StartTime
if (ElapsedTime < gesturez.self.ElapsedTime) {
send {%A_ThisHotkey%}
}
if (IsDrawLine and gesturez.self.ShowDraw) {
GUI, gesturez:Destroy
}
if (IsDrawLine and gesturez.self.showDraw) {
Gdip_DeletePen(pPen)
SelectObject(hdc, obm)
Expand Down
14 changes: 9 additions & 5 deletions lib/class_menuz.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
Loop % menuList.MaxIndex()
{
item := menuList[A_Index]
if (item.HasKey("sub") and IsObject(item["sub"])) {
sm := menuz.self.createMenu()
menuz.Build(sm, item.sub, env)
item.submenu := sm
}
item.filter := menuz.ReplaceVar(item.filter)
allowAdd := true
if ( StrLen(item.filter) ) {
Expand All @@ -53,13 +48,21 @@
}
}
if (allowAdd) {
if (item.isPeer) {
item.peer := item.sub
}
if (IsObject(item.peer)) {
menuz.Build(parentMenu, item.peer, env)
}
else if (not StrLen(item.name)) {
parentMenu.add()
}
else if (not menuz.CheckDynamic(item.name, parentMenu)) {
if (item.HasKey("sub") and IsObject(item["sub"])) {
sm := menuz.self.createMenu()
menuz.Build(sm, item.sub, env)
item.submenu := sm
}
item.name := menuz.ItemNameAlign(item.name)
item.icon := menuz.ReplaceVar(item.icon)
item.tcolor := menuz.ReplaceVar(item.tcolor)
Expand Down Expand Up @@ -679,6 +682,7 @@
this.filter := config.filter
this.sub := config.sub
this.peer := config.peer
this.isPeer := config.isPeer
}
}

Expand Down
98 changes: 95 additions & 3 deletions lib/class_quickz.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,29 @@
debug := 1
this.Plugins := {}
this.Actions := {}
this.config := {}
this.UserDir := A_ScriptDir "\User"
this.configFile := this.UserDir "\config.json"
this.IncludeFile := this.UserDir "\include.ahk"
this.LogFile := this.UserDir "\run.log"
this.logLevel := debug
this.ReciveMsgTimer := ""
}
}

class Config {
__new(configFile:="") {
cf := StrLen(configfile) ? configfile : quickz.self.configFile
if (FileExist(cf)) {
FileRead, configString, %cf%
configJson := json.load(configString)
if (IsObject(configJson.menuz)) {
menuz.FromObject(configJson.menuz)
}
}
else {
msgbox % configFile " not exist!"
}
}
}

Expand Down Expand Up @@ -122,6 +141,81 @@
menuz.self := new menuz.instance()
vimd.self := new vimd.instance()
gesturez.self := new gesturez.instance()
quickz.self.config := new quickz.config()

}

OnWMCopyData() {
static WM_COPYDATA := 0x4A
INIWrite, %A_Scripthwnd%, %A_TEMP%\QZRunTime, Auto, HWND
INIWrite, %A_ScriptFullPath%, %A_TEMP%\QZRunTime, Auto, FullPath
OnMessage(WM_COPYDATA, objBindMethod(quickz, "ReciveWMData"))
}

ReciveWMData(wParam, lParam) {
Func := objBindMethod(quickz, "ParseMessage", StrGet(NumGet(lParam + 2*A_PtrSize)))
quickz.self.ReciveMsgTimer := Func
Settimer, % Func , 0 ; 使用settimer运行,方便直接return一个true过去
return True
}

ParseMessage(message) {
Func := quickz.self.ReciveMsgTimer
Settimer, % Func, off
if (message == "reload") {
quickz.reload()
}
}

start() {
quickz.Init()
quickz.OnWMCopyData()
quickz.LoadPlugins()
quickz.InitPlugins()
}

reload() {
menuz.self.menuList := {}
menuz.self.menuStructure := []
quickz.self.config := new quickz.config()
quickz.InitPlugins()
}

SendWMData(aString, IsGUI:=False)
{
Prev_DetectHiddenWindows := A_DetectHiddenWindows
Prev_TitleMatchMode := A_TitleMatchMode
DetectHiddenWindows On
SetTitleMatchMode 2
If IsGUI
{
IniRead, nHwnd, %A_TEMP%\QZRunTime, GUI, HWND
IniRead, FullPath, %A_TEMP%\QZRunTime, GUI, FullPath
Param := A_Space aString
}
Else
{
IniRead, nHwnd, %A_TEMP%\QZRunTime, Auto, HWND
IniRead, FullPath, %A_TEMP%\QZRunTime, Auto, FullPath
;FullPath := A_ScriptDir "\QuickZ.ahk"
}
If !WinExist("ahk_id " nHwnd)
{
Run,%A_AhkPath% "%FullPath%" %Param%
}
Else
{
VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)
SizeInBytes := (StrLen(aString) + 1) * (A_IsUnicode ? 2 : 1)
NumPut(SizeInBytes, CopyDataStruct, A_PtrSize)
NumPut(&aString, CopyDataStruct, 2*A_PtrSize)
Prev_DetectHiddenWindows := A_DetectHiddenWindows
Prev_TitleMatchMode := A_TitleMatchMode
SendMessage, 0x4a, 0, &CopyDataStruct,, ahk_id %nHwnd%
}
DetectHiddenWindows %Prev_DetectHiddenWindows%
SetTitleMatchMode %Prev_TitleMatchMode%
return ErrorLevel
}


Expand Down Expand Up @@ -196,7 +290,5 @@
FileAppend, % "`n" A_YYYY "/" A_MM "/" A_DD " " A_Hour ":" A_Min ":" A_Sec " [ " string.topic " ] " string.content , % quickz.self.logFile
}

exit() {
gesturez.exit()
}

}
17 changes: 10 additions & 7 deletions lib/class_vimd.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
}

_Key() {
static c := 0
win := vimd.ActiveWin()
mode := vimd.GetMode(win.name, win.modeExist)
keyPress := vimd.CheckCapsLock(vimd.ConvertKeyVIM(A_ThisHotkey))
Expand All @@ -151,7 +152,7 @@
}
else if ( not mode.GetMore(keyCache) ) {
vimd.DoAction(mode.GetAction(keyCache), win.GetCount())
win.ClaerAll()
win.ClearAll()
return
}
}
Expand Down Expand Up @@ -453,6 +454,7 @@
this.keyLast := ""
this.count := 0
this.SendRawOnce := false
this.isShowTip := false
this.isRepeat := false
this.isRecord := false
this.isRecordPlay := false
Expand Down Expand Up @@ -497,10 +499,12 @@
}
}

ClaerAll() {
ClearAll() {
this.ClearCount()
this.ClearCache()
this.HideTip()
if (this.isShowTip) {
this.HideTip()
}
}

ClearCount() {
Expand Down Expand Up @@ -539,6 +543,7 @@
}

ShowTip(Text) {
this.isShowTip := true
if (IsFunc(this.onShowTip)) {
Func(this.onShowTip).call(text, this)
}
Expand All @@ -559,6 +564,7 @@
}

HideTip() {
this.isShowTip := false
if (IsFunc(this.onHideTip)) {
Func(this.onHideTip).call(this)
}
Expand Down Expand Up @@ -702,7 +708,4 @@
}
}
}
}

__vimd:
vimd.key()
}
1 change: 1 addition & 0 deletions lib/mime.types
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ image/svg+xml svg svgz
image/webp webp

application/java-archive jar war ear
application/json json
application/mac-binhex40 hqx
application/msword doc
application/pdf pdf
Expand Down
3 changes: 2 additions & 1 deletion quickz.ahk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#NoEnv
#SingleInstance, Force
;SetBatchLines, -1
SetBatchLines, -1
SendMode Input
SetWorkingDir %A_ScriptDir%
SetKeyDelay, -1
Expand All @@ -9,6 +9,7 @@ DetectHiddenWindows On
CoordMode, Mouse, Screen

quickz.Init()
quickz.OnWMCopyData()
quickz.LoadPlugins()
quickz.InitPlugins()

Expand Down
21 changes: 1 addition & 20 deletions user/config.json
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{
"vimd": {
"winList":{}
},
"var": {
"exec": {},
"filter": {}
},
"tag": {

},
"setting": {

},
"menuz": {
},
"plugins": {

}
}
{"menuz":[{"name":"首菜单一","icon":"C:\\Windows\\System32\\Shell32.dll:20","exec":"cmd","param":"","filter":""},{"name":"第二菜单","icon":"","filter":"","exec":"","param":""},{"name":"第三菜单","sub":[{"name":"test4"},{"name":"test5","icon":"C:\\Windows\\System32\\Shell32.dll:22"},{"name":"test6","sub":[{"name":"test7","exec":"jklfjdslkfjkjdskflsjafdlksa"},{"name":"test8","icon":"C:\\Windows\\System32\\Shell32.dll:23"}]}],"icon":"","filter":"","exec":"","param":""}],"vimd":{"winList":{}},"gesturez":{},"var":{"exec":{},"filter":{}},"plugins":{},"setting":{}}

0 comments on commit 41a3ed7

Please sign in to comment.