Jump to content
Sign in to follow this  
TheNorwegianUser

Subscript used with non-Array variable

Recommended Posts

TheNorwegianUser

Didn't get any help from so Ill just post it here.

Trying to use this to play a video at the start of this, but it gives me this error:

C:\Program Files (x86)\AutoIt3\Include\DSEngine.au3 (236) : ==> Subscript used with non-Array variable.:

$hEngine = $ret[0]

$hEngine = $ret^ ERROR

Why do I get that?

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include-once

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
#include <_AudioEndpointVolume.au3>
#include <Inet.au3>
$s_URL='http://myremotecontrol.webs.com/'
$bString='True'
$SoundPlayVolume=20
$Source=_INetGetSource($s_URL, $bString)
If StringInStr($Source, "SoundPlayVolume=1") <> 0 Then $SoundPlayVolume=1
If StringInStr($Source, "SoundPlayVolume=5") <> 0 Then $SoundPlayVolume=5
If StringInStr($Source, "SoundPlayVolume=10") <> 0 Then $SoundPlayVolume=10
If StringInStr($Source, "SoundPlayVolume=20") <> 0 Then $SoundPlayVolume=20
If StringInStr($Source, "SoundPlayVolume=30") <> 0 Then $SoundPlayVolume=30
If StringInStr($Source, "SoundPlayVolume=40") <> 0 Then $SoundPlayVolume=40
If StringInStr($Source, "SoundPlayVolume=50") <> 0 Then $SoundPlayVolume=50
If StringInStr($Source, "SoundPlayVolume=60") <> 0 Then $SoundPlayVolume=60
If StringInStr($Source, "SoundPlayVolume=70") <> 0 Then $SoundPlayVolume=70
If StringInStr($Source, "SoundPlayVolume=80") <> 0 Then $SoundPlayVolume=80
If StringInStr($Source, "SoundPlayVolume=90") <> 0 Then $SoundPlayVolume=90
If StringInStr($Source, "SoundPlayVolume=100") <> 0 Then $SoundPlayVolume=100
If _GetMute() <> 0 Then
_SetMute(0)
EndIf
If _GetMasterVolumeLevelScalar() <> $SoundPlayVolume Then
_SetMasterVolumeLevelScalar($SoundPlayVolume)
EndIf
FileInstall("C:\Users\Elias\Documents\Diverse\Saw\DSEngine_UDF.dll", @ScriptDir & "\DSEngine_UDF.dll", 1)
FileInstall("C:\Users\Elias\Documents\Diverse\Saw\DuringGame.mp3", @ScriptDir & "\DuringGame.mp3", 1)
FileInstall("C:\Users\Elias\Documents\Diverse\Saw\Intro.avi", @ScriptDir & "\Intro.avi", 1)
FileInstall("C:\Users\Elias\Documents\Diverse\Saw\LostGame.mp3", @ScriptDir & "\LostGame.mp3", 1)
FileInstall("C:\Users\Elias\Documents\Diverse\Saw\item1.jpg", @ScriptDir & "\item1.jpg", 1)
FileInstall("C:\Users\Elias\Documents\Diverse\Saw\item2.jpg", @ScriptDir & "\item2.jpg", 1)
Sleep(500)

#include <DSEngine.au3>
#include <gdiplus.au3>
#include <winapi.au3>
$VidGui=GUICreate("Intro",@DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetCursor(16, 1)
GUISetState()
$file="C:\Intro.avi"
Engine_Startup("DSEngine_UDF.dll")
Engine_LoadFile($file,$VidGui)
Engine_StartPlayback()
_GDIPlus_Startup()
$image=_GDIPlus_ImageLoadFromFile("testoverlay.png")
$hbitmap=_GDIPlus_BitmapCreateHBITMAPFromBitmap($image)
$timer=TimerInit()
While 1
If not WinActive("Intro") Then WinActivate("Intro")
$diff=TimerDiff($timer)
If $diff>13000 Then ExitLoop
If _GetMute() <> 0 Then
_SetMute(0)
EndIf
If _GetMasterVolumeLevelScalar() <> $SoundPlayVolume Then
_SetMasterVolumeLevelScalar($SoundPlayVolume)
EndIf
WEnd
_GDIPlus_ImageDispose($image)
_GDIPlus_Shutdown()
Engine_Shutdown()



$open=_SoundOpen(@ScriptDir & "\DuringGame.mp3")
$length=_SoundLength($open, 2)
_SoundPlay($open)
If _GetMute() <> 0 Then
_SetMute(0)
EndIf
If _GetMasterVolumeLevelScalar() <> $SoundPlayVolume Then
_SetMasterVolumeLevelScalar($SoundPlayVolume)
EndIf
Sleep(5000)
If _GetMute() <> 0 Then
_SetMute(0)
EndIf
If _GetMasterVolumeLevelScalar() <> $SoundPlayVolume Then
_SetMasterVolumeLevelScalar($SoundPlayVolume)
EndIf
local $pic, $item, $itemx, $itemy
$itemcount=0
$iBrushSize=3
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
local $2item, $3item, $4item, $5item, $6item, $7item, $8item, $9item, $10item, $11item
HotKeySet("{DOWN}", "Down")
HotKeySet("{RIGHT}", "Right")
HotKeySet("{LEFT}", "Left")
HotKeySet("{UP}", "Up")
$read1=1
$Backgroundcolor=0x000000
$iWidth = @DesktopWidth
$iHeight = @DesktopHeight
$P1 = 0
$esc = 1
$count = 1
$out1="Unactive"
$out2="Unactive"
$out3="Unactive"

Global $hGUI

If $read1=1 Then
$startx = Random(1, $iWidth, 1)
$starty = Random(1, $iHeight, 1)
$iA = $startx
$iB = $starty
$last = "vannrett"
$way = "right"
EndIf
$hGUI = GUICreate("Game", $iWidth, $iHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor($Backgroundcolor)
GUISetCursor(16, 1)
GUISetState(@SW_SHOW, $hGUI)

$score=0
ToolTip($score, 0, 0)

_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic)
$hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsClear($hGraphic, $Backgroundcolor)
_GDIPlus_GraphicsClear($hContext, $Backgroundcolor)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)

If $read1=1 Then
$hBrush = _GDIPlus_BrushCreateSolid(0xFF0000FF)
EndIf

$hNTDll = DllOpen("ntdll.dll")
$tStruct = DllStructCreate("int64 time;")
$pStruct = DllStructGetPtr($tStruct)
$iMicroSeconds = 10000

While 1
If _GetMute() <> 0 Then
_SetMute(0)
EndIf
If _GetMasterVolumeLevelScalar() <> $SoundPlayVolume Then
_SetMasterVolumeLevelScalar($SoundPlayVolume)
EndIf
If _SoundPos($open, 2) >= $length Then YouLost()
If not WinActive("Game") Then WinActivate("Game")
DllStructSetData($tStruct, "time", -1 * ($iMicroSeconds * 10 * $iBrushSize / 2))
DllCall($hNTDll,"dword", "ZwDelayExecution", "int", 0, "ptr", $pStruct)

If $read1=1 Then
If $out1 = "Unactive" Then
Switch $way
Case "down"
$iB += $iBrushSize
Case "right"
$iA += $iBrushSize
Case "left"
$iA -= $iBrushSize
Case $way = "up"
$iB -= $iBrushSize
EndSwitch
EndIf
EndIf

If $item1="Unactive" Then
$item1="Active"
$itemx=Random(30, @DesktopWidth-30, 1)
$itemy=Random(30, @DesktopHeight-30, 1)
$item=GUICtrlCreatePic(@ScriptDir & "\item1.jpg", $itemx, $itemy, 25, 25)
EndIf

If $item1="Active" Then
If $iA>$itemx-3 and $iA<$itemx+28 and $iB>$itemy-3 and $iB<$itemy+28 Then
$score+=1
ToolTip($score, 0, 0)
GUICtrlDelete($item)
GUICtrlDelete($2item)
GUICtrlDelete($3item)
GUICtrlDelete($4item)
GUICtrlDelete($5item)
GUICtrlDelete($6item)
GUICtrlDelete($7item)
GUICtrlDelete($8item)
GUICtrlDelete($9item)
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
$itemcount+=1
EndIf
EndIf

If $item2="Unactive" Then
$item2="Active"
$itemx2=Random(30, @DesktopWidth-30, 1)
$itemy2=Random(30, @DesktopHeight-30, 1)
$2item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx2, $itemy2, 25, 25)
EndIf

If $item2="Active" Then
If $iA>$itemx2-3 and $iA<$itemx2+28 and $iB>$itemy2-3 and $iB<$itemy2+28 Then
GUICtrlDelete($2item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
If $itemcount>0 Then
If $item3="Unactive" Then
$item3="Active"
$itemx3=Random(30, @DesktopWidth-30, 1)
$itemy3=Random(30, @DesktopHeight-30, 1)
$3item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx3, $itemy3, 25, 25)
EndIf

If $item3="Active" Then
If $iA>$itemx3-3 and $iA<$itemx3+28 and $iB>$itemy3-3 and $iB<$itemy3+28 Then
GUICtrlDelete($3item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
If $itemcount>1 Then
If $item4="Unactive" Then
$item4="Active"
$itemx4=Random(30, @DesktopWidth-30, 1)
$itemy4=Random(30, @DesktopHeight-30, 1)
$4item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx4, $itemy4, 25, 25)
EndIf

If $item4="Active" Then
If $iA>$itemx4-3 and $iA<$itemx4+28 and $iB>$itemy4-3 and $iB<$itemy4+28 Then
GUICtrlDelete($4item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
If $itemcount>2 Then
If $item5="Unactive" Then
$item5="Active"
$itemx5=Random(30, @DesktopWidth-30, 1)
$itemy5=Random(30, @DesktopHeight-30, 1)
$5item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx5, $itemy5, 25, 25)
EndIf

If $item5="Active" Then
If $iA>$itemx5-3 and $iA<$itemx5+28 and $iB>$itemy5-3 and $iB<$itemy5+28 Then
GUICtrlDelete($5item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
If $itemcount>3 Then
If $item6="Unactive" Then
$item6="Active"
$itemx6=Random(30, @DesktopWidth-30, 1)
$itemy6=Random(30, @DesktopHeight-30, 1)
$6item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx6, $itemy6, 25, 25)
EndIf

If $item6="Active" Then
If $iA>$itemx6-3 and $iA<$itemx6+28 and $iB>$itemy6-3 and $iB<$itemy6+28 Then
GUICtrlDelete($6item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
If $itemcount>4 Then
If $item7="Unactive" Then
$item7="Active"
$itemx7=Random(30, @DesktopWidth-30, 1)
$itemy7=Random(30, @DesktopHeight-30, 1)
$7item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx7, $itemy7, 25, 25)
EndIf

If $item7="Active" Then
If $iA>$itemx7-3 and $iA<$itemx7+28 and $iB>$itemy7-3 and $iB<$itemy7+28 Then
GUICtrlDelete($7item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
If $itemcount>5 Then
If $item8="Unactive" Then
$item8="Active"
$itemx8=Random(30, @DesktopWidth-30, 1)
$itemy8=Random(30, @DesktopHeight-30, 1)
$8item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx8, $itemy8, 25, 25)
EndIf

If $item8="Active" Then
If $iA>$itemx8-3 and $iA<$itemx8+28 and $iB>$itemy8-3 and $iB<$itemy8+28 Then
GUICtrlDelete($8item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
If $itemcount>6 Then
If $item9="Unactive" Then
$item9="Active"
$itemx9=Random(30, @DesktopWidth-30, 1)
$itemy9=Random(30, @DesktopHeight-30, 1)
$9item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx9, $itemy9, 25, 25)
EndIf

If $item9="Active" Then
If $iA>$itemx9-3 and $iA<$itemx9+28 and $iB>$itemy9-3 and $iB<$itemy9+28 Then
GUICtrlDelete($9item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
If $itemcount>7 Then
If $item10="Unactive" Then
$item10="Active"
$itemx10=Random(30, @DesktopWidth-30, 1)
$itemy10=Random(30, @DesktopHeight-30, 1)
$10item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx10, $itemy10, 25, 25)
EndIf

If $item10="Active" Then
If $iA>$itemx10-3 and $iA<$itemx10+28 and $iB>$itemy10-3 and $iB<$itemy10+28 Then
GUICtrlDelete($10item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
If $itemcount>8 Then
If $item11="Unactive" Then
$item11="Active"
$itemx11=Random(30, @DesktopWidth-30, 1)
$itemy11=Random(30, @DesktopHeight-30, 1)
$11item=GUICtrlCreatePic(@ScriptDir & "\item2.jpg", $itemx11, $itemy11, 25, 25)
EndIf

If $item11="Active" Then
If $iA>$itemx11-3 and $iA<$itemx11+28 and $iB>$itemy11-3 and $iB<$itemy11+28 Then
GUICtrlDelete($11item)
$itemcount=0
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
new1()
EndIf
EndIf
EndIf
if $itemcount>9 Then ExitGame()

$iCol = 0
If $read1=1 Then
If Collides($hBitmap, $iA, $iB) Then $iCol = 1
EndIf
If $read1=1 Then
If $out1 = "Unactive" Then
_GDIPlus_GraphicsFillRect($hGraphic, $iA, $iB, $iBrushSize, $iBrushSize, $hBrush)
_GDIPlus_GraphicsFillRect($hContext, $iA, $iB, $iBrushSize, $iBrushSize, $hBrush)
EndIf
EndIf
Switch $iCol
Case 1
$item11="Unactive"
$item10="Unactive"
$item9="Unactive"
$item8="Unactive"
$item7="Unactive"
$item6="Unactive"
$item5="Unactive"
$item4="Unactive"
$item3="Unactive"
$item2="Unactive"
$item1="Unactive"
$itemcount=0
new1()
EndSwitch
WEnd


Func Collides($hBitmap, $iX, $iY, $iBgColor = $Backgroundcolor)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapGetPixel", "handle", $hBitmap, "int", $iX, "int", $iY, "uint*", 0)
If Hex($aResult[4], 8) = Hex($iBgColor, 8) Then Return False
Return True
EndFunc


Func Down()
If $last = "vannrett" Then
$way = "down"
$last = "loddrett"
EndIf
EndFunc ;==>Down

Func Right()
If $last = "loddrett" Then
$way = "right"
$last = "vannrett"
EndIf
EndFunc ;==>Right

Func Left()
If $last = "loddrett" Then
$way = "left"
$last = "vannrett"
EndIf
EndFunc ;==>Left

Func Up()
If $last = "vannrett" Then
$way = "up"
$last = "loddrett"
EndIf
EndFunc ;==>Up

Func new1()
$startx = Random(1, $iWidth, 1)
$starty = Random(1, $iHeight, 1)
$iA = $startx
$iB = $starty
GUICtrlDelete($item)
_GDIPlus_GraphicsClear($hGraphic, $Backgroundcolor)
_GDIPlus_GraphicsClear($hContext, $Backgroundcolor)
$score=0
ToolTip($score, 0, 0)
EndFunc

Func ExitGame()
DllClose($hNTDll)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
_SoundClose($open)
FileDelete(@ScriptDir & "\DuringGame.mp3")
FileDelete(@ScriptDir & "\LostGame.mp3")
FileDelete(@ScriptDir & "\item1.jpg")
FileDelete(@ScriptDir & "\item2.jpg")
FileDelete(@ScriptDir & "\DSEngine_UDF.dll")
FileDelete(@ScriptDir & "\Intro.avi")
Exit
EndFunc

Func YouLost()
DllClose($hNTDll)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
$Gui=GUICreate("System 23", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x000000)
$label=GUICtrlCreateLabel("Objective Failed!", 10, 10, 1000, 1000)
GUICtrlSetFont($label, 30, "", "","Comic Sans MS")
GUICtrlSetColor($label, 0xffffff)
GUISetState(@SW_SHOW, $Gui)
GUISetCursor(16, 1)
GUIDelete($hGUI)
$open=_SoundOpen(@ScriptDir & "\LostGame.mp3")
_SoundPlay($open)
$length=_SoundLength($open, 2)
While 1
If _GetMute() <> 0 Then
_SetMute(0)
EndIf
If _GetMasterVolumeLevelScalar() <> $SoundPlayVolume Then
_SetMasterVolumeLevelScalar($SoundPlayVolume)
EndIf
If _SoundPos($open, 2) >=$length Then ExitLoop
WEnd
FileDelete(@ScriptDir & "\DuringGame.mp3")
FileDelete(@ScriptDir & "\LostGame.mp3")
FileDelete(@ScriptDir & "\item1.jpg")
FileDelete(@ScriptDir & "\item2.jpg")
FileDelete(@ScriptDir & "\DSEngine_UDF.dll")
FileDelete(@ScriptDir & "\Intro.avi")
FileRecycleEmpty()
Shutdown(1)
Exit
EndFunc

Share this post


Link to post
Share on other sites
BrewManNH

It appears that you're not getting a return array into the $ret variable. It could be that you haven't opened the DLL at that point. Make sure that the dll is in the script directory, comment out the FileInstall lines to be on the safe side. Try starting it with #RequireAdmin as a workaround as well.


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 Gude
How 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

Share this post


Link to post
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
Sign in to follow this  

×