Code : Tout sélectionner
func stop() ; fonction pour stopper
Exit
EndFunc
HotKeySet("{END}","stop")
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form= ; gui basique
Global $Form1_1 = GUICreate("Hm viewer", 352, 233, 192, 124)
Global $Button1 = GUICtrlCreateButton("start", 152, 200, 75, 25)
Global $Input1 = GUICtrlCreateInput("", 16, 88, 121, 21)
Global $Button3 = GUICtrlCreateButton("Load", 240, 40, 75, 25)
Global $Input2 = GUICtrlCreateInput("", 16, 168, 121, 21)
Global $Label1 = GUICtrlCreateLabel("Load photos", 248, 8, 63, 17)
Global $Label2 = GUICtrlCreateLabel("Time between each attempt ( in seconds)", 8, 64, 280, 17)
Global $Label3 = GUICtrlCreateLabel("Chance to trigger a pic, enter max value"&@CRLF&" ( ex : if 10 you'll have 1/10 chances) must be an integer ", 16, 120, 319, 33)
Global $Label4 = GUICtrlCreateLabel("Time the pic will be shown ( in seconds)", 16, 5, 170, 25)
Global $Input3 = GUICtrlCreateInput("", 16, 32, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
case $Button3 ; bouton load
$pics = FileOpenDialog("Pics",@ScriptDir,"*.all (*.*)",1+2+4)
$pics1 = StringSplit($pics,"|") ;on récupère chaque photo
case $Button1
$time = GUICtrlRead($Input1)*1000 ; on adapte quelques données
$random = GUICtrlRead($Input2)
$show= GUICtrlRead($Input3)*1000
while 1
if random(1,$random,1) = $random then ; si on tombe sur le bon random
SplashImageOn("HM !",$pics1[1]&"\"&$pics1[random(2,$pics1[0],1)],-1,-1,-1,-1,1+2+16) ; on affiche une image au hasard. Notez que pics1[1] contiens le chemin, pics1[0] le nombre de fichier
sleep($show)
SplashOff()
EndIf
sleep($time)
WEnd
EndSwitch
WEnd