Jump to content

Subscript used on non-accessible variable *Error*


Recommended Posts

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Rainmeter Suspend
#AutoIt3Wrapper_Res_Fileversion=0.0.0.1
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_ProductName=Rainmeter Suspend
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("TrayAutoPause",0)


while 1
    sleep(5000)
    _IsFullScreen()
WEnd

Func _IsFullScreen ()
    Local $hwnd = WinGetHandle ("[ACTIVE]")
    Local $aWinRect = WinGetPos ($hwnd)
    If ($aWinRect[2] >= _WinAPI_GetSystemMetrics($SM_CXSCREEN)) OR ($aWinRect[3] >= _WinAPI_GetSystemMetrics($SM_CYSCREEN)) Then
        _ProcessSuspend("rainmeter.exe")
    Else
        _ProcessResume("rainmeter.exe")
    EndIf
EndFunc

Func _ProcessSuspend($process)
$processid = ProcessExists($process)
If $processid Then
    $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
    $i_sucess = DllCall("ntdll.dll","int","NtSuspendProcess","int",$ai_Handle[0])
    DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
    If IsArray($i_sucess) Then
        Return 1
    Else
        SetError(1)
        Return 0
    Endif
Else
    SetError(2)
    Return 0
Endif
EndFunc

Func _ProcessResume($process)
$processid = ProcessExists($process)
If $processid Then
    $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $processid)
    $i_sucess = DllCall("ntdll.dll","int","NtResumeProcess","int",$ai_Handle[0])
    DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle)
    If IsArray($i_sucess) Then
        Return 1
    Else
        SetError(1)
        Return 0
    Endif
Else
    SetError(2)
    Return 0
Endif
EndFunc

 

I'm getting this error when running my script: "Error: Subscript used on non-accessible variable" 

I'm very confused because the script works 99% of the time and then I just get the random error. What am I missing?

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

×
×
  • Create New...