简体   繁体   English

AutoHotkey:如何在XP,Win7键盘快捷键Win +左/右箭头上模拟?

[英]AutoHotkey: How can I emulate on XP, Win7 keyboard shortcuts Win + left/right arrows?

On a Windows XP machine, I would like to emulate with AutoHotkey, Windows 7 keyboard shortcuts such as 在Windows XP机器上,我想用AutoHotkey,Windows 7键盘快捷键等模拟

  • Windows logo key + Right arrow, which maximizes the app or desktop window to the right side of the screen Windows徽标键+右箭头,可将应用程序或桌面窗口最大化到屏幕右侧
  • Windows logo key + Left arrow, which maximizes the app or desktop window to the left side of the screen Windows徽标键+向左箭头,可将应用程序或桌面窗口最大化到屏幕左侧

How can I do this? 我怎样才能做到这一点?

Thanks to user3419297 for the hints. 感谢user3419297的提示。 I've done my homework: 我做完了我的作业:

;
; AutoHotkey Version:   1.0.48.5
; Language:             English
; Platform:             Windows XP
; Author:               gerdami
; License:              CC-By-SA 4.0 http://creativecommons.org/licenses/by-sa/4.0/
;
; Script Function:      WinMoveXPasWin7.ahk
; Version               1.0
; Date                  7 March 2015    


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


; ----------------------------------------------------------------------------
; Windows 7 keyboard shortcuts emulation
; Windows + Left arrow
; Windows + Right arrow
; Windows + Up arrow
; Windows + Down arrow
; ----------------------------------------------------------------------------
GetTaskBarDetails()
    {
        Global  ; If a function needs to access or create a large number of global variables, it can be defined to assume that all its variables are global 
        WinGetPos, TaskBarXpos, TaskBarYpos, TaskBarWidth, TaskBarHeight, ahk_class Shell_TrayWnd
        ;MsgBox, TaskBar details`nXpos:`t`t%TaskBarXpos%`nYpos:`t`t%TaskBarYpos%`nWidth:`t`t%TaskBarWidth%`nHeight:`t`t%TaskBarHeight%`nA_ScreenWidth:`t%A_ScreenWidth%`nA_ScreenHeight:`t%A_ScreenHeight%
        TaskBarXpos *=1
        TaskBarYpos *=1
        TaskBarWidth *=1
        TaskBarHeight *=1
    }   
#Left:: 
    {
    GetTaskBarDetails()
    ;MsgBox, TaskBarXpos:`t%TaskBarXpos%`nTaskBarYpos:`t%TaskBarYpos%`nTaskBarWidth:`t%TaskBarWidth%`nTaskBarHeight:`t%TaskBarHeight%`nA_ScreenWidth:`t%A_ScreenWidth%`nA_ScreenHeight:`t%A_ScreenHeight%
    If  (TaskBarWidth * 1) >= (A_ScreenWidth * 1)       ; TaskBar on top or bottom - I had to force to numbers for comparison
        {
            ;MsgBox TaskBar on top or bottom
            NewWidth := (A_ScreenWidth / 2)
            if  TaskBarYpos <= 0            ; TaskBar top
                {
                    ;MsgBox TaskBar top
                    NewXpos := 0
                    NewYpos := (TaskBarHeight + TaskBarYpos)
                    NewHeight := (A_ScreenHeight - (TaskBarHeight + TaskBarYpos))
                }   
            else                            ; TaskBar bottom
                {
                    ;MsgBox TaskBar bottom
                    NewXpos := 0
                    NewYpos := 0
                    NewHeight := TaskBarYpos
                }
        }
    else                                ; TaskBar left or right
        {
            ;MsgBox TaskBar TaskBar left or right
            NewHeight := A_ScreenHeight
            if  TaskBarXpos <= 0        ; TaskBar left
                {
                    ;MsgBox TaskBar left
                    NewXpos := (TaskBarWidth + TaskBarXpos)
                    NewYpos := 0
                    NewWidth := ((A_ScreenWidth - (TaskBarWidth + TaskBarXpos)) / 2)
                }
            else                        ; TaskBar right
                {
                    ;MsgBox TaskBar right
                    NewXpos := 0
                    NewYpos := 0
                    NewWidth := (TaskBarXpos / 2)
                }
        }
    ;MsgBox WinMove, A,, %NewXpos%, %NewYpos%, %NewWidth%, %NewHeight%
    WinRestore, A       ; if windows was maximized mode 
    WinMove, A,, NewXpos, NewYpos, NewWidth, NewHeight
    Return
    }

#Right::
    {
    GetTaskBarDetails()
    ;MsgBox, TaskBarXpos:`t%TaskBarXpos%`nTaskBarYpos:`t%TaskBarYpos%`nTaskBarWidth:`t%TaskBarWidth%`nTaskBarHeight:`t%TaskBarHeight%`nA_ScreenWidth:`t%A_ScreenWidth%`nA_ScreenHeight:`t%A_ScreenHeight%
    If  (TaskBarWidth * 1) >= (A_ScreenWidth * 1)       ; TaskBar on top or bottom
        {
            ;MsgBox TaskBar on top or bottom
            NewWidth := (A_ScreenWidth / 2)
            if  TaskBarYpos <= 0            ; TaskBar top
                {
                    ;MsgBox TaskBar top
                    NewXpos := (A_ScreenWidth / 2)
                    NewYpos := (TaskBarHeight + TaskBarYpos)
                    NewHeight := (A_ScreenHeight - (TaskBarHeight + TaskBarYpos))
                }   
            else                            ; TaskBar bottom
                {
                    ;MsgBox TaskBar bottom
                    NewXpos := (A_ScreenWidth / 2)
                    NewYpos := 0
                    NewHeight := TaskBarYpos
                }
        }
    else                                ; TaskBar left or right
        {
            ;MsgBox TaskBar TaskBar left or right
            NewHeight := A_ScreenHeight
            if  TaskBarXpos <= 0        ; TaskBar left
                {
                    ;MsgBox TaskBar left
                    NewWidth := ((A_ScreenWidth - (TaskBarWidth + TaskBarXpos)) / 2)
                    NewXpos := ((TaskBarWidth + TaskBarXpos) + NewWidth)
                    NewYpos := 0
                }
            else                        ; TaskBar right
                {
                    ;MsgBox TaskBar right
                    NewXpos := (TaskBarXpos / 2)
                    NewYpos := 0
                    NewWidth := (TaskBarXpos / 2)
                }
        }
    ;MsgBox WinMove, A,, %NewXpos%, %NewYpos%, %NewWidth%, %NewHeight%
    WinRestore, A       ; if windows was maximized mode 
    WinMove, A,, NewXpos, NewYpos, NewWidth, NewHeight
    Return
    }

#Up::           ; maximize window
    {
    WinRestore, A       ; if windows is in a false maximized mode 
    WinMaximize, A
    Return
    }

#Down::         ; minimize window
    {
    WinMinimize, A
    Return
    }

Comments and improvements are welcome, as usual. 像往常一样欢迎评论和改进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM