halikus Posted June 12, 2013 Share Posted June 12, 2013 I have a puzzling error i can't seem to figure out. I have a rather simple toolbar i made for aiding with windows installs to make the WinPE a little more robust. When i run the following script from my desktop of a regular Windows install or from a Winbuilder WinPE it runs fine and without error. If i run the same script from a vanilla (non-modified) boot.wim (no desktop environment) it has the "Subscript used with non-Array variable" error. Its a bit of a bummer because its the vanilla boot.wim that could really benefit from the toolbar. The only difference between the 2 environments i can think of is one has the desktop environment and the other doesn't. I do use a setting to have the toolbar reside above the taskbar, but the vanilla boot.wim doesn't have a taskbar. Could that be the problem, and if so, is there an easy remedy to have it function in both scenarios? expandcollapse popup#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Files\OSInstaller.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#NoTrayIcon #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> Sleep(4000) If _Singleton("1", 1) = 0 Then Exit EndIf ;Delete FileDelete("x:\Users\Public\Desktop\desktop.ini") FileDelete("x:\Windows\system32\config\systemprofile\desktop\desktop.ini") ;Shortcuts If FileExists("x:\windows\explorer.exe") Then FileCreateShortcut("x:\sources\recovery\StartRep.exe", @DesktopCommonDir & "\Startup Repair.lnk", "x:\Windows\system32", @SW_SHOWNORMAL) EndIf If FileExists("x:\windows\explorer.exe") Then FileCreateShortcut("x:\windows\system32\Runsetup.exe", @DesktopCommonDir & "\WinPE Taskbar.lnk", "x:\Windows\system32", @SW_SHOWNORMAL) EndIf ;Example() ;Func Example() Local $hGUI = GUICreate('WinPE Taskbar', 484, 26, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg($WM_NCHITTEST, 'WinPE Taskbar') $aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "") $aWin = WinGetPos($hGUI) WinMove($hGUI, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4) GUISetFont(6, 400, 0, "MS Sans Serif") GUISetBkColor(0x006020) $Button1 = GUICtrlCreateButton("Install OS", 0, 0, 59, 25) $Button2 = GUICtrlCreateButton("DART", 200, 0, 43, 25) $Button3 = GUICtrlCreateButton("Startup Repair", 240, 0, 83, 25) $Button4 = GUICtrlCreateButton("Recovery", 320, 0, 59, 25) $Button5 = GUICtrlCreateButton("Desktop", 376, 0, 59, 25) $Button6 = GUICtrlCreateButton("Explorer", 152, 0, 51, 25) $Button7 = GUICtrlCreateButton("Internet", 104, 0, 51, 25) $Button8 = GUICtrlCreateButton("ssWPI", 56, 0, 51, 25) $Button9 = GUICtrlCreateButton("Reboot", 432, 0, 51, 25) WinSetOnTop($hGUI, "", 1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ;Run("x:\Windows\system32\TASKBAR_EXIT_" & @OSArch & ".exe") Exit Case $Button1 ;Os Gui If FileExists("x:\windows\system32\OS_" & @OSArch & ".exe") = 1 Then Run("x:\windows\system32\OS_" & @OSArch & ".exe") EndIf If FileExists("x:\windows\system32\OS_" & @OSArch & ".exe") = 0 Then $Test = Asc("A") For $Tem = 2 To 25 If FileExists(Chr($Test + $Tem) & ":\sources\$OEM$\OS_" & @OSArch & ".exe") Then $CDDRIVE = Chr($Test + $Tem) & ":" If FileExists($CDDRIVE & "\sources\$OEM$\OS_" & @OSArch & ".exe") = 1 Then Run($CDDRIVE & "\sources\$OEM$\OS_" & @OSArch & ".exe") EndIf ExitLoop EndIf Next EndIf Case $Button2 ; DART Run("x:\sources\recovery\tools\MSDartTools.exe") Case $Button3 ;Startup Repair Run("x:\sources\recovery\StartRep.exe") Case $Button4 ;Recovery Env Run("x:\sources\recovery\RecEnv.exe") Case $Button5 ; Desktop Local $ShellObj = ObjCreate("Shell.Application") $ShellObj.ToggleDesktop() Case $Button6; Explorer If FileExists(@WindowsDir & "\explorer.exe") = 1 Then Run(@WindowsDir & "\explorer.exe") EndIf If FileExists(@WindowsDir & "\explorer.exe") = 0 Then $Test1 = Asc("A") For $Tem1 = 2 To 25 If FileExists(Chr($Test1 + $Tem1) & ":\boot\firadisk\explorer_" & @OSArch & ".exe") Then $CDDRIVE2 = Chr($Test1 + $Tem1) & ":" If FileExists($CDDRIVE2 & "\boot\firadisk\explorer_" & @OSArch & ".exe") = 1 Then Run($CDDRIVE2 & "\boot\firadisk\explorer_" & @OSArch & ".exe") EndIf ExitLoop EndIf Next EndIf Case $Button7 ; internet If FileExists("x:\Program Files\Internet Explorer\iexplore.exe") = 0 Then Run("x:\Program Files\Opera12\opera.exe") Run("x:\Program Files\CD-Opera\opera.exe") EndIf If FileExists("x:\Program Files\Internet Explorer\iexplore.exe") = 1 Then Run("x:\Program Files\Internet Explorer\iexplore.exe") EndIf Case $Button8 ; sswpi $Test2 = Asc("A") For $Tem2 = 2 To 25 If FileExists(Chr($Test2 + $Tem2) & ":\ssAppsInstalls\ssWPIInstaller\ssWPI.exe") Then $sswpi = Chr($Test2 + $Tem2) & ":" If FileExists($sswpi & "\ssAppsInstalls\ssWPIInstaller\ssWPI.exe") = 1 Then Run($sswpi & "\ssAppsInstalls\ssWPIInstaller\ssWPI.exe") EndIf ExitLoop EndIf Next Case $Button9 ; reboot Run("x:\windows\system32\wpeutil REBOOT") EndSwitch WEnd GUIDelete($hGUI) ;EndFunc ;==>Example Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Return $HTCAPTION EndFunc ;==>WM_NCHITTEST Link to comment Share on other sites More sharing options...
BrewManNH Posted June 12, 2013 Share Posted June 12, 2013 Where's the error coming from, and what have you tried to find out what's causing it? Any MsgBoxes to tell you which line of the script might be causing it? What does WinGetPos return when you have the error? I'm going to assume that is where the error is coming from, as it's the only place I can see you using an array. 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...
guinness Posted June 12, 2013 Share Posted June 12, 2013 It's probably the WinGetPos functions which you should be looking at, add error checking to see if they return an array i.e. @error or UBound. 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...
halikus Posted June 13, 2013 Author Share Posted June 13, 2013 (edited) Thanks BrewManH and guinness, i actually didn't know about the @error command. I have some really extravagant code i could of posted, but this was as minimal an example i could find in my au3s to reproduce the error. The error was WinGetPos, but i have spent so much time coding im racoon eyed and stupid atm. As i tried my best before the post to have the toolbar reside roughly above the taskbar, can you take pity on me and guide me in the right direction to an alternate method doing the same thing without an error? Im not a beginner, but i am a novice, and with my code i bit off more than i can chew. Some of my au3 apps i use have 20,000 lines of code. If i can figure this one thing out, i can finally get some well deserved R&R and perfect my various codes. I 100% am one of those people that relies on the help to solve problems, but i can't seem to find an alternative to this one problem and my brain is mush. If either of you know an easy method without any effort on your end, can you please provide an alternative method example or a specific place in the help to search? Edited June 13, 2013 by halikus Link to comment Share on other sites More sharing options...
guinness Posted June 13, 2013 Share Posted June 13, 2013 I don't use WinPE so I can really help. Look at @DesktopHeight and Width,maybe that will help if WinGetPos fails. 20,000 lines, I think my biggest application is something like 5,000! 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...
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