Jump to content

Trouble with Run statement


Recommended Posts

This program creates an almost absurd error.

progman.au3

#include <GUIConstants.au3>

$gui = GUICreate("Program Manager", 400, 300)

$config = FileOpen("progman-config.txt", 0)
$icons= Number(FileReadLine($config))
Dim $icon[$icons]
Dim $label[$icons]
Dim $run[$icons]
Dim $workingdir[$icons]

$popup = GUICtrlCreateContextMenu()
$popup_edit_config = GUICtrlCreateMenuItem("Edit Config", $popup)

For $i = 0 to $icons-1
    $temp = FileReadLine($config)
; $temp in format iconname, iconnum, left,top, label
    
    $temp = StringSplit($temp, ",")
    $icon[$i] = GUICtrlCreateIcon($temp[1],Number($temp[2]), Number($temp[3]), Number($temp[4]), 32,32)
    $label[$i] = GUICtrlCreateLabel($temp[5]&" ", Number($temp[3]), Number($temp[4])+32, -1 , 14, $SS_SIMPLE)
    $run[$i] = $temp[6]
    $workingdir[$i] = $temp[7]
    $pos = ControlGetPos($gui,"", $label[$i])
    $width = $pos[2]
    $left = Number($temp[3])
    GUICtrlSetPos($label[$i], $left - ($width-32)/2+ 4 , $temp[4]+32)
    GUICtrlSetBkColor($label[$i], 0x0000AA)
    GUICtrlSetColor($label[$i], 0xFFFFFF)
Next

GUISetBkColor(0xDDDDDD, $gui)
GUISetState(@SW_SHOW, $gui)


While 1
    $msg = GUIGetMsg(1)
    $mouse = GUIGetCursorInfo()
    For $i = 0 to $icons-1
        If $mouse[2]=1 And ($mouse[4]=$icon[$i] Or $mouse[4] = $label[$i]) Then
            Run ($run[$i], $workingdir[$i])
        EndIf
        
        If $mouse[3]=1 And ($mouse[4]=$icon[$i] Or $mouse[4] = $label[$i]) Then
        ; rightclick
        EndIf
    Next
    If $msg[0] = $GUI_EVENT_CLOSE Then
        Exit
    EndIf
WEnd

progman-config.txt

1
C:\windows\notepad.exe,0,140,10,Notepad,C:\windows\notepad.exe,C:\windows

When an icon is clicked, this program goes beserk. Suddenly, $mouse isn't an array any more. (This problem can be avoided with RunWait, but I want multiple programs to run at once.

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...