Je cherche un moyen pour ne pas permettre a mon application de s'exécuter deux fois, donc la question est : Comment laisser une seule instance en exécution de mon application ?
Voici mon script Autoit : DJ Buzz Radio.au3
► Afficher le texteDJ Buzz Radio.au3
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Vinyl.ico ;http://www.iconarchive.com/show/80s-icons-by-iconshock/vinyl-icon.html
#AutoIt3Wrapper_UseUpx=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <TrayConstants.au3>
#include <Misc.au3>
Local $sOccurenceName = @ScriptFullPath
MsgBox("","",$sOccurenceName)
If _Singleton($sOccurenceName,1) = 0 Then
MsgBox(16, "Error", "Another instance of this program is already running.")
Exit
EndIf
HotKeySet("{Esc}", "Quit")
Local $Title = "DJ Buzz Radio by Hackoo 2018"
Local $MsgAR = ChrW(1575)&ChrW(1590)&ChrW(1594)&ChrW(1591)&ChrW(32)&ChrW(1593)&ChrW(1604)&ChrW(1609)& _
ChrW(32)&ChrW(1605)&ChrW(1601)&ChrW(1578)&ChrW(1575)&ChrW(1581)&ChrW(32)&ChrW(91)&ChrW(1573)&ChrW(1610)& _
ChrW(1587)&ChrW(1603)&ChrW(93)&ChrW(32)&ChrW(1604)&ChrW(1573)&ChrW(1610)&ChrW(1602)&ChrW(1575)&ChrW(1601)& _
ChrW(32)&ChrW(1575)&ChrW(1604)&ChrW(1605)&ChrW(1608)&ChrW(1587)&ChrW(1610)&ChrW(1602)&ChrW(1609)&ChrW(32)& _
ChrW(1608)&ChrW(1602)&ChrW(1605)&ChrW(32)&ChrW(1576)&ChrW(1573)&ChrW(1606)&ChrW(1607)&ChrW(1575)&ChrW(1569)& _
ChrW(32)&ChrW(1607)&ChrW(1584)&ChrW(1575)&ChrW(32)&ChrW(1575)&ChrW(1604)&ChrW(1578)&ChrW(1591)&ChrW(1576)& _
ChrW(1610)&ChrW(1602)
Local $URL = ChrW(104)&ChrW(116)&ChrW(116)&ChrW(112)&ChrW(58)&ChrW(47)&ChrW(47)&ChrW(119)&ChrW(119)& _
ChrW(119)&ChrW(46)&ChrW(99)&ChrW(104)&ChrW(111)&ChrW(99)&ChrW(114)&ChrW(97)&ChrW(100)&ChrW(105)&ChrW(111)& _
ChrW(115)&ChrW(46)&ChrW(99)&ChrW(104)&ChrW(47)&ChrW(100)&ChrW(106)&ChrW(98)&ChrW(117)&ChrW(122)&ChrW(122)& _
ChrW(114)&ChrW(97)&ChrW(100)&ChrW(105)&ChrW(111)&ChrW(95)&ChrW(119)&ChrW(105)&ChrW(110)&ChrW(100)&ChrW(111)& _
ChrW(119)&ChrW(115)&ChrW(46)&ChrW(109)&ChrW(112)&ChrW(51)&ChrW(46)&ChrW(97)&ChrW(115)&ChrW(120)
Local $MsgFR = "Tapez la touche [Echap] pour arrêter la musique et quitter cette application"
Local $MsgEN = "Press [ESC] button to stop the music and quit this application"
TrayTip($Title,$MsgAR , 0, $TIP_ICONASTERISK)
TrayTip($Title,$MsgEN & @CRLF & $MsgFR, 0, $TIP_ICONASTERISK)
$oMyError = ObjEvent("AutoIt.Error", "Quit")
$oMediaplayer = ObjCreate("WMPlayer.OCX.7")
If Not IsObj($oMediaplayer) Then Exit
$oMediaplayer.URL = $URL
$oMediaPlayControl = $oMediaplayer.Controls
$oMediaPlaySettings = $oMediaplayer.Settings
$oMediaPlaySettings.volume = 100
$oMediaPlayControl.Play
While $oMediaplayer.currentmedia.duration = 0
Sleep(100)
WEnd
Func Quit()
$oMediaPlayControl.Stop
Exit
EndFunc
#AutoIt3Wrapper_Icon=Vinyl.ico ;http://www.iconarchive.com/show/80s-icons-by-iconshock/vinyl-icon.html
#AutoIt3Wrapper_UseUpx=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <TrayConstants.au3>
#include <Misc.au3>
Local $sOccurenceName = @ScriptFullPath
MsgBox("","",$sOccurenceName)
If _Singleton($sOccurenceName,1) = 0 Then
MsgBox(16, "Error", "Another instance of this program is already running.")
Exit
EndIf
HotKeySet("{Esc}", "Quit")
Local $Title = "DJ Buzz Radio by Hackoo 2018"
Local $MsgAR = ChrW(1575)&ChrW(1590)&ChrW(1594)&ChrW(1591)&ChrW(32)&ChrW(1593)&ChrW(1604)&ChrW(1609)& _
ChrW(32)&ChrW(1605)&ChrW(1601)&ChrW(1578)&ChrW(1575)&ChrW(1581)&ChrW(32)&ChrW(91)&ChrW(1573)&ChrW(1610)& _
ChrW(1587)&ChrW(1603)&ChrW(93)&ChrW(32)&ChrW(1604)&ChrW(1573)&ChrW(1610)&ChrW(1602)&ChrW(1575)&ChrW(1601)& _
ChrW(32)&ChrW(1575)&ChrW(1604)&ChrW(1605)&ChrW(1608)&ChrW(1587)&ChrW(1610)&ChrW(1602)&ChrW(1609)&ChrW(32)& _
ChrW(1608)&ChrW(1602)&ChrW(1605)&ChrW(32)&ChrW(1576)&ChrW(1573)&ChrW(1606)&ChrW(1607)&ChrW(1575)&ChrW(1569)& _
ChrW(32)&ChrW(1607)&ChrW(1584)&ChrW(1575)&ChrW(32)&ChrW(1575)&ChrW(1604)&ChrW(1578)&ChrW(1591)&ChrW(1576)& _
ChrW(1610)&ChrW(1602)
Local $URL = ChrW(104)&ChrW(116)&ChrW(116)&ChrW(112)&ChrW(58)&ChrW(47)&ChrW(47)&ChrW(119)&ChrW(119)& _
ChrW(119)&ChrW(46)&ChrW(99)&ChrW(104)&ChrW(111)&ChrW(99)&ChrW(114)&ChrW(97)&ChrW(100)&ChrW(105)&ChrW(111)& _
ChrW(115)&ChrW(46)&ChrW(99)&ChrW(104)&ChrW(47)&ChrW(100)&ChrW(106)&ChrW(98)&ChrW(117)&ChrW(122)&ChrW(122)& _
ChrW(114)&ChrW(97)&ChrW(100)&ChrW(105)&ChrW(111)&ChrW(95)&ChrW(119)&ChrW(105)&ChrW(110)&ChrW(100)&ChrW(111)& _
ChrW(119)&ChrW(115)&ChrW(46)&ChrW(109)&ChrW(112)&ChrW(51)&ChrW(46)&ChrW(97)&ChrW(115)&ChrW(120)
Local $MsgFR = "Tapez la touche [Echap] pour arrêter la musique et quitter cette application"
Local $MsgEN = "Press [ESC] button to stop the music and quit this application"
TrayTip($Title,$MsgAR , 0, $TIP_ICONASTERISK)
TrayTip($Title,$MsgEN & @CRLF & $MsgFR, 0, $TIP_ICONASTERISK)
$oMyError = ObjEvent("AutoIt.Error", "Quit")
$oMediaplayer = ObjCreate("WMPlayer.OCX.7")
If Not IsObj($oMediaplayer) Then Exit
$oMediaplayer.URL = $URL
$oMediaPlayControl = $oMediaplayer.Controls
$oMediaPlaySettings = $oMediaplayer.Settings
$oMediaPlaySettings.volume = 100
$oMediaPlayControl.Play
While $oMediaplayer.currentmedia.duration = 0
Sleep(100)
WEnd
Func Quit()
$oMediaPlayControl.Stop
Exit
EndFunc
GeSHi © Extension Codebox Plus