Jump to content

my script work .. then don't worl !!!!!!!!!


Recommended Posts

hello guys

at first sorry for the mistake in the title of the topic :

my script work .. then don't work

I have this script that changes the resolution of the desktop

DisplayChangeRes(1024, 768, 32, 85)
Func DisplayChangeRes($WIDTH, $HEIGHT, $BPP, $FREQ)
$DM_PELSWIDTH = 0x00080000
$DM_PELSHEIGHT = 0x00100000
$DM_BITSPERPEL = 0x00040000
$DM_DISPLAYFREQUENCY = 0x00400000
$CDS_TEST = 0x00000002
$CDS_UPDATEREGISTRY = 0x00000001
$DISP_CHANGE_RESTART = 1
$DISP_CHANGE_SUCCESSFUL = 0
$HWND_BROADCAST = 0xffff
$WM_DISPLAYCHANGE = 0x007E
$DEVMODE = DLLStructCreate ("byte[32];int[10];byte[32];int[6]")
$B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DLLStructGetPtr ($DEVMODE))
If @error Then
$B = 0
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, $WIDTH, 2)
DllStructSetData ($DEVMODE, 4, $HEIGHT, 3)
DllStructSetData ($DEVMODE, 4, $BPP, 1)
DllStructSetData ($DEVMODE, 4, $FREQ, 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", $BPP, "int", $HEIGHT * 2 ^ 16 + $WIDTH)
$DEVMODE = ""
Return 1
Case Else
$DEVMODE = ""
Return $B
EndSelect
EndIf
EndFunc ;==>DisplayChangeRes

I have windows vista

now

when i try this script in its .au3 file it works perfectly

but when I compile it to exe file I try to start but the windows send to me this message :

my script name is : change.exe

change.exe has stopped working

windows can check online for a solution for this problem ...

Posted Image

please help me

hello guys

at first sorry for the mistake in the title of the topic :

my script work .. then don't work

I have this script that changes the resolution of the desktop

DisplayChangeRes(1024, 768, 32, 85)
Func DisplayChangeRes($WIDTH, $HEIGHT, $BPP, $FREQ)
$DM_PELSWIDTH = 0x00080000
$DM_PELSHEIGHT = 0x00100000
$DM_BITSPERPEL = 0x00040000
$DM_DISPLAYFREQUENCY = 0x00400000
$CDS_TEST = 0x00000002
$CDS_UPDATEREGISTRY = 0x00000001
$DISP_CHANGE_RESTART = 1
$DISP_CHANGE_SUCCESSFUL = 0
$HWND_BROADCAST = 0xffff
$WM_DISPLAYCHANGE = 0x007E
$DEVMODE = DLLStructCreate ("byte[32];int[10];byte[32];int[6]")
$B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DLLStructGetPtr ($DEVMODE))
If @error Then
$B = 0
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, $WIDTH, 2)
DllStructSetData ($DEVMODE, 4, $HEIGHT, 3)
DllStructSetData ($DEVMODE, 4, $BPP, 1)
DllStructSetData ($DEVMODE, 4, $FREQ, 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", $BPP, "int", $HEIGHT * 2 ^ 16 + $WIDTH)
$DEVMODE = ""
Return 1
Case Else
$DEVMODE = ""
Return $B
EndSelect
EndIf
EndFunc ;==>DisplayChangeRes

I have windows vista

now

when i try this script in its .au3 file it works perfectly

but when I compile it to exe file I try to start but the windows send to me this message :

my script name is : change.exe

change.exe has stopped working

windows can check online for a solution for this problem ...

Posted Image

please help me

Edited by Soledad
Link to comment
Share on other sites

Try this:

#RequireAdmin

This function was primarily aimed at allowing AutoIt scripts to work correctly with Windows Vista User Account Control (UAC) (However, will also work on Windows 2000 and Windows XP).

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...