red0fireus Posted August 3, 2020 Posted August 3, 2020 Hello, I've been playing with Arrays and I'm receiving this error code: "C:\Users\datea\Desktop\New AutoIt v3 Script.au3" (32) : ==> Subscript used on non-accessible variable.: If BitAND(WinGetState($var[$i][1]), 2) and ($aWinRect[2] >= @DesktopWidth) Or ($aWinRect[3] >= @DesktopHeight) then If BitAND(WinGetState($var[$i][1]), 2) and ($aWinRect[2] >= @DesktopWidth) Or ($aWinRect^ ERROR I have found that by opening certain windows when checking for a Maximized window for instance [Class:Shell_TrayWnd] or [CLASS:NotifyIconOverflowWindow] or Opening the Calendar, Side Windows 10 Panel or Volume button I receive this error. I believe it's mostly irrelevant because it only happens sometimes and the code works just find most of the time. I'm new to error checking and creating an "@error" for arrays. I think I need to implement a If @error then ContinueLoop But I'm not exactly sure how to achieve this because the error is inside the Array I believe? Here is my code snippet that I'm working on expandcollapse popup#include <WinAPI.au3> Opt("WinTitleMatchMode", 4) Opt("WinSearchChildren", 1) AdlibRegister("_AggIsFullScreen") While 1 $tmp = _AggIsFullScreen() sleep(1000) If $tmp = 1 and ProcessExists("rainmeter.exe") then run("cmd.exe /c taskkill /im rainmeter.exe /f", "", @SW_HIDE) ConsoleWrite("true") elseif $tmp = 0 and not ProcessExists("rainmeter.exe") then Run("C:\Program Files\Rainmeter\rainmeter.exe", "C:\Program Files\Rainmeter", @SW_HIDE) ConsoleWrite("false") EndIf WEnd Func _AggIsFullScreen() $xMousePos = MouseGetPos(0) $yMousePos = MouseGetPos(1) Local $iPid ; Local $iWin Local $hwnd = WinGetHandle ("[ACTIVE]") Local $aWinRect = WinGetPos ($hwnd) Local $var = WinList("[REGEXPTITLE:^(?!Microsoft Text Input Application|Program Manager)(?s).*]") If $xMousePos >= 0 AND $xMousePos < @DesktopWidth AND $yMousePos >= 0 AND $yMousePos < @DesktopHeight and Not WinActive("[CLASS:NotifyIconOverflowWindow]") And Not WinActive("[Class:Shell_TrayWnd]") Then For $i = 1 To $var[0][0] ; $iWin = $var[$i][1] If BitAND(WinGetState($var[$i][1]), 2) and ($aWinRect[2] >= @DesktopWidth) Or ($aWinRect[3] >= @DesktopHeight) then ; is visible $iPid = WinGetProcess($var[$i][1]) If ProcessExists($iPid) Then return 1 else return 0 endIf EndIf Next else return -1 Endif EndFunc Thank you - red
Developers Jos Posted August 3, 2020 Developers Posted August 3, 2020 You will have to test whether this statement actually did find something and created the array: Local $aWinRect = WinGetPos ($hwnd) Check the Helpfile how to do that. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
red0fireus Posted August 3, 2020 Author Posted August 3, 2020 I believe I got it working, I will report back if I still receive the error. Thank you Jos
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