首页 > 代码库 > 浏览器自动跳转

浏览器自动跳转

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.  
; #Warn  ; Enable warnings to assist with detecting common errors.  
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.  
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.  
#SingleInstance,force  
Menu, Tray, Icon, shell32.dll, 151
;另存为|保存|复制|新建|打开|图形另存为|文件打开|保存副本|上传|选择文件 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  
GroupAdd,Window32770,置入嵌入对象 ahk_class #32770  
;~ ----------------------------------------------------
GroupAdd,Window32770 , ahk_class bosa_sdm_Microsoft Office Word 11.0
GroupAdd, Window32770 , ahk_class bosa_sdm_XL9
GroupAdd, Window32770 , ahk_class bosa_sdm_Mso96
 
;在某些程序中自动切换中文,某些英文 注册个窗口钩子然后监听系统消息  
Gui +LastFound +hwndhwndshellwindow  
DllCall( "RegisterShellHookWindow", "UInt",hwndshellwindow )  
OnMessage( DllCall( "RegisterWindowMessage", "Str", "SHELLHOOK" ), "SwitchMessage" )  
return  
 
  


SwitchMessage( wParam,lParam ) ;{ 
{ 
    if ( wParam != 1 ) ;新开窗口 
    { 
        if WinActive("ahk_class CabinetWClass") ;若激活了桌面; 
        { 
            WinWaitNotActive ahk_class CabinetWClass ;等待桌面失活; 
            ;以下三种方法是获取地址栏文本,也就是路径; 
            ; 方法一 
            ;WinGetTitle, this_title, ahk_class CabinetWClass ;“文件夹选项”,“查看”,“在标题栏显示完整路径”,“确定”,显示完整路径 
            ; 方法二 
            ;hExplorer := DllCall("FindWindowEx", Int, 0, Int, 0, Str, "CabinetWClass", Int, 0) 
            ;hAddressBar := DllCall("FindWindowEx", Int, hExplorer, Int, 0, Str, "ShellTabWindowClass", Int, 0) 
            ;ControlGetText, path, , ahk_id %hAddressBar% 
            ; 方法三 
            ControlGetText, this_title, ToolbarWindow322, ahk_class CabinetWClass 
            this_title := StrReplace(this_title, "地址:", "") 
            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 
                WinGetClass,w_Class,A
                    if w_Class not contains bosa_sdm_  ;Office对话框
                        { 
                           ControlFocus, Edit1, A 
                            ControlSetText, Edit1, %this_title%, A 
                            Sleep, 50 
                            ControlSend, Edit1, {Enter}, A  
                        }  
                    else
                        { 
                         ControlSetText, RichEdit20W2, %this_title%, A 
                            Sleep, 50 
                            ControlSend, RichEdit20W2, {Enter}, A  
                        }}  
                else  
                    return  
            }  
            else  
                return  
            return  
        }  
}  
}   

 

浏览器自动跳转