Sign in to follow this  
Followers 0

Change apps perceived width of desktop

6 posts in this topic

#1 ·  Posted

A simple question that may not have a very simple solution - what code should I be looking at to make normal windows applications (Firefox/Office/Notepad..etc.) think that the screen resolution is 1480x 1050 instead of 1680x1050.

Or stated in another way: how do I make it so that I can press 'maximize' in a given window (Firefox/Office/Notepad..etc.) and have that window leave space free, say 200px, on the right side of the screen?

Any input would be appreciated, have searched high and low with no result..

Cheers.

Share this post


Link to post
Share on other sites



#2 ·  Posted

A simple question that may not have a very simple solution - what code should I be looking at to make normal windows applications (Firefox/Office/Notepad..etc.) think that the screen resolution is 1480x 1050 instead of 1680x1050.

Or stated in another way: how do I make it so that I can press 'maximize' in a given window (Firefox/Office/Notepad..etc.) and have that window leave space free, say 200px, on the right side of the screen?

Any input would be appreciated, have searched high and low with no result..

Cheers.

not very clean solution but it seems to work :

waiting for a solution with titlebar hook and api, but I have no idea how to to this...

Dim $s_OldTitle,$v_OldState
$CS_Maximized = 32
$CS_Minimized = 16
$i_MaxWidth = @DesktopWidth*2/3
$i_MaxHeight = @DesktopHeight*2/3


While 1
    $s_Title = WinGetTitle("")
    $v_State = WinGetState($s_Title)
    If $s_OldTitle==$s_Title And $v_OldState<>$v_State Then
        If BitAnd($v_State,$CS_Maximized) Then
            WinMove($s_Title,"",0,0,$i_MaxWidth,$i_MaxHeight)
        EndIf
    EndIf
    $s_OldTitle = $s_Title
    $v_OldState = $v_State
    Sleep(500)
WEnd

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

not very clean solution but it seems to work :

waiting for a solution with titlebar hook and api, but I have no idea how to to this...

Thanks for your ideas here baghenamoth; but yes; an api-hook would by far be the best solution; in a production environment the GUI shuffling that occurs with a simple loop solution is simply not very workable!

The best possible solution would be to define part of the desktop as 'keep off' in the same way the taskbar works - no matter how large you make it a window which is maximized will only use the space available to it. I intend to make a lite-style deskbar application but this basic problem really needs to be dealt with before I care to invest my time in the project! ;)

Anyone?

Edited by Sunaj

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks for your ideas here baghenamoth; but yes; an api-hook would by far be the best solution; in a production environment the GUI shuffling that occurs with a simple loop solution is simply not very workable!

The best possible solution would be to define part of the desktop as 'keep off' in the same way the taskbar works - no matter how large you make it a window which is maximized will only use the space available to it. I intend to make a lite-style deskbar application but this basic problem really needs to be dealt with before I care to invest my time in the project! ;)

Anyone?

This might help.

Const $SPI_SETWORKAREA = 47, $SPI_GETWORKAREA = 48
Const $SPIF_SENDCHANGE = 11


$newWid = @DesktopWidth - 300
$newHt = @DesktopHeight

$DtopRect = DllStructCreate("int[4]")
$PDTopRect = DllStructGetPtr($DtopRect)

$OrigRect = DllStructCreate("int[4]")
$POrigRect = DllStructGetPtr($OrigRect)

$res = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_GETWORKAREA, "int", 0, "ptr", $POrigRect, "int", 0)
MsgBox(262144, 'The work area is ', DllStructGetData($OrigRect, 1, 1) & ', ' & DllStructGetData($OrigRect, 1, 2) & _
        ' x ' & DllStructGetData($OrigRect, 1, 3) & ', ' & DllStructGetData($OrigRect, 1, 4))
Sleep(2000)
MsgBox(262144, "next step", "we'll change it to something smaller")

DllStructSetData($DtopRect, 1, DllStructGetData($OrigRect, 1, 1), 1);top
DllStructSetData($DtopRect, 1, DllStructGetData($OrigRect, 1, 2), 2);left
DllStructSetData($DtopRect, 1, DllStructGetData($OrigRect, 1, 3) - 300, 3);bottom
DllStructSetData($DtopRect, 1, DllStructGetData($OrigRect, 1, 4) - 200, 4);right

$res = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_SETWORKAREA, "int", 0, "ptr", $PDTopRect, "int", $SPIF_SENDCHANGE)

MsgBox(262144, "somthing might have changed on your desktop", "better have a look. (Try to maximize something)")

$res = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_GETWORKAREA, "int", 0, "ptr", $PDTopRect, "int", 0)
MsgBox(262144, 'work area is now', DllStructGetData($DtopRect, 1, 1) & ', ' & DllStructGetData($DtopRect, 1, 2) & _
               ' x ' & DllStructGetData($DtopRect, 1, 3) & ', ' & DllStructGetData($DtopRect, 1, 4))
;we'll put the working area back to how it was
sleep(2000)
MsgBox(262144, "final step", "we'll put it back how it was")
$res = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_SETWORKAREA, "int", 0, "ptr", $POrigRect, "int", $SPIF_SENDCHANGE)
$res = DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_GETWORKAREA, "int", 0, "ptr", $POrigRect, "int", 0)
MsgBox(262144, 'work area is now', DllStructGetData($OrigRect, 1, 1) & ', ' & DllStructGetData($OrigRect, 1, 2) & _
        ' x ' & DllStructGetData($OrigRect, 1, 3) & ', ' & DllStructGetData($OrigRect, 1, 4));right
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Dude, that is, to me, simply amazing! :) Thank you so much for helping out; this post is going straight in my signature to create reference for future budding deskbar writers :)

No kidding! I've been working on my own custom shell application and now I can make my own taskbar and not worry about a maximized program covering it up. Awesome!

Edited by dreniarb

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  
Followers 0