本文介绍了在 Ahk 中发送 Alt + Tab 的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的.我知道这是一个非常愚蠢的问题.但我已经卡住了一个小时.

Ok. I know this is a very stupid question.But I'm stuck already for an hour.

我对 ahk 的经验很少,但是直到现在我都制作了每个脚本,没有任何问题.我浏览了 ahk 教程,但到目前为止还没有找到解决方案.

I got very little experience with ahk, however I made work every script until now with no problems. I explored the ahk tutorials but found no solution up to now.

我正在尝试切换到上一个.具有单个小键盘关闭键的应用程序.我试过了:

I'm trying to switch to prev. app with a single numpad off key.I've tried:

!{Tab}

,

{Alt down}{Tab}{Alt up}

我已经尝试过睡眠延迟、多行、括号内的多行、命令后有或没有逗号等.

I've tried it with Sleep delays, multiline, multiline inside brackets, with and without commas after commands, etc.

我很确定这很简单,但我还没有尝试过.

I'm quite sure is very simple but something I've not tried yet.

有什么建议吗?

推荐答案

$F1:: AltTab()
$F2:: AltTabMenu()

; AltTab-replacement for Windows 8:
AltTab(){
    list := ""
    WinGet, id, list
    Loop, %id%
    {
        this_ID := id%A_Index%
        IfWinActive, ahk_id %this_ID%
            continue    
        WinGetTitle, title, ahk_id %this_ID%
        If (title = "")
            continue
        If (!IsWindow(WinExist("ahk_id" . this_ID))) 
            continue
        WinActivate, ahk_id %this_ID%, ,2
            break
    }
}

; AltTabMenu-replacement for Windows 8:
AltTabMenu(){
    list := ""
    Menu, windows, Add
    Menu, windows, deleteAll
    WinGet, id, list
    Loop, %id%
    {
        this_ID := id%A_Index%
        WinGetTitle, title, ahk_id %this_ID%
        If (title = "")
            continue            
        If (!IsWindow(WinExist("ahk_id" . this_ID))) 
            continue
        Menu, windows, Add, %title%, ActivateTitle      
        WinGet, Path, ProcessPath, ahk_id %this_ID%
        Try 
            Menu, windows, Icon, %title%, %Path%,, 0
        Catch 
            Menu, windows, Icon, %title%, %A_WinDir%System32SHELL32.dll, 3, 0 
    }
    CoordMode, Mouse, Screen
    MouseMove, (0.4*A_ScreenWidth), (0.35*A_ScreenHeight)
    CoordMode, Menu, Screen
    Xm := (0.25*A_ScreenWidth)
    Ym := (0.25*A_ScreenHeight)
    Menu, windows, Show, %Xm%, %Ym%
}

ActivateTitle:
    SetTitleMatchMode 3
    WinActivate, %A_ThisMenuItem%
return

;-----------------------------------------------------------------
; Check whether the target window is activation target
;-----------------------------------------------------------------
IsWindow(hWnd){
    WinGet, dwStyle, Style, ahk_id %hWnd%
    if ((dwStyle&0x08000000) || !(dwStyle&0x10000000)) {
        return false
    }
    WinGet, dwExStyle, ExStyle, ahk_id %hWnd%
    if (dwExStyle & 0x00000080) {
        return false
    }
    WinGetClass, szClass, ahk_id %hWnd%
    if (szClass = "TApplication") {
        return false
    }
    return true
}

EDIT(由用户 Ooker 建议):

EDIT (suggested by the user Ooker):

脚本会弹出一个菜单供您选择.

The script pops up a menu for you to choose.

这是它的样子:

这篇关于在 Ahk 中发送 Alt + Tab 的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 00:06