Hi, also ich hab ein Problem wenn ich zB "While 1" benutze, was ich aber muss, da ich ein Menu erstellen muss/will.
Ich denke das hängt mit den Arrays zusammen aber ich zeig euch einfach mal das Script.
Was passiert ist entweder, das TrayIcon wird gestartet, aber das Fenster nicht ODER er macht 300+ Prozesse von zB Settings.exe (Die in der While Schleife ist.)
Spoiler anzeigen
#include <GuiConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]Opt('GUIOnEventMode', 1); Den OnEvent-Mode benutzen
[/autoit] [autoit][/autoit] [autoit]Global $iCount = 4 ; Anzahl der Buttons
Global $ahButton[$iCount], $abOnOff[$iCount], $aPID[$iCount], $aProg[$iCount], $aProgName[$iCount], $ahIcon[$iCount]
$aProg[0] = 'farm\job.exe'
$aProg[1] = 'beta\Alert_HP.exe'
$aProg[2] = 'beta\Alert_MP.exe'
$aProg[3] = 'beta\Alert_SP.exe'
$aProgName[0] = '[*~JobLevel~*]'
$aProgName[1] = '[~*Alarm.HP*~]'
$aProgName[2] = '[~*Alarm.MP*~]'
$aProgName[3] = '[~*Alarm.SP*~]'
Global $aPos[$iCount][4] = [ _
[002, 040, 080, 020], _
[490, 220, 080, 025], _
[490, 250, 080, 025], _
[490, 280, 080, 025] _
]
Global $aIconPath[2] = [@ScriptDir & '\mats\off.ico', @ScriptDir & '\mats\on.ico']
GUICreate('PC_Crapper', 640, 422)
GUISetOnEvent($GUI_EVENT_CLOSE, '_End')
GUICtrlCreateLabel("*~Crappy~*", 260, 10)
GUICtrlCreateLabel("<=200 Targets p.sec.", 115, 45)
GUICtrlCreateLabel("(Close / return ", 215, 255)
GUICtrlCreateLabel("(Close / return", 215, 290)
GUICtrlCreateLabel("<BETA", 600, 223.5)
GUICtrlCreateLabel("<BETA", 600, 253.5)
GUICtrlCreateLabel("<BETA", 600, 283.5)
For $i = 0 To $iCount - 1
$ahButton[$i] = GUICtrlCreateButton($aProgName[$i], $aPos[$i][0], $aPos[$i][1], 80, 20)
GUICtrlSetOnEvent(-1, '_Switch')
$abOnOff[$i] = False
$ahIcon[$i] = GUICtrlCreateIcon($aIconPath[0], -1, $aPos[$i][0] + 85, $aPos[$i][1] - 2, 24, 24)
Next
GUICtrlCreateButton('[~*new choise*~]', 505, 10, 120, 20)
GUICtrlSetOnEvent(-1, '_StopAll2')
GUICtrlCreateButton('[~*restart*~]', 505, 30, 120, 20)
GUICtrlSetOnEvent(-1, '_restart')
GUICtrlCreateButton('[~*Standart*~]', 20, 10, 120, 20)
GUICtrlSetOnEvent(-1, '_Main')
GUICtrlCreateButton('[~*Exit VisiBot*~]', 240, 270, 120, 20)
GUICtrlSetOnEvent(-1, '_StopAll')
;***************HIERUM GEHT ES*******************
$MainMenu = GUICtrlCreateMenu("Main")
$MainMenuSettings = GUICtrlCreateMenuItem("Options", $MainMenu)
$MainMenuUpdate = GUICtrlCreateMenuItem("Update", $MainMenu)
GUICtrlCreateMenuItem("", $MainMenu)
$MainMenuQuit = GuiCtrlCreateMenuItem("Quit", $MainMenu)
$helpmenu = GuiCtrlCreateMenu ("?")
$aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu)
While 1
select
Case $MainMenuSettings
run("settings.exe")
Case $MainMenuUpdate
run("updater.exe")
Case $MainMenuQuit
ExitLoop
Exit
Case $aboutitem
msgbox (0,"About","?")
EndSelect
WEnd
;***************************************************************************
GUISetState()
While True
Sleep(20)
WEnd
Func _Main()
_StopAll2()
run("overlay_int.exe")
exit
EndFunc
Func _restart()
_StopAll2()
run("farm_int.exe")
Exit
EndFunc
Func _StartAll()
For $i = 0 To $iCount - 1
If Not $aPID[$i] Then $aPID[$i] = Run($aProg[$i])
$abOnOff[$i] = True
GUICtrlSetImage($ahIcon[$i], $aIconPath[1])
soundplay("sound\ac.wav")
Next
EndFunc
Func _StopAll()
For $i = 0 To $iCount - 1
If $aPID[$i] Then
ProcessClose($aPID[$i])
$aPID[$i] = 0
EndIf
If $abOnOff[$i] Then
$abOnOff[$i] = False
GUICtrlSetImage($ahIcon[$i], $aIconPath[0])
soundplay("sound\de_ac.wav")
EndIf
Next
exit
EndFunc
Func _StopAll2()
For $i = 0 To $iCount - 1
If $aPID[$i] Then
ProcessClose($aPID[$i])
$aPID[$i] = 0
EndIf
If $abOnOff[$i] Then
$abOnOff[$i] = False
GUICtrlSetImage($ahIcon[$i], $aIconPath[0])
soundplay("sound\de_ac.wav")
EndIf
Next
EndFunc
Func _Switch()
Local $i = (@GUI_CtrlId - $ahButton[0]) / 2
$abOnOff[$i] = Not $abOnOff[$i]
Switch $abOnOff[$i]
Case True
GUICtrlSetImage($ahIcon[$i], $aIconPath[1])
$aPID[$i] = Run($aProg[$i])
soundplay("sound\ac.wav")
Case False
GUICtrlSetImage($ahIcon[$i], $aIconPath[0])
ProcessClose($aPID[$i])
$aPID[$i] = 0
soundplay("sound\de_ac.wav")
EndSwitch
EndFunc
Func _End()
Exit
EndFunc