Jump to content

my app was working but stopped...?


RichE
 Share

Recommended Posts

Afternoon All,

I have a weird problem, my app script that I wrote was working but now isn't and throws an error :

Line 796 (blah...)

Error Subscript used with non-array variable.

the compile didn't pick it up and i've checked through and can't see anything obvious.

can someone check it over, just to prove I'm not going mad...

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=icopeople.ico
#AutoIt3Wrapper_Outfile=USRinFO.exe
#AutoIt3Wrapper_Res_Description=Display user info
#AutoIt3Wrapper_Res_Fileversion=1.0.0.7
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_LegalCopyright=Richard Easton
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.8.1
Author:         Richard Easton

Script Function:
USER inFO.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

dim $h, $w, $usr, $hd, $hp, $hs, $cn, $os, $ld, $ls, $regvar, $USRinFO, $dirsize, $gmail, $gcal, $gdrv, $gsch, $mininmize, $homedir
;desktop metrics
$h = @DesktopHeight - 500
$w = @DesktopWidth - 300

;usr details
$usr = @UserName
$hd = @HomeDrive
$hp = @HomePath
$hs = @HomeShare
;local info
$cn = @ComputerName
$os = @OSArch

;network info
$ld = @LogonDomain
$ls = @LogonServer


$regvar = Regread("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun", "USRinFO")
if $regvar = @error Then
regwrite("HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun", "USRinFO", "REG_SZ", '"' & @Scriptdir & 'USRinFO.exe"')
EndIf


opt("MustDeclareVars", 0)
Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
Opt("TrayOnEventMode", 1) ;
TrayCreateItem("Display")
TrayItemSetOnEvent(-1, "Show")
TrayCreateItem("")
TrayCreateItem("About")
TrayItemSetOnEvent(-1, "about")


;gui
$USRinFO = GUICreate("USRinFO: " & $usr, 260, 450, $w, $h, $WS_EX_TOPMOST)
GUICtrlCreateGroup(" User Details ", 8, 8, 240, 120)

;users logon name
GUICtrlCreateLabel("Username:", 16, 30, 55, 17)
GUICtrlCreateLabel($usr, 80, 30, 100, 17)

;computer name
GUICtrlCreateLabel("PC Name:", 16, 48, 60, 17)
GUICtrlCreateLabel($cn, 80, 48, 100, 17)

;path to user home directory
GUICtrlCreateLabel("HomeDrive:", 16, 66, 60, 17)
GUICtrlCreateLabel($hd, 80, 66, 200, 17)

GUICtrlCreateLabel("Homepath:", 16, 84, 60, 17)
GUICtrlCreateLabel(StringMid($hp & $hs, 2), 80, 84, 200, 17)

$dirsize = DirGetSize($hd, 1)

if isarray($dirsize) Then
If $dirsize[0] > 1000000000 Then
$p = $dirsize[0] / 1024 / 1024 / 1024
GUICtrlCreateLabel("Size used:", 16, 104, 60, 17)
GUICtrlCreateLabel(Round($p, 2) & " GB", 80, 104, 100, 17)
Else
$p = ($dirsize[0] / 1024 / 1024)
GUICtrlCreateLabel("Size used:", 16, 104, 60, 17)
GUICtrlCreateLabel(Round($p, 2) & " MB", 80, 104, 100, 17)
EndIf
EndIf

GUICtrlCreateGroup("", -99, -99, 1, 1)

GUICtrlCreateGroup(" Network Details ", 8, 150, 240, 90)
;logon domain
GUICtrlCreateLabel("Domain:", 16, 172, 60, 17)
GUICtrlCreateLabel($ld, 80, 172, 100, 17)
;logon server
GUICtrlCreateLabel("Server:", 16, 190, 60, 17)
GUICtrlCreateLabel($ls, 80, 190, 100, 17)
;endgroup
GUICtrlCreateGroup("", -99, -99, 1, 1)

;Google controls
GUICtrlCreateGroup(" Google Apps ", 8, 300, 240, 65)

$gmail = GUICtrlCreateButton("gmail", 16, 320, 36, 36, $BS_ICON + $BS_FLAT)
GUICtrlSetImage($gmail, @ScriptDir & "g-mail.ico", 1)

$gcal = GUICtrlCreateButton("gcal", 53, 320, 36, 36, $BS_ICON + $BS_FLAT)
GUICtrlSetImage($gcal, @ScriptDir & "gcal.ico", 1)

$gdrv = GUICtrlCreateButton("gdrive", 90, 320, 36, 36, $BS_ICON + $BS_FLAT)
GUICtrlSetImage($gdrv, @ScriptDir & "drive.ico", 1)

$gsch = GUICtrlCreateButton("gsearch", 127, 320, 36, 36, $BS_ICON + $BS_FLAT)
GUICtrlSetImage($gsch, @ScriptDir & "gsearch.ico", 1)

If $os = "x86" Then
If FileExists("C:Program FilesSIMSSIMS .netPulsar.exe") Then
$sims = GUICtrlCreateButton("SIMS", 164, 320, 36, 36, $BS_ICON + $BS_FLAT)
GUICtrlSetImage($sims, @ScriptDir & "sims.ico", 1)
EndIf
ElseIf $os = "x64" Then
If FileExists("C:Program Files (x86)SIMSSIMS .netPulsar.exe") Then
$sims = GUICtrlCreateButton("SIMS", 164, 320, 36, 36, $BS_ICON + $BS_FLAT)
GUICtrlSetImage($sims, @ScriptDir & "sims.ico", 1)
EndIf
EndIf

GUICtrlCreateGroup("", -99, -99, 1, 1)


;button controls
$mininmize = GUICtrlCreateButton("Minimize", 8, 380, 80, 30)
$homedir = GUICtrlCreateButton("Home Dir", 90, 380, 80, 30)

GUISetState(@SW_SHOWMINIMIZED)


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $mininmize
GUISetState(@SW_MINIMIZE, $USRinFO)
Case $homedir
Run("explorer.exe " & $hd, @SystemDir)
Case $gmail
If @OSArch = "X64" Then
Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe https://mail.google.com/mail/?tab=mm&authuser=0", "")
Else
Run("C:\Program Files\Internet Explorer\iexplore.exe https://mail.google.com/mail/?tab=mm&authuser=0", "")
EndIf
Case $gcal
If @OSArch = "X64" Then
Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe https://www.google.com/calendar?tab=mc&authuser=0", "")
Else
Run("C:\Program Files\Internet Explorer\iexplore.exe https://www.google.com/calendar?tab=mc&authuser=0", "")
EndIf
Case $gdrv
If @OSArch = "X64" Then
Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe https://drive.google.com/?tab=mo&authuser=0", "")
Else
Run("C:\Program Files\Internet Explorer\iexplore.exe https://drive.google.com/?tab=mo&authuser=0", "")
EndIf
Case $gsch
If @OSArch = "X64" Then
Run("C:\Program Files (x86)\Internet Explorer\iexplore.exe http://www.google.com/webhp?hl=en&tab=mw&authuser=0", "")
Else
Run("C:\Program Files\Internet Explorer\iexplore.exe http://www.google.com/webhp?hl=en&tab=mw&authuser=0", "")
EndIf
Case $sims
If $os = "x86" Then
Run("C:Program FilesSIMSSIMS .netPulsar.exe", "")
ElseIf $os = "x64" Then
Run("C:Program Files (x86)SIMSSIMS .netPulsar.exe", "")
EndIf
EndSwitch
WEnd

Func show()
GUISetState(@SW_RESTORE, $USRinFO)
EndFunc   ;==>show

Func about()
MsgBox(64, "USRinFo", "USRinFo" & @CR & "Version: " & FileGetVersion("USRinFO.exe") & @CR & @CR & "Created By Richard Easton 2012")
EndFunc   ;==>about

Edit: Code updated

Edited by RichE

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Link to comment
Share on other sites

it's ok I found the problem, it wasn't the autoit app, it was my PC and the fact that I'd rebooted it and it hadn't remapped my home dir ... DOH!, so i'm currently looking at GPO's as to why it isn't

@mihaibr thx I'll put that in

thanks for the help

regards

Rich

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Link to comment
Share on other sites

So the story so far, the app works... on my pc and on a work mates, (we're both domain admins), but when I login on another "test" PC with my domain admin account and run it I get this:

Line 861 (file...blah)

Error: Variable used without being declared.

I've checked that I've declared ALL my variables, and I'm now completely stumped...

anyone got any ideas..?

regards

Rich

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Link to comment
Share on other sites

  • Moderators

RichE,

If you run AU3Check on the script you posted above it tells you that:

"M:ProgramAu3 Scriptsfred.au3"(88,40) : warning: $p possibly not declared/created yet
        $p = $dirsize[0] / 1024 / 1024 / 1024
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"M:ProgramAu3 Scriptsfred.au3"(127,77) : warning: $sims possibly not declared/created yet
        $sims = GUICtrlCreateButton("SIMS", 164, 320, 36, 36, $BS_ICON + $BS_FLAT)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"M:ProgramAu3 Scriptsfred.au3"(148,21) : warning: $nMsg possibly not declared/created yet
    $nMsg = GUIGetMsg()
    ~~~~~~~~~~~~~~~~~~~^

Given that you had problems with the folder size before, I would suggest that $p is a good place to start debugging. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

RichE,

If you run AU3Check on the script you posted above it tells you that:

"M:ProgramAu3 Scriptsfred.au3"(88,40) : warning: $p possibly not declared/created yet
$p = $dirsize[0] / 1024 / 1024 / 1024
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"M:ProgramAu3 Scriptsfred.au3"(127,77) : warning: $sims possibly not declared/created yet
$sims = GUICtrlCreateButton("SIMS", 164, 320, 36, 36, $BS_ICON + $BS_FLAT)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"M:ProgramAu3 Scriptsfred.au3"(148,21) : warning: $nMsg possibly not declared/created yet
$nMsg = GUIGetMsg()
~~~~~~~~~~~~~~~~~~~^

Given that you had problems with the folder size before, I would suggest that $p is a good place to start debugging. ;)

M23

Your a star !, sorted and working like a treat, now I just need to stop it from being closed on the taskbar right click

RichE

[font="'Arial Narrow';"]Current projects[/font]

[font="'Arial Narrow';"]are on my site [/font]Sellostring

Link to comment
Share on other sites

  • Moderators

RichE,

Try Opt("TrayMenuMode", 3) - the Help file explains what it does. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...