Une fonction design Bureau:
Code : Tout sélectionner
#include-once
#include <FileConstants.au3>
#include <WinAPI.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
;#FUNCTION# ===================================================================================================================
; Name ..........: __SimpleSplashReader
; Description ...: Lisez des fichiers sur le bureau ou notifier des evenements avec le Style de votre choix
;................:
; Syntax ........: __SimpleSlashReader([$sFile = False[, $IconAnim = False[, $sString = ''[, $ReadTime = 2[, $sMoveTimes = 2[,
; $sWaitTimes = 1[, $aArrayConfig = 0[, $HWN_Icon = ''[, $GuiColor = 0]]]]]]]]])
; Parameters ....: $sFile - [optional] a string value. Default is False.
; $IconAnim - [optional] an unknown value. Default is False.
; $sString - [optional] a string value. Default is ''.
; $ReadTime - [optional] an unknown value. Default is 2.
; $sMoveTimes - [optional] a string value. Default is 2.
; $sWaitTimes - [optional] a string value. Default is 1.
; $aArrayConfig - [optional] an array of unknowns. Default is 0.
; $HWN_Icon - [optional] an unknown value. Default is ''.
; $GuiColor - [optional] an unknown value. Default is 0.
; Return values .: Effects
; Author ........: Numeric
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func __SimpleSplashReader($sFile = False, $IconAnim = False, $sString = '', _
$ReadTime = 2, $sMoveTimes = 2, $sWaitTimes = 1, $aArrayConfig = 0, $HWN_Icon = '', $GuiColor = 0)
HotKeySet('{ESC}', '__EXIT')
If $GuiColor = '' Or $GuiColor = Default Then $GuiColor = 0
If $sFile = '' Or $sFile = Default Then $sFile = False
If $IconAnim = '' Or $IconAnim = Default Then $IconAnim = False
If $ReadTime = '' Or $ReadTime = Default Then $ReadTime = 2
If $sMoveTimes = '' Or $sMoveTimes = Default Then $sMoveTimes = 2
If $sWaitTimes = '' Or $sWaitTimes = Default Then $sWaitTimes = 700
If $aArrayConfig = Default Then $aArrayConfig = 0
Local $hGuiWidth = @DesktopWidth, $hGuiHeight = 108, $hGuiLeft = 0, $hGuiTop = 0
Local $hiconLeft = 0, $hiconTop = 0, $hiconWidth = 96, $hiconHeight = 104
Local $hLabelLeft = 104, $hLabelTop = 40, $hLabelWidth = 1145, $hLabelHeight = 50;41
Local $hGUI = GUICreate('', $hGuiWidth, $hGuiHeight, $hGuiLeft, $hGuiTop, $WS_POPUP, __hGuiDefaultStyle())
Local $hLabel = GUICtrlCreateLabel('', $hLabelLeft, $hLabelTop, $hLabelWidth, $hLabelHeight)
Local $hIcon = GUICtrlCreateIcon($HWN_Icon, -1, $hiconLeft, $hiconTop, $hiconWidth, $hiconHeight)
Local $tag__Config = 'struct;int Size; uint Weight; wchar sFont[230]; long Color; hwnd Area; int areaflags; endstruct'
Local $isSTRUCT = DllStructCreate($tag__Config)
__DLLset($isSTRUCT, 'Size', 24)
__DLLset($isSTRUCT, 'Weight', 800)
__DLLset($isSTRUCT, 'sFont', 'MS Sans Serif')
__DLLset($isSTRUCT, 'Color', 0x0000FF)
__DLLset($isSTRUCT, 'Area', WinGetHandle($hGUI))
__DLLset($isSTRUCT, 'areaflags', 3000)
If IsArray($aArrayConfig) Then
GUICtrlSetFont($hLabel, $aArrayConfig[0], $aArrayConfig[1], 0, $aArrayConfig[2])
GUICtrlSetColor($hLabel, $aArrayConfig[3])
__GetWorkArea($hGUI, $GuiColor, $aArrayConfig[4])
Else
GUICtrlSetFont($hLabel, __get('Size', $isSTRUCT), __get('Weight', $isSTRUCT), 0, __get('sFont', $isSTRUCT))
GUICtrlSetColor($hLabel, __get('Color', $isSTRUCT))
__GetWorkArea(__get('Area', $isSTRUCT), 0, __get('areaflags', $isSTRUCT))
EndIf
GUISetState()
If $sFile = True Then
$sFile = 1
ElseIf $sFile = False Then
$sFile = 0
EndIf
If $IconAnim = True Then
$IconAnim = 1
ElseIf $IconAnim = False Then
$IconAnim = 0
EndIf
Local $isOpen, $ReadFile, $sOpenDialog
If $IconAnim = 1 Then
For $i = $hiconLeft To @DesktopWidth
__isWaiting(2)
GUICtrlSetPos($hIcon, $i)
Next
For $j = @DesktopWidth To $hiconLeft Step -1
__isWaiting($sMoveTimes)
GUICtrlSetPos($hIcon, $j)
Next
EndIf
Switch $sFile
Case 1
$sOpenDialog = FileOpenDialog('Fichier', @ScriptDir, 'Texte(*.txt;*pdf;*xps;word)', 1)
$isOpen = FileOpen($sOpenDialog, $FO_READ)
$ReadFile = FileReadToArray($isOpen)
If @error = 1 Then Exit
Local $sLeft = ''
FileClose($isOpen)
__isWaiting($sWaitTimes)
For $k = 0 To UBound($ReadFile) - 1
Local $sLengh = StringLen($ReadFile[$k])
For $l = 1 To $sLengh
__isWaiting($ReadTime)
$sLeft = StringLeft($ReadFile[$k], $l)
GUICtrlSetData($hLabel, $sLeft)
Next
Next
__isWaiting($sWaitTimes)
Case 0
$sLengh = StringLen($sString)
For $w = 0 To $sLengh
__isWaiting($ReadTime)
$sLeft = StringLeft($sString, $w)
GUICtrlSetData($hLabel, $sLeft)
Next
__isWaiting($sWaitTimes)
EndSwitch
$isSTRUCT = 0
GUIDelete($hGUI)
EndFunc ;==>__SimpleSplashReader
#Region INTERNAL FUNC
;==========================================================================================
;=================================FUNCTIONS REGIONS=======================================
;
;=========================================================================================
Func __EXIT()
Exit
EndFunc ;==>__EXIT
Func __get($VarName, $tag__Dll)
Return DllStructGetData($tag__Dll, $VarName)
EndFunc ;==>__get
;==============Remarque=============
; Juste pour l'ecriture
;==================================
Func __isWaiting($isTimes = 500)
Sleep($isTimes)
EndFunc ;==>__isWaiting
; #INTERNAL_USE_ONLY# ===========================================================================================================
; Name ..........: __SetBk_Mode
; Description ...: Set Bk mode
; Syntax ........: __SetBk_Mode([$hwnd = 0[, $iMode = $TRANSPARENT]])
; Parameters ....: $hwnd - [optional] a handle value. Default is 0.
; $iMode - [optional] an integer value. Default is $TRANSPARENT.
; Return values .: None
; Author ........: Numeric
; ===============================================================================================================================
Func __SetBk_Mode($hwnd = 0, $iMode = $TRANSPARENT)
Dim $isBK_Mode, $g_hDC, $isBK_Mode
$g_hDC = _WinAPI_GetDC($hwnd)
$isBK_Mode = _WinAPI_SetBkMode($g_hDC, $iMode)
Return $isBK_Mode
EndFunc ;==>__SetBk_Mode
Func __hGuiDefaultStyle()
Return BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)
EndFunc ;==>__hGuiDefaultStyle
Func __GetWorkArea($hForm, $AreaBkg_Color = 0, $itFlags = 120);TRANSPA
Local $tRECT = _WinAPI_GetWorkArea()
Local $iWidth = DllStructGetData($tRECT, 'Right') - DllStructGetData($tRECT, 'Left')
Local $iHeight = DllStructGetData($tRECT, 'Bottom') - DllStructGetData($tRECT, 'Top')
Local $X = DllStructGetData($tRECT, 'Left')
Local $Y = DllStructGetData($tRECT, 'Top')
GUISetBkColor($AreaBkg_Color, $hForm)
Return WinSetTrans($hForm, '', $itFlags)
EndFunc ;==>__GetWorkArea
Func __DLLset($tag__Dll, $Var, $Value)
Return DllStructSetData($tag__Dll, $Var, $Value)
EndFunc ;==>__DLLset
Func __ArrayForFunc($stringSize = 24, $sWeight = 800, $sFont = 'MS Sans Serif', $sColor = 0x0000FF, $AreaFl = 3000)
If $stringSize = '' Or $stringSize = Default Then $stringSize = 24
If $sWeight = '' Or $sWeight = Default Then $sWeight = 800
If $sFont = '' Or $sFont = Default Then $sFont = 'MS Sans Serif'
If $sColor = '' Or $sColor = Default Then $sColor = 0x0000FF
If $AreaFl = '' Or $AreaFl = Default Then $AreaFl = 3000
Local $isArray[5] = [$stringSize, $sWeight, $sFont, $sColor, $AreaFl]
Return $isArray
EndFunc ;==>__ArrayForFunc
;=============================================================================================
;==================================END REGIONS================================================
;============================================================================================
#EndRegion INTERNAL FUNC