智能跳轉---TC資源管理器
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;作者:天甜;QQ:105224583
;一花一世界,一葉一枯榮,心無掛礙,無掛礙故,無有恐怖,遠離顛倒夢想,究竟涅盤。
;更新於:2016-10-10-20-36
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Process, Priority,,high ;腳本高優先級
#NoTrayIcon ;隱藏托盤圖標
#NoEnv ;不檢查空變量是否爲環境變量
#Persistent ;讓腳本持久運行(關閉或ExitApp)
#SingleInstance Force ;跳過對話框並自動替換舊實例
#WinActivateForce ;強制激活窗口
#MaxHotkeysPerInterval 200 ;時間內按熱鍵最大次數
SetBatchLines -1 ;腳本全速執行
SetControlDelay 0 ;控件修改命令自動延時
CoordMode Menu Window ;座標相對活動窗口
SendMode Input ;更速度和可靠方式發送鍵盤點擊
SetTitleMatchMode 2 ;窗口標題模糊匹配
;SetTitleMatchMode,RegEx
DetectHiddenWindows On ;顯示隱藏窗口
SetWorkingDir %A_ScriptDir% ;當前腳本所在目錄的絕對路徑.不包含最後的反斜線(根目錄同樣如此);A_ScriptDir指的是D:\zxh\QuickZ\Apps
;另存爲|保存|複製|新建|打開|圖形另存爲|文件打開|保存副本|上傳|選擇文件 ahk_class #32770
GroupAdd,Window32770,另存爲 ahk_class #32770
GroupAdd,Window32770,保存 ahk_class #32770
GroupAdd,Window32770,複製 ahk_class #32770
GroupAdd,Window32770,新建 ahk_class #32770
GroupAdd,Window32770,打開 ahk_class #32770
GroupAdd,Window32770,圖形另存爲 ahk_class #32770
GroupAdd,Window32770,文件打開 ahk_class #32770
GroupAdd,Window32770,打開文件 ahk_class #32770
GroupAdd,Window32770,保存副本 ahk_class #32770
GroupAdd,Window32770,上傳 ahk_class #32770
GroupAdd,Window32770,選擇文件 ahk_class #32770
GroupAdd,Window32770,插入圖片 ahk_class #32770
GroupAdd,Window32770,導入 ahk_class #32770
global this_title=
global zParam
;~ OnMessage(0x5555, "MsgMonitor")
;在某些程序中自動切換中文,某些英文 註冊個窗口鉤子然後監聽系統消息
Gui +LastFound +hwndhwndshellwindow
DllCall( "RegisterShellHookWindow", "UInt",hwndshellwindow )
OnMessage( DllCall( "RegisterWindowMessage", "Str", "SHELLHOOK" ), "SwitchMessage" )
return
;~ MsgMonitor(wParam, lParam, msg)
;~ {
;~ zParam = %wParam%
;~ }
^+!1::zParam := 1
^+!0::zParam := 0
SwitchMessage( wParam,lParam ) ;{
{
If ( wParam != 1 ) ;新開窗口
{
If WinActive("ahk_class TTOTAL_CMD")
{
WinWaitNotActive ahk_class TTOTAL_CMD
SendMessage 1074, 21, 0, , ahk_class TTOTAL_CMD
ControlGetText, varPathInTC, , ahk_id %ErrorLevel%
StringReplace, this_title, varPathInTC, >, \
IfWinExist ahk_group Window32770
{
WinWaitActive ahk_group Window32770, , 2
if !ErrorLevel
;IfWinActive ahk_group Window32770
{
ControlClick, Edit1, A
Sleep, 100
ControlSetText, Edit1, %this_title%, A
Sleep, 50
ControlSend, Edit1, {Enter}, A
}
else
return
}
else
return
return
}
If WinActive("ahk_class CabinetWClass")
{
WinWaitNotActive ahk_class CabinetWClass
WinGetTitle, this_title, ahk_class CabinetWClass ;“文件夾選項”,“查看”,“在標題欄顯示完整路徑”,“確定”,顯示完整路徑
if this_title=桌面
this_title=%A_Desktop%
;if this_title=庫\文檔
;this_title=%A_MyDocuments%
IfWinExist ahk_group Window32770
{
WinWaitActive ahk_group Window32770, , 2
if !ErrorLevel
;IfWinActive ahk_group Window32770
{
ControlClick, Edit1, A
Sleep, 100
ControlSetText, Edit1, %this_title%, A
Sleep, 50
ControlSend, Edit1, {Enter}, A
}
else
return
}
else
return
return
}
If WinActive("ahk_class SciTEWindow")
{
if zParam = 1
{
OCR_IBEAM =32513
hbeam := DllCall("LoadCursorFromFile","Str","D:\zxh\QuickZ\User\Icons\zzx.cur")
DllCall( "SetSystemCursor", Uint,hbeam, Int,OCR_IBEAM )
}
if zParam = 0
{
SPI_SETCURSORS := 0x57
DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS, "UInt", 0, "UInt", 0, "UInt", 0)
}
WinWaitNotActive ahk_class SciTEWindow
{
SPI_SETCURSORS := 0x57
DllCall("SystemParametersInfo", "UInt", SPI_SETCURSORS, "UInt", 0, "UInt", 0, "UInt", 0)
}
return
}
}
} ;}
>!o::
Send, ^o
WinWaitActive ahk_class #32770
ControlFocus, Edit1, A
send,{Backspace}
sleep 100
ControlSetText, Edit1, %this_title%, A
Sleep, 50
ControlSend, Edit1, {Enter}, A
return
>!l::
Send, ^+s
WinWaitActive ahk_class #32770
ControlFocus, Edit1, A
send,{Backspace}
sleep 100
ControlSetText, Edit1, %this_title%, A
Sleep, 50
ControlSend, Edit1, {Enter}, A
return
>!n::
Send, ^n
WinWaitActive ahk_class #32770
ControlFocus, Edit1, A
send,{Backspace}
sleep 100
ControlSetText, Edit1, %this_title%, A
Sleep, 50
ControlSend, Edit1, {Enter}, A
return
;~ ^+s::
;~ Send ^+s
;~ WinWaitActive ahk_class #32770
;~ ControlFocus, Edit1, A
;~ send,{Backspace}
;~ sleep 100
;~ ControlSetText, Edit1, %this_title%, A
;~ Sleep, 50
;~ ControlSend, Edit1, {Enter}, A
;~ return
#IfWinActive, ahk_class #32770
^g:: ;發送最後 TC or 資管 路徑到32770
ControlClick, Edit1, A
Sleep, 100
ControlSetText, Edit1, %this_title%, A
Sleep, 100
ControlSend, Edit1, {Enter}, A
return
^e:: GoSub,Sub_SendCurDiagPath2Exp ;在系統資管中打開對話框的路徑
^t:: GoSub,Sub_SendCurDiagPath2Tc ;在TC中打開對話框的路徑
;~ Space & t:: GoSub,Sub_SendCurDiagPath2Tc
#If
;將Explorer中路徑發送到對話框
Sub_SendExpCurPath2Diag:
{
WinActivate ahk_class CabinetWClass
WinGetTitle, Title, ahk_class CabinetWClass ;打開“文件夾選項”,切換到“查看”選項卡,在高級設置列表框中勾選“在標題欄顯示完整路徑”,單擊“確定”按鈕使設置生效,現在訪問文件夾路徑時就會在左上角的標題欄顯示完整路徑
if Title=桌面
Title=%A_Desktop%
Send !{Tab}
ControlFocus, Edit1, A
send,{Backspace}
sleep 100
ControlSetText, Edit1, %Title%,A
send,{enter}
return
}
;將tc中路徑發送到對話框
Sub_SendTcCurPath2Diag:
{
clipraw:=Clipboard
Clipboard =
PostMessage, 1075, 2029,0,, ahk_class TTOTAL_CMD
ClipWait, 1
srcDIR := Clipboard
Clipboard:=clipraw
;再發送剪貼板路徑到控件
ControlFocus, Edit1, A
send,{Backspace}
sleep 100
ControlSetText, Edit1, %srcDIR%,A
send,{enter}
return
}
;將tc中路徑發送到對話框-備份
Sub_SendTcCurPath2Diag2:
{
;將剪貼板中內容作爲文件名
B_Clip2Name := false
B_ChangeDiagSize := true
;先獲取TC中當前路徑
clip:=Clipboard
Clipboard =
;TC_Msg := 1075,cm_CopySrcPathToClip 2029
PostMessage, 1075, 2029,0,, ahk_class TTOTAL_CMD
ClipWait, 1
srcDIR := Clipboard
Clipboard:=clip
;再發送剪貼板路徑到控件
ControlFocus, Edit1, A
send,{Backspace}
sleep 100
ControlSetText, Edit1, %srcDIR%,A
send,{enter}
;msgbox %clip%
if(B_Clip2Name){
Sleep 100
ControlSetText, Edit1, %clip%,A
}
;ControlSetText, Edit1, %text%,A
if(B_ChangeDiagSize){
;WinGetPos, xTB, yTB,lengthTB,hightTB, ahk_class Shell_TrayWnd
;改變對話框大小,省事就直接移動到100,100的位置,然後85%屏幕大小,否則就要詳細結算任務欄在上下左右的位置
WinMove, A,,80,80, A_ScreenWidth * 0.85, A_ScreenHeight * 0.85
}
return
}
;在TC中打開對話框的路徑
Sub_SendCurDiagPath2Tc:
{
WinGetText, CurWinAllText
Loop, parse, CurWinAllText, `n, `r
{
If RegExMatch(A_LoopField, "^地址: "){
curDiagPath := SubStr(A_LoopField,4)
break
}
}
{
DiagPath := % curDiagPath
WinActivate ahk_class TTOTAL_CMD
PostMessage 1075, 3001, 0, , AHK_CLASS TTOTAL_CMD
ControlSetText, Edit1, cd %DiagPath%, ahk_class TTOTAL_CMD
Sleep 400
ControlSend, Edit1, {Enter}, ahk_class TTOTAL_CMD
}
return
}
;在系統資管中打開對話框的路徑
Sub_SendCurDiagPath2Exp:
{
WinGetText, CurWinAllText
Loop, parse, CurWinAllText, `n, `r
{
If RegExMatch(A_LoopField, "^地址: "){
curDiagPath := SubStr(A_LoopField,4)
break
}
}
{
DiagPath := % curDiagPath
run explorer.exe %DiagPath%
}
return
}
^F12::Reload
^F11::ExitApp