Jump to content
Sign in to follow this  
Malkey

Change a window to its mirror image

Recommended Posts

Malkey

Instead of going off topic here. I came across a curious behavior when replacing $WS_EX_TRANSPARENT with -1.

Subsequently, a search of these forums did show the GUI exStyle $WS_EX_LAYOUTRTL has been demonstrated before.

On my xp this script makes any window (Notepad window used here) appear as its mirror image including the text.

#include <WinAPI.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>

Run("notepad.exe")
WinActivate("Untitled - Notepad")
WinWaitActive("Untitled - Notepad")
$hWnd = WinGetHandle("Untitled - Notepad")
WinMove("[CLASS:Notepad]", "", @DesktopWidth / 2 - 200, @DesktopHeight / 2 - 250, 400, 200)

Local $ExS = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) ; Existing extended style of the window.

_WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($ExS, $WS_EX_LAYOUTRTL))
_WinAPI_InvalidateRect($hWnd)
Send("qwerty - 1234567890")
MsgBox(0, "", "Continue")

_WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($ExS, $WS_EX_COMPOSITED, $WS_EX_LAYOUTRTL))
_WinAPI_InvalidateRect($hWnd)
MsgBox(0, "", "Continue")

_WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $ExS) ; Back to original exStyle of the window.
_WinAPI_InvalidateRect($hWnd)

MsgBox(0, "", "End")
$PID = ProcessExists("notepad.exe")
If $PID Then ProcessClose($PID)

Share this post


Link to post
Share on other sites
UEZ

Looks very interesting!

This works also on Vista x32 and Win7 x64!

#include <WinAPI.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>

$pid = Run("notepad.exe")
Sleep(750)
WinActivate("[CLASS:Notepad]", "")
WinWaitActive("[CLASS:Notepad]")
$hWnd = WinGetHandle("[CLASS:Notepad]")
WinMove("[CLASS:Notepad]", "", @DesktopWidth / 2 - 200, @DesktopHeight / 2 - 250, 400, 200)

Local $ExS = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) ; Existing extended style of the window.

_WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($ExS, $WS_EX_LAYOUTRTL))
_WinAPI_InvalidateRect($hWnd)
Send("qwerty - 1234567890")
MsgBox(0, "", "Continue")

_WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($ExS, $WS_EX_COMPOSITED, $WS_EX_LAYOUTRTL))
_WinAPI_InvalidateRect($hWnd)
MsgBox(0, "", "Continue")

_WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $ExS) ; Back to original exStyle of the window.
_WinAPI_InvalidateRect($hWnd)

MsgBox(0, "", "End")

ProcessClose($PID)

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
jvanegmond

The behavior is as described here: http://msdn.microsoft.com/en-us/library/aa913269.aspx

Share this post


Link to post
Share on other sites
dmob

Cool stuff... will use this to prank my employees.

Share this post


Link to post
Share on other sites
picea892

I can see all those closet apple users liking this feature. Really strange.

Share this post


Link to post
Share on other sites
Michel Claveau

Hi, all!

It's OK, for me, on Win 7 32bits.

(but UAC off and AV properly configured)

@+

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  

×