Sign in to follow this  
Followers 0
alex16

Transparent

2 posts in this topic

Hi, Guys,

Just thought id throw this out there,

I am creating a script to change the resolution of my screen from 1280 by 1024 to 1024 by 768, what i was wondering was, is there another way to change the resolution without showing all of the boxes or is it possible to make the running of the script transparent so as its not seen when run,

Here is the script below,

BlockInput(1)

run("control desktop")

WinWaitActive("Personalization")

MouseClick("left",316,507)

WinWaitActive("Display Settings")

MouseClick("left",83,349)

MouseClick("left",419,454)

WinWaitActive("Display Settings","Yes")

MouseClick("left",242,113)

MouseClick("left",262,449)

Just something simple,

I know that it works on windows vista home premium not sure about other variants,

Cheers,

Alex

Share this post


Link to post
Share on other sites



Here's a script that I did some two years ago, still working :P...

#NoTrayIcon
#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=icon.ico
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#Include <Constants.au3>

Opt("TrayAutoPause", 0 )
Opt("TrayMenuMode",1)
Opt("WinTitleMatchMode", 4)

Global $desktopHdefault= @DesktopHeight
Global $desktopWdefault= @DesktopWidth

$_resolution1 = TrayCreateItem("1152x648")
$_resolution2 = TrayCreateItem("1440x810")
$_resolution3 = TrayCreateItem("1024x768")
$_resolution4 = TrayCreateItem("1280x1024")
$_resolution5 = TrayCreateItem("1600x1200")
TrayCreateItem("")
$exititem     = TrayCreateItem("Exit")

TraySetState()

if @DesktopWidth=640 then TrayItemSetState( $_resolution1, $TRAY_CHECKED )
if @DesktopWidth=800 then TrayItemSetState( $_resolution1, $TRAY_CHECKED )
if @DesktopWidth=1024 then TrayItemSetState( $_resolution1, $TRAY_CHECKED )
if @DesktopWidth=1280 then TrayItemSetState( $_resolution1, $TRAY_CHECKED )
if @DesktopWidth=1600 then TrayItemSetState( $_resolution5, $TRAY_CHECKED )

While 1
    $msg = TrayGetMsg()
    Switch $msg
        Case 0
            ContinueLoop
        Case $exititem
            ExitLoop
        Case $_resolution1
            TrayItemSetState( $_resolution1, $TRAY_CHECKED )
            TrayItemSetState( $_resolution2, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution3, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution4, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution5, $TRAY_UNCHECKED )
            _ChangeScreenRes(1152,648)
        Case $_resolution2
            TrayItemSetState( $_resolution1, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution2, $TRAY_CHECKED )
            TrayItemSetState( $_resolution3, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution4, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution5, $TRAY_UNCHECKED )
            _ChangeScreenRes(1440,810)
        Case $_resolution3
            TrayItemSetState( $_resolution1, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution2, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution3, $TRAY_CHECKED )
            TrayItemSetState( $_resolution4, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution5, $TRAY_UNCHECKED )
            _ChangeScreenRes(1024,768)
        Case $_resolution4
            TrayItemSetState( $_resolution1, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution2, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution3, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution4, $TRAY_CHECKED )
            TrayItemSetState( $_resolution5, $TRAY_UNCHECKED )
            _ChangeScreenRes(1280,1024)
        Case $_resolution5
            TrayItemSetState( $_resolution1, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution2, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution3, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution4, $TRAY_UNCHECKED )
            TrayItemSetState( $_resolution5, $TRAY_CHECKED )
            _ChangeScreenRes(1600,1200)
    EndSwitch
WEnd
Exit


#include-once
;===============================================================================
;
; Function Name:    _ChangeScreenRes()
; Description:    Changes the current screen geometry, colour and refresh rate.
; Version:        1.0.0.1
; Parameter(s):  $i_Width - Width of the desktop screen in pixels. (horizontal resolution)
;                  $i_Height - Height of the desktop screen in pixels. (vertical resolution)
;                   $i_BitsPP - Depth of the desktop screen in bits per pixel.
;                   $i_RefreshRate - Refresh rate of the desktop screen in hertz.
; Requirement(s):   AutoIt Beta > 3.1
; Return Value(s):  On Success - Screen is adjusted, @ERROR = 0
;                  On Failure - sets @ERROR = 1
; Forum(s):      http://www.autoitscript.com/forum/index.php?showtopic=20121
; Author(s):        Original code - psandu.ro
;                  Modifications - PartyPooper
;
;===============================================================================
Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh)
    Local Const $DM_PELSWIDTH = 0x00080000
    Local Const $DM_PELSHEIGHT = 0x00100000
    Local Const $DM_BITSPERPEL = 0x00040000
    Local Const $DM_DISPLAYFREQUENCY = 0x00400000
    Local Const $CDS_TEST = 0x00000002
    Local Const $CDS_UPDATEREGISTRY = 0x00000001
    Local Const $DISP_CHANGE_RESTART = 1
    Local Const $DISP_CHANGE_SUCCESSFUL = 0
    Local Const $HWND_BROADCAST = 0xffff
    Local Const $WM_DISPLAYCHANGE = 0x007E
    If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth; default to current setting
    If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight; default to current setting
    If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth; default to current setting
    If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh; default to current setting
    Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]")
    Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE))
    If @error Then
        $B = 0
        SetError(1)
        Return $B
    Else
        $B = $B[0]
    EndIf
    If $B <> 0 Then
        DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5)
        DllStructSetData($DEVMODE, 4, $i_Width, 2)
        DllStructSetData($DEVMODE, 4, $i_Height, 3)
        DllStructSetData($DEVMODE, 4, $i_BitsPP, 1)
        DllStructSetData($DEVMODE, 4, $i_RefreshRate, 5)
        $B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST)
        If @error Then
            $B = -1
        Else
            $B = $B[0]
        EndIf
        Select
            Case $B = $DISP_CHANGE_RESTART
                $DEVMODE = ""
                Return 2
            Case $B = $DISP_CHANGE_SUCCESSFUL
                DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY)
                DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _
                        "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width)
                $DEVMODE = ""
                Return 1
            Case Else
                $DEVMODE = ""
                SetError(1)
                Return $B
        EndSelect
    EndIf
EndFunc;==>_ChangeScreenRes

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