Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you get AutoHotKey hotkeys to work with Remote Desktop in fullscreen on Windows 7?

share|improve this question
up vote 2 down vote accepted

As user16659 notes, Reload makes the hotkeys work again (But his script did not work for me).

Basically, I now have two scripts running, one which contains my hotkeys and hotstrings "script.ahk" and another which will reload this script if RDP is maximised "controller.ahk".

script.ahk:

#SingleInstance force
::hw::Hello World

controller.ahk:

Run "autohotkey" "script.ahk"

#Persistent
SetTimer, ReloadOnRDPMaximized, 500
return

ReloadOnRDPMaximized:
If WinActive("ahk_class TscShellContainerClass")
{
    WinGet, maxOrMin, MinMax, ahk_class TscShellContainerClass

    if (maxOrMin = 0) {
        WinGetPos, PosX, PosY, WinWidth, WinHeight, ahk_class TscShellContainerClass

        if (PosY = 0) {
            ; it is fully maximized therefore reload "script.ahk"
            Run "autohotkey" "script.ahk"

            ; wait until window gets deactivated so you don't reload it again.
            WinWaitNotActive, ahk_class TscShellContainerClass

        }
    }
}
return
share|improve this answer
2  
However, I have noticed that even my solution does not work because in RDP it does not send the shift key press for hot strings, e.g. if you send * then it will send 8... :( – Tahir Hassan Nov 16 '12 at 15:23
    
I had to do something like SendInput, {shift}8{shift up} to send * in RDP, but it will send 8 in Windows. SendInput, {shift down}8{shift up} works the other way around. – user16659 Nov 16 '12 at 17:14
1  
Since answering your above question, I have decided to run my AHK script on the remote server (it is a LOT more reliable). I have changed controller.ahk to close script.ahk so it does not interfere with the server's script. I pasted my solution on my blog: tahirhassan.blogspot.co.uk/2012/11/autohotkey-scripts_19.html – Tahir Hassan Dec 5 '12 at 13:46

You also need to set "Apply windows key combinations" on the "Local resources" tab of remote desktop connection 'mstsc.exe' to "ON THIS COMPUTER"MSTSC WINDOWS KEY COMBINATIONS

share|improve this answer

To make AHK work with Microsoft's Terminal Server client in fullscreen, AHK has to reload after the Remote Desktop window is activated.

SetTimer, waitforrdp, -250
return

:*:ppp::password
:*:ccc::
SendInput, {shift}C{shift up}
SendInput, apitalized
return

waitforrdp:
IfWinActive, ahk_class TscShellContainerClass
{
    WinWaitNotActive, ahk_class TscShellContainerClass,,3600
}
WinWaitActive, ahk_class TscShellContainerClass,,3600
Reload
return
share|improve this answer

Can't add comment to top answer, but I have modified the suggested script that Tahir linked to his blog in the top answer to make it cleaner and easier to use.

The following works by suspending the local script when full screen RDP is active instead of trying to kill and restart the separate script version everytime focus is moved. This is lighter, and also avoids littering the notification tray with lots of zombie AHK icons for the killed scripts. This also means you can just add this to your existing script instead of having to run both of them separately!

; this line should be put on top (auto-exec) section of ahk script
SetTimer, SuspendOnRDPMaximized, 500

; this actual code label and the fn can be put anywhere in the script file
SuspendOnRDPMaximized:
If WinActive("ahk_class TscShellContainerClass") {
    WinGet, maxOrMin, MinMax, ahk_class TscShellContainerClass
    if (maxOrMin = 0) {
        WinGetPos, PosX, PosY, WinWidth, WinHeight, ahk_class TscShellContainerClass
        if (PosY = 0) {  ; it is fully maximized
            Suspend, On
            WinWaitNotActive, ahk_class TscShellContainerClass
            Suspend, Off
        }
    }
}
return
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .