Jump to content
Sign in to follow this  

Help with a AHK to AutoIT Conversion

Recommended Posts

I use a 3 monitor setup at work and remote into other servers on the regular.  

For the longest I used only one monitor for RDP and that was terrible because when I do a support session from that RDP session I have no space left to use for documents.

I recently enabled the "use all monitors" feature and now the RDP session spans all 3 monitors, ends up that is not much better as I usually have a ticket or other important information on my host computer so I end up having to minimize and restore the RDP session over and over to get the details I want.

The real solution for me is going to be a RDP session with 2 monitors and leaving my 3rd untouched.  Looks like there is no "real" way to do this.  But I did find a work around using AHK.

ere is my work around for my 3x1 setup to use 2 monitors with a similar experience:

edit the RDP file for the resolution I'm looking for.  Turn off multi monitor and turn off smart screen sizing (not really required)

screen mode id:i:1
use multimon:i:0
smart sizing:i:0
Next I use auto hot key to make the app appear like a full screen, borderless app.  Windows+F11 resizes the window to desktop 2 and 3 and removes the border.  Win+f12 restores the border for easy move.

Just FYI, the RDP client is odd in that it captures all key strokes so I had to use the class name of the window to target it.  You cannot have the app active.  Just select the desktop or another app and then hit win+F11 or win+F12.  Also, make sure the window is not maximized.

Here is the ahk script:
WinSet, Style, -0xCF0000, ahk_class TscShellContainerClass
WinMove ahk_class TscShellContainerClass,, 0,0,3840,1080
WinSet, Style, +0xCF0000, ahk_class TscShellContainerClass

So I looked and I know we have WinSetState() and WinMove() but I cant see how to recreate t he Set Style portion, where the window border is removed.  I know we have GUI functions for that, but how to do that for a normal window?

This is the closest I have found so far I think:

Func _API_SetWindowLongPtr($hWnd, $iIndex, $iValue)
  Local $aResult
  $aResult = DllCall("User32.dll", "int", "SetWindowLongPtr", "hwnd", $hWnd, "int", $iIndex, "int", $iValue)
  Return $aResult[0]

And used these pages for reference: 



My testing script


$hWnd = WinGetHandle("Untitled - Notepad", "")

_API_SetWindowLongPtr($hWnd, -16, "0x00040000L")

Func _API_SetWindowLongPtr($hWnd, $iIndex, $iValue)
  Local $aResult
  $aResult = DllCall("User32.dll", "int", "SetWindowLongPtr", "hwnd", $hWnd, "int", $iIndex, "int", $iValue)
  Return $aResult[0]

However no luck so far, not sure what I am doing wrong.

Share this post

Link to post
Share on other sites

Hello. AutoIt does not use "L" suffix.


#include <WinAPI.au3>
Global Const $WS_SIZEBOX = 0x00040000
Global Const $GWL_STYLE = -16

Local $hWnd = WinGetHandle("Untitled - Notepad", "")
_WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $WS_SIZEBOX)


Edited by Danyfirex

Share this post

Link to post
Share on other sites

Thanks Dany, so what can I use for  WS_OVERLAPPEDWINDOW  style? it does not have a value on the MSDN  page.   I guess just sum up the values of each individual style? 

Share this post

Link to post
Share on other sites

I don't know what you're trying to achieve but I think is WS_OVERLAPPED.

Check Window Styles link you posted above.


Share this post

Link to post
Share on other sites

Well, made progress but still stuck.

Seems no matter what style I apply I just lose the title and all the buttons on the window, it becomes static in the background and nothing on the window can be interacted with any longer.


Edit: looks like I needed to append it to the current style.

This is pretty much working the way I wanted it too.


#Include <WinAPI.au3>
#Include <WindowsConstants.au3>
HotKeySet("{F11}", "Borderless")
HotKeySet("{F10}", "Bordered")
HotKeySet("{F9}", "Minimize")

GLOBAL $hWnd = WinGetHandle("[CLASS:TscShellContainerClass]")
GLOBAL $Style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)

;_WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOr($Style, $WS_OVERLAPPEDWINDOW))

While 1

Func Borderless()
_WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR($Style, 0xCF0000))
WinMove($hWnd, "", -1920, 0, (1920*2), 1080)

Func Bordered()
_WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $Style)
WinMove($hWnd, "", -1920, 0, (1920*2), 1080)

Func Minimize()
    WinSetState($hWnd, "", @SW_MINIMIZE)


Edited by ViciousXUSMC

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By ChenYangHuan
      Hello everyone, I am writing this article with the purpose of learning, knowledge sharing.
      Sorry, if my english is bad
      Here is the code was compiled by me and use many resources on this forum - BASS Function Library (Sound and Music Functions)     etc...
      I call it "Xcry Hacker" because it works through the network and control other computers.
      To the use of this code, you need to open the port for the modem, the required ports in code you can change if you want.
      Next, sigup for a ddns (no-ip.com)
      /Download <url>,<path>   - Download File
      /GetProcess              - Getlist Process
      /KillProcess             - Getlist Process
      /SendFile                - Send file via TCP
      /DelTree                 - Delete a file or a folder
      /RunFile                 - Run a file in Tree View
      /Remote                  - Remote Desktop Victim
      /Update                  - Update for client
      /ReShowList              - ReShow list of Connections
      /ShowDesk                - Begin show Desktop
      /GetSound                - Begin Capture sound
      /ShowChat                - Chat with victim
      /HideChat                - End of the Chat
      /Exit                    - Exit XcryHacker
        Else for remote cmd
      I will show some info late
      Comment if you have questions
      I'm concentrating on studying for exams should be able to answer slow! THANK FOR READING!
  • Create New...