Chimaera Posted November 18, 2012 Share Posted November 18, 2012 (edited) Got an install script with a few tools tied to buttons One of the buttons the tool tied to it which is NDoG's background changer and a bit of OS detection etc thrown in will not reliably trigger its button 5 in this snippet Case $Button5 ShellExecuteWait(@ScriptDir & "Softwarebackgroundschanger.exe") Case $Button6 ShellExecute(@ScriptDir & "Softwarecdgonecdgone.reg") All the others work fine just this one, i tried run and run wait and shellexecute and shellexecutewait etc but some machines it triggers others it doesn't and i cant seem to work out why its odd? If i run the exe on its own it works perfect everytime Any thoughts edit if it helps both exes have require admin and the machines are different OS's Edited November 18, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
kylomas Posted November 18, 2012 Share Posted November 18, 2012 Chimaera, You've probably done this already, but, put a consolewrite after the case stmt for the suspect buttons to make sure that they are not being actioned (as opposed to something else going wrong). kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Chimaera Posted November 18, 2012 Author Share Posted November 18, 2012 (edited) Yeah the button appears to be triggered properly.The script it triggers isn't complex or massive it just checks the screen size and sets the appropriate company wallpaper for that size of screen and OSThe change part is this Its weird how there is no fixed pattern ie it doesn't like XP etcIt definatly doesn't like just run or shellexecute, it doesn't even try with those it seems to need the wait part to enable the script.I may have to add the scripts together in the endAnyway ive made some changes again so ill keep testing Edited November 18, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2012 Share Posted November 18, 2012 What are the returns of run/wait shellex etc.. when the execution fails? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Chimaera Posted November 18, 2012 Author Share Posted November 18, 2012 (edited) Ive changed it to this now ShellExecute(@ScriptDir & "Softwarebackgroundschanger.exe", "", "", "open") MsgBox(0, "Errorcode", @error & " / " & @extended) Oddly even though it works on my machine it reports 0 as the error, when i assumed it should be 1 Success: Returns 1. Failure: Returns 0 and sets @error to non-zero. So maybe there is something wrong ill report back when ive run it across a number of machines to get a bigger picture Edited November 18, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2012 Share Posted November 18, 2012 Ive changed it to this now ShellExecute(@ScriptDir & "Softwarebackgroundschanger.exe", "", "", "open") MsgBox(0, "Errorcode", @error & " / " & @extended) Oddly even though it works on my machine it reports 0 as the error, when i assumed it should be 1 So maybe there is something wrong ill report back when ive run it across a number of machines to get a bigger picture That is correct. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Chimaera Posted November 18, 2012 Author Share Posted November 18, 2012 Ok so what constitutes a success then if successfully changing the background = 0 ? If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
BrewManNH Posted November 18, 2012 Share Posted November 18, 2012 ShellExecute only tells you if it could run the program, it doesn't tell you if the program executed what it's supposed to do correctly. Unless the script has an exitcode that tells the calling program that there was an error, then even using ShellExecuteWait won't tell you anything. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2012 Share Posted November 18, 2012 Ok so what constitutes a success then if successfully changing the background = 0 ?It returns 1 if success and 0 if not.@error is set to 1 on failure, so it works on your machine, @error = 0. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kylomas Posted November 18, 2012 Share Posted November 18, 2012 (edited) Chimaera, The result from shellexecute has nothing to do with whatever you are running. I believe that it just means that it was able to find the resource and launch it. In the following example the first line fails and returns the appropriate code, the second line runs and returns success. However, the script has no idea what the program executed in the second line is doing. consolewrite('file does not exist ' & shellexecute(@scriptdir & 'file.that.does.not.exist') & @lf) consolewrite('This does exist ' & shellexecute('notepad.exe') & @lf) I would look closely at whatever you are executing, especially at run time parms that might aid in debugging. Good Luck, kylomas edit: Pretty much what BewmanNH said, more succinctly. Edited November 18, 2012 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Chimaera Posted November 18, 2012 Author Share Posted November 18, 2012 Hmm thx guys Think ill add a load of error checking in the other exe and backtrack till i can find what causes it If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
guinness Posted November 18, 2012 Share Posted November 18, 2012 Why not use run instead? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2012 Share Posted November 18, 2012 Poor workaround, if the problem persists and you do not have access to target exe is to put your func (Run/RunWait/whatever) in a loop until it succeeds or times out at your discretion. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Chimaera Posted November 18, 2012 Author Share Posted November 18, 2012 Why not use run instead?Because they all are twitchy Run/Runwait/ShellExecute/ShellExecuteWaitIve made a test of each one now with error checking and ill run them till i can narrow it down@JohnOne the target is one of my scripts as explained above If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Chimaera Posted November 20, 2012 Author Share Posted November 20, 2012 Tested on my win 7 machine with no errors and works fine, took it to work with shellexecutewait in use and first win 7 machine it returned 0/0 but failed to change the background, the only difference i could see was it was doing updates and installing software at the same time. Ill keep testing If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
kylomas Posted November 20, 2012 Share Posted November 20, 2012 chimaera, Have you looked at the Windows logs on the affected machine? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Chimaera Posted November 20, 2012 Author Share Posted November 20, 2012 I havent no, the machine was being rushed out for a customer but as i get more examples ill run it down If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Chimaera Posted November 23, 2012 Author Share Posted November 23, 2012 Failed again today on 2 machines (One fresh install the other one of our machines 8 months into an install) I tried ShellExecute and ShellExecuteWait neither worked and both returned 0/0 ShellExecute(@ScriptDir & "\Toolz\chimaera\backgrounds\wallpaper_changer.exe", "", "", "open") MsgBox(0, "Errorcode", @error & " / " & @extended) I also made a version with the original code added into the main script and ran it like that and it failed as well ??? This is the code im using to change the desktop expandcollapse popup_Desktop_Resolution() #include <GDIPlus.au3> Global $resolution, $OS, $dest_dir Global $os_test = _OsDetect() _Desktop_Resolution() ;=============================================================================== Func _Desktop_Resolution() Switch $resolution = "" ;=============================================================================== Case @DesktopWidth = 1024 And @DesktopHeight = 600; 1024x600 FileCopy(@WorkingDir & "\TS_1024x600.jpg", $dest_dir & "\TS_1024x600.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1024x600.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1024 And @DesktopHeight = 768; 1024x768 FileCopy(@WorkingDir & "\TS_1024x768.jpg", $dest_dir & "\TS_1024x768.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1024x768.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1152 And @DesktopHeight = 864; 1152x864 FileCopy(@WorkingDir & "\TS_1152x864.jpg", $dest_dir & "\TS_1152x864.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1152x864.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 720; 1280x720 FileCopy(@WorkingDir & "\TS_1280x720.jpg", $dest_dir & "\TS_1280x720.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1280x720.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 768; 1280x768 FileCopy(@WorkingDir & "\TS_1280x768.jpg", $dest_dir & "\TS_1280x768.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1280x768.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 800; 1280x800 FileCopy(@WorkingDir & "\TS_1280x800.jpg", $dest_dir & "\TS_1280x800.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1280x800.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 960; 1280x960 FileCopy(@WorkingDir & "\TS_1280x960.jpg", $dest_dir & "\TS_1280x960.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1280x960.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 1024; 1280x1024 FileCopy(@WorkingDir & "\TS_1280x1024.jpg", $dest_dir & "\TS_1280x1024.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1280x1024.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1360 And @DesktopHeight = 768; 1360x768 FileCopy(@WorkingDir & "\TS_1360x768.jpg", $dest_dir & "\TS_1360x768.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1360x768.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1366 And @DesktopHeight = 768; 1366x768 FileCopy(@WorkingDir & "\TS_1366x768.jpg", $dest_dir & "\TS_1366x768.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1366x768.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1440 And @DesktopHeight = 900; 1440x900 FileCopy(@WorkingDir & "\TS_1440x900.jpg", $dest_dir & "\TS_1440x900.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1440x900.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1400 And @DesktopHeight = 1050; 1400x1050 FileCopy(@WorkingDir & "\TS_1400x1050.jpg", $dest_dir & "\TS_1400x1050.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1400x1050.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1600 And @DesktopHeight = 900; 1600x900 FileCopy(@WorkingDir & "\TS_1600x900.jpg", $dest_dir & "\TS_1600x900.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1600x900.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1600 And @DesktopHeight = 1200; 1600x1200 FileCopy(@WorkingDir & "\TS_1600x1200.jpg", $dest_dir & "\TS_1600x1200.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1600x1200.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1680 And @DesktopHeight = 1050; 1680x1050 FileCopy(@WorkingDir & "\TS_1680x1050.jpg", $dest_dir & "\TS_1680x1050.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1680x1050.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1920 And @DesktopHeight = 1080; 1920x1080 FileCopy(@WorkingDir & "\TS_1920x1080.jpg", $dest_dir & "\TS_1920x1080.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "\TS_1920x1080.jpg", 2) ;=============================================================================== Case Else Exit EndSwitch EndFunc ;==>_Desktop_Resolution ;=============================================================================== Func _ChangeWallpaper($sFile, $iType) Local $apos, $bpos, $sFileName, $hImage, $sCLSID ; Changes the wallpaper to $sFileName using $iType as: ; 1 Tiled ; 2 Centered ; 3 Stretched ; any other value (usually 0) unchanged ; ; Returns ; 0 if everything is allright. ; -1 if $sFile does not exist. @error is set to 1 ; -2 if $sFile is not bmp or jpg file. @error is set to 2 If Not FileExists($sFile) Then SetError(1) Return -1 EndIf $apos = StringInStr($sFile, "\", 0, -1) $bpos = StringInStr($sFile, ".", 0, -1) $sFileName = StringMid($sFile, $apos + 1, $bpos - $apos - 1) ;~ ConsoleWrite($sFileName & @CRLF) If Not StringRight($sFile, 3) = "jpg" Or Not StringRight($sFile, 3) = "bmp" Then SetError(2) Return -2 EndIf Select Case $iType = 1 RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '1') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0') Case $iType = 2 RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '0') Case $iType = 3 RegWrite('HKCU\Control Panel\Desktop', 'TileWallpaper', 'reg_sz', '0') RegWrite('HKCU\Control Panel\Desktop', 'WallpaperStyle', 'reg_sz', '2') Case Else EndSelect ; Convert jpg to bmp If StringRight($sFile, 3) = "jpg" Then _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFile) $sCLSID = _GDIPlus_EncodersGetCLSID("BMP") _GDIPlus_ImageSaveToFileEx($hImage, @TempDir & "\" & $sFileName & ".bmp", $sCLSID) _GDIPlus_Shutdown() $sFile = @TempDir & "\" & $sFileName & ".bmp" EndIf Sleep(500) RegWrite('HKCU\Control Panel\Desktop', 'Wallpaper', 'reg_sz', $sFile) DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0) EndFunc ;==>_ChangeWallpaper ;=============================================================================== Func _OsDetect() If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Or @OSVersion = "WIN_XPe" Then $OS = "V-" $dest_dir = "C:\Windows\Web\Wallpaper" Else $OS = "V+" $dest_dir = "C:\Windows\Web\Wallpaper\Windows" EndIf ;~ ConsoleWrite($OS & @CRLF) Return $OS EndFunc ;==>_OsDetect And if i run it from the normal exe it works fine ..Gr$@##!! The other code is just a button, nothing fancy This is proper getting on my wick now If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
BrewManNH Posted November 23, 2012 Share Posted November 23, 2012 If you remove the #RequireAdmin from the script, does it work? Because when you use RequireAdmin, it restarts the script using different credentials than the user, so it's probably changing the background for the Admin and not the user. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Chimaera Posted November 23, 2012 Author Share Posted November 23, 2012 No difference im afraid and most of the machines we do are admin single account. I just made this up to double check and it doesn't even work on my machine anymore. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include ; ------------------------------------------------------------------------------ Global $resolution, $OS, $dest_dir Global $os_test = _OsDetect() Global $button1, $button2 Local $GUI_Start = GUICreate(" Gui Test", 500, 500, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) $button1 = GUICtrlCreateButton( " Test 1 ", 20, 50, 130, 35) GUICtrlSetFont(-1, 11, 550, -1, "Tahoma") $button2 = GUICtrlCreateButton( " Test 2 ", 20, 100, 130, 35) GUICtrlSetFont(-1, 11, 550, -1, "Tahoma") GUISetState() Local $nMsg = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $button1 ShellExecute(@ScriptDir & "Toolzchimaerabackgroundswallpaper_changer.exe", "", "", "open") MsgBox(0, "Errorcode", @error & " / " & @extended) Case $button2 _Desktop_Resolution() EndSwitch WEnd ;=============================================================================== Func _Desktop_Resolution() Switch $resolution = "" ;=============================================================================== Case @DesktopWidth = 1024 And @DesktopHeight = 600; 1024x600 FileCopy(@WorkingDir & "TS_1024x600.jpg", $dest_dir & "TS_1024x600.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1024x600.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1024 And @DesktopHeight = 768; 1024x768 FileCopy(@WorkingDir & "TS_1024x768.jpg", $dest_dir & "TS_1024x768.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1024x768.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1152 And @DesktopHeight = 864; 1152x864 FileCopy(@WorkingDir & "TS_1152x864.jpg", $dest_dir & "TS_1152x864.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1152x864.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 720; 1280x720 FileCopy(@WorkingDir & "TS_1280x720.jpg", $dest_dir & "TS_1280x720.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1280x720.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 768; 1280x768 FileCopy(@WorkingDir & "TS_1280x768.jpg", $dest_dir & "TS_1280x768.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1280x768.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 800; 1280x800 FileCopy(@WorkingDir & "TS_1280x800.jpg", $dest_dir & "TS_1280x800.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1280x800.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 960; 1280x960 FileCopy(@WorkingDir & "TS_1280x960.jpg", $dest_dir & "TS_1280x960.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1280x960.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1280 And @DesktopHeight = 1024; 1280x1024 FileCopy(@WorkingDir & "TS_1280x1024.jpg", $dest_dir & "TS_1280x1024.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1280x1024.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1360 And @DesktopHeight = 768; 1360x768 FileCopy(@WorkingDir & "TS_1360x768.jpg", $dest_dir & "TS_1360x768.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1360x768.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1366 And @DesktopHeight = 768; 1366x768 FileCopy(@WorkingDir & "TS_1366x768.jpg", $dest_dir & "TS_1366x768.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1366x768.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1440 And @DesktopHeight = 900; 1440x900 FileCopy(@WorkingDir & "TS_1440x900.jpg", $dest_dir & "TS_1440x900.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1440x900.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1400 And @DesktopHeight = 1050; 1400x1050 FileCopy(@WorkingDir & "TS_1400x1050.jpg", $dest_dir & "TS_1400x1050.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1400x1050.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1600 And @DesktopHeight = 900; 1600x900 FileCopy(@WorkingDir & "TS_1600x900.jpg", $dest_dir & "TS_1600x900.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1600x900.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1600 And @DesktopHeight = 1200; 1600x1200 FileCopy(@WorkingDir & "TS_1600x1200.jpg", $dest_dir & "TS_1600x1200.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1600x1200.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1680 And @DesktopHeight = 1050; 1680x1050 FileCopy(@WorkingDir & "TS_1680x1050.jpg", $dest_dir & "TS_1680x1050.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1680x1050.jpg", 2) ;=============================================================================== Case @DesktopWidth = 1920 And @DesktopHeight = 1080; 1920x1080 FileCopy(@WorkingDir & "TS_1920x1080.jpg", $dest_dir & "TS_1920x1080.jpg", 9) Sleep(1000) _ChangeWallpaper($dest_dir & "TS_1920x1080.jpg", 2) ;=============================================================================== Case Else Exit EndSwitch EndFunc ;==>_Desktop_Resolution ;=============================================================================== Func _ChangeWallpaper($sFile, $iType) Local $apos, $bpos, $sFileName, $hImage, $sCLSID ; Changes the wallpaper to $sFileName using $iType as: ; 1 Tiled ; 2 Centered ; 3 Stretched ; any other value (usually 0) unchanged ; ; Returns ; 0 if everything is allright. ; -1 if $sFile does not exist. @error is set to 1 ; -2 if $sFile is not bmp or jpg file. @error is set to 2 If Not FileExists($sFile) Then SetError(1) Return -1 EndIf $apos = StringInStr($sFile, "", 0, -1) $bpos = StringInStr($sFile, ".", 0, -1) $sFileName = StringMid($sFile, $apos + 1, $bpos - $apos - 1) ;~ ConsoleWrite($sFileName & @CRLF) If Not StringRight($sFile, 3) = "jpg" Or Not StringRight($sFile, 3) = "bmp" Then SetError(2) Return -2 EndIf Select Case $iType = 1 RegWrite('HKCUControl PanelDesktop', 'TileWallpaper', 'reg_sz', '1') RegWrite('HKCUControl PanelDesktop', 'WallpaperStyle', 'reg_sz', '0') Case $iType = 2 RegWrite('HKCUControl PanelDesktop', 'TileWallpaper', 'reg_sz', '0') RegWrite('HKCUControl PanelDesktop', 'WallpaperStyle', 'reg_sz', '0') Case $iType = 3 RegWrite('HKCUControl PanelDesktop', 'TileWallpaper', 'reg_sz', '0') RegWrite('HKCUControl PanelDesktop', 'WallpaperStyle', 'reg_sz', '2') Case Else EndSelect ; Convert jpg to bmp If StringRight($sFile, 3) = "jpg" Then _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sFile) $sCLSID = _GDIPlus_EncodersGetCLSID("BMP") _GDIPlus_ImageSaveToFileEx($hImage, @TempDir & "" & $sFileName & ".bmp", $sCLSID) _GDIPlus_Shutdown() $sFile = @TempDir & "" & $sFileName & ".bmp" EndIf Sleep(500) RegWrite('HKCUControl PanelDesktop', 'Wallpaper', 'reg_sz', $sFile) DllCall("user32", "int", "SystemParametersInfo", "int", 20, "int", 0, "str", $sFile, "int", 0) EndFunc ;==>_ChangeWallpaper ;=============================================================================== Func _OsDetect() If @OSVersion = "WIN_2000" Or @OSVersion = "WIN_2003" Or @OSVersion = "WIN_XP" Or @OSVersion = "WIN_XPe" Then $OS = "V-" $dest_dir = "C:WindowsWebWallpaper" Else $OS = "V+" $dest_dir = "C:WindowsWebWallpaperWindows" EndIf ;~ ConsoleWrite($OS & @CRLF) Return $OS EndFunc ;==>_OsDetect If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now