| »Master |
| | ecco la mia, l'o chiamata xLoad e se volete la metto apposto per farne una UDF (cosi' metto altri parametri opzionali, tolgo le cose che ho messo per il debug, eccetera xd), anche se cosi' com'e' basta che la mettete nel vostro script che funziona, basta chiamare _xLoad_Start(), _xLoad_SetProgress() ed _xLoad_End(), potete creare diverse finestre di caricamento, pero' non ho ancora aggiunto l'opzione per le coordinate, quindi verranno sovrapposte xD l'o fatto in un paio di ore, pero' 'e ancora da perfezionare asd CODICE #include<GDIPlus.au3> #include<GUIConstantsEx.au3> #include<WinAPI.au3> #include<WindowsConstants.au3> #include<Array.au3> Global Const $nPI = 3.1415926535897932384626433832795
$xLoad=_xLoad_Start("»MASTER") Sleep(12000) ToolTip("Imposto il percentaggio a 10%") _xLoad_SetProgress($xLoad, 10) Sleep(1000) ToolTip("Imposto il percentaggio a 20%") _xLoad_SetProgress($xLoad, 20) Sleep(1000) ToolTip("Imposto il percentaggio a 50%") _xLoad_SetProgress($xLoad, 50) Sleep(1000) ToolTip("Imposto il percentaggio a 80%") _xLoad_SetProgress($xLoad, 80) Sleep(1000) ToolTip("Imposto il percentaggio a 100%") _xLoad_SetProgress($xLoad, 100) Sleep(1000) ToolTip("") MsgBox(0, "", "Io sono una MsgBox, ed sono qui per informarvi che la schermata di caricamento fatta da master non blocca lo script principale lol") Sleep(2000) _xLoad_End($xLoad)
Func _xLoad_Start($text) ; by »Master at autoit.forumcommunity.net - last update : 25/06/2012 Local $_XLOAD_VARIABLES[50], $n, $x _GDIPlus_Startup() $_XLOAD_VARIABLES[0]=1 ; 1=active 0=inactive $_XLOAD_VARIABLES[1]=StringUpper(StringLeft($text, 30)) $_XLOAD_VARIABLES[2]=GUICreate("xLoad - Loading "&$_XLOAD_VARIABLES[0], 540, 300, Default, Default, $WS_POPUPWINDOW, $WS_EX_LAYERED) GUISetBkColor(0x010101, $_XLOAD_VARIABLES[2]) WinSetTrans($_XLOAD_VARIABLES[2], "", 250) GUISetState(@SW_SHOW, $_XLOAD_VARIABLES[2]) $_XLOAD_VARIABLES[3]=GUICtrlCreatePic("", 0, 0, 540, 300) $_XLOAD_VARIABLES[4]=_GDIPlus_GraphicsCreateFromHWND($_XLOAD_VARIABLES[2]) $_XLOAD_VARIABLES[5]=_GDIPlus_PenCreate(0xFFFEFEFE, 5) ; border white pen $_XLOAD_VARIABLES[6]=_GDIPlus_BrushCreateSolid(0x20010101) ; backcolor w/ alpha $_XLOAD_VARIABLES[7]=_GDIPlus_BrushCreateSolid(0xFF010101) ; solid backcolor $_XLOAD_VARIABLES[8]=_GDIPlus_BrushCreateSolid(0xFFFEFEFE) ; hBrush - text solid white $_XLOAD_VARIABLES[9]=_GDIPlus_StringFormatCreate() ; hFormat $_XLOAD_VARIABLES[10]=_GDIPlus_FontFamilyCreate("Arial") ; hFamily $_XLOAD_VARIABLES[11]=_GDIPlus_FontCreate($_XLOAD_VARIABLES[10], 18) ; hFont $tLayout=_GDIPlus_RectFCreate(0, 200) $aInfo=_GDIPlus_GraphicsMeasureString($_XLOAD_VARIABLES[4], $_XLOAD_VARIABLES[1], $_XLOAD_VARIABLES[11], $tLayout, $_XLOAD_VARIABLES[9]) $_XLOAD_VARIABLES[12]=270-(DllStructGetData($aInfo[0], "Width")/2) ; X $_XLOAD_VARIABLES[13]=80-(DllStructGetData($aInfo[0], "Height")/2) ; Y $_XLOAD_VARIABLES[14]=1 ; 1 - Initial state $_XLOAD_VARIABLES[15]=1 ; State 0 - Current Char $_XLOAD_VARIABLES[16]=0 ; State 0 - Chars List $_XLOAD_VARIABLES[17]=0 ; State 0 - Current Char $_XLOAD_VARIABLES[18]=0 ; State 0 - Current Char $_XLOAD_VARIABLES[19]=DllStructGetData($aInfo[0], "Height") ; Height $_XLOAD_VARIABLES[20]=DllStructGetData($aInfo[0], "Width") ; Width $_XLOAD_VARIABLES[23]=1 ; State 0 - Current Char $_XLOAD_VARIABLES[24]=1 ; State 0 - Current Char $_XLOAD_VARIABLES[25]=_GDIPlus_FontCreate($_XLOAD_VARIABLES[10], 12) ; hFont $_XLOAD_VARIABLES[26]=_GDIPlus_PenCreate(0xFFFEFEFE, 10) $_XLOAD_VARIABLES[27]=$nPI/100
If Not IsDeclared("_GLOB_XLOAD_VARIABLES") Then $n=0 Global $_GLOB_XLOAD_VARIABLES[1][UBound($_XLOAD_VARIABLES, 1)] Else $n=UBound($_GLOB_XLOAD_VARIABLES, 1) ReDim $_GLOB_XLOAD_VARIABLES[$n+1][UBound($_GLOB_XLOAD_VARIABLES, 2)] EndIf For $x=0 To UBound($_XLOAD_VARIABLES, 1)-1 $_GLOB_XLOAD_VARIABLES[$n][$x]=$_XLOAD_VARIABLES[$x] Next AdlibRegister("_xLoad_Draw", 60) Return $n EndFunc
Func _xLoad_Draw() Local $x, $c, $txt, $tLayout If Not IsDeclared("_GLOB_XLOAD_VARIABLES") Then Return For $x=0 To UBound($_GLOB_XLOAD_VARIABLES, 1)-1 _DebugWrite("Now EXEC>"&$x) If $_GLOB_XLOAD_VARIABLES[$x][0]=0 Then ContinueLoop _DebugWrite("ISACTIVE - START PROCEDURE>"&$_GLOB_XLOAD_VARIABLES[$x][14])
For $c=0 To $_GLOB_XLOAD_VARIABLES[$x][24] $txt&="." Next $_GLOB_XLOAD_VARIABLES[$x][24]+=1 If $_GLOB_XLOAD_VARIABLES[$x][24]>=10 Then $_GLOB_XLOAD_VARIABLES[$x][24]=0 $tLayout=_GDIPlus_RectFCreate(10, 10) $aInfo=_GDIPlus_GraphicsMeasureString($_GLOB_XLOAD_VARIABLES[$x][4], "Loading"&$txt, $_GLOB_XLOAD_VARIABLES[$x][25], $tLayout, $_GLOB_XLOAD_VARIABLES[$x][9]) _GDIPlus_GraphicsFillRect($_GLOB_XLOAD_VARIABLES[$x][4], DllStructGetData($aInfo[0], "X"), DllStructGetData($aInfo[0], "Y"), DllStructGetData($aInfo[0], "Width"), DllStructGetData($aInfo[0], "Height"), $_GLOB_XLOAD_VARIABLES[$x][7]) _GDIPlus_GraphicsDrawStringEx($_GLOB_XLOAD_VARIABLES[$x][4], "Loading"&$txt, $_GLOB_XLOAD_VARIABLES[$x][25], $tLayout, $_GLOB_XLOAD_VARIABLES[$x][9], $_GLOB_XLOAD_VARIABLES[$x][8])
Switch $_GLOB_XLOAD_VARIABLES[$x][14] Case 1 If $_GLOB_XLOAD_VARIABLES[$x][15]>StringLen($_GLOB_XLOAD_VARIABLES[$x][1]) Then $_GLOB_XLOAD_VARIABLES[$x][14]=2 $_GLOB_XLOAD_VARIABLES[$x][15]=0 $_GLOB_XLOAD_VARIABLES[$x][16]=0 $_GLOB_XLOAD_VARIABLES[$x][17]=0 $_GLOB_XLOAD_VARIABLES[$x][18]=0 $_GLOB_XLOAD_VARIABLES[$x][21]=0 $_GLOB_XLOAD_VARIABLES[$x][22]=0 $_GLOB_XLOAD_VARIABLES[$x][23]=0 ContinueCase EndIf If StringLen($_GLOB_XLOAD_VARIABLES[$x][16])<=2 Then $_GLOB_XLOAD_VARIABLES[$x][16]="" For $c=1 To 5 $_GLOB_XLOAD_VARIABLES[$x][16]&=Chr(65+Random(0, 25, 1))&"|" Next $_GLOB_XLOAD_VARIABLES[$x][16]&=StringMid($_GLOB_XLOAD_VARIABLES[$x][1], $_GLOB_XLOAD_VARIABLES[$x][15], 1)&"|"&Chr(65+Random(0, 25, 1))&"|"&Chr(65+Random(0, 25, 1)) _DebugWrite(">>>>> "&$_GLOB_XLOAD_VARIABLES[$x][16]) $_GLOB_XLOAD_VARIABLES[$x][17]=1 EndIf If $_GLOB_XLOAD_VARIABLES[$x][17]<=8 Then _DebugWrite("---------------------") $climit=0 ;~ $_GLOB_XLOAD_VARIABLES[$x][23]*=-1 ;~ If $_GLOB_XLOAD_VARIABLES[$x][23]=-1 Then $climit=-0.5 For $c=$_GLOB_XLOAD_VARIABLES[$x][17] To 1 Step -1 $split=StringSplit($_GLOB_XLOAD_VARIABLES[$x][16], "|") If $c>$split[0] Or $climit>=5 Then ContinueLoop $txt=$split[$c] $climit+=1 _DebugWrite("["&$c&"]"&$txt)
$tLayout=_GDIPlus_RectFCreate(Round($_GLOB_XLOAD_VARIABLES[$x][12]+$_GLOB_XLOAD_VARIABLES[$x][22]), Round($_GLOB_XLOAD_VARIABLES[$x][13]-($_GLOB_XLOAD_VARIABLES[$x][19]*3)+($_GLOB_XLOAD_VARIABLES[$x][19]*$climit))) $aInfo=_GDIPlus_GraphicsMeasureString($_GLOB_XLOAD_VARIABLES[$x][4], $txt, $_GLOB_XLOAD_VARIABLES[$x][11], $tLayout, $_GLOB_XLOAD_VARIABLES[$x][9]) If $_GLOB_XLOAD_VARIABLES[$x][21]<DllStructGetData($aInfo[0], "Width") Then $_GLOB_XLOAD_VARIABLES[$x][21]=DllStructGetData($aInfo[0], "Width") If $climit<=1 Then _GDIPlus_GraphicsFillRect($_GLOB_XLOAD_VARIABLES[$x][4], DllStructGetData($aInfo[0], "X"), DllStructGetData($aInfo[0], "Y")-($_GLOB_XLOAD_VARIABLES[$x][19]*0.5), $_GLOB_XLOAD_VARIABLES[$x][21], DllStructGetData($aInfo[0], "Height"), $_GLOB_XLOAD_VARIABLES[$x][7])
_GDIPlus_GraphicsFillRect($_GLOB_XLOAD_VARIABLES[$x][4], DllStructGetData($aInfo[0], "X"), DllStructGetData($aInfo[0], "Y"), $_GLOB_XLOAD_VARIABLES[$x][21], DllStructGetData($aInfo[0], "Height"), $_GLOB_XLOAD_VARIABLES[$x][7]) ;~ If $_GLOB_XLOAD_VARIABLES[$x][23]=1 Then ;~ _GDIPlus_GraphicsFillRect($_GLOB_XLOAD_VARIABLES[$x][4], DllStructGetData($aInfo[0], "X"), DllStructGetData($aInfo[0], "Y")+($_GLOB_XLOAD_VARIABLES[$x][19]*0.5), $_GLOB_XLOAD_VARIABLES[$x][21], DllStructGetData($aInfo[0], "Height"), $_GLOB_XLOAD_VARIABLES[$x][7]) ;~ Else ;~ _GDIPlus_GraphicsFillRect($_GLOB_XLOAD_VARIABLES[$x][4], DllStructGetData($aInfo[0], "X"), DllStructGetData($aInfo[0], "Y"), $_GLOB_XLOAD_VARIABLES[$x][21], DllStructGetData($aInfo[0], "Height")+($_GLOB_XLOAD_VARIABLES[$x][19]*0.5), $_GLOB_XLOAD_VARIABLES[$x][7]) ;~ EndIf
_GDIPlus_GraphicsDrawStringEx($_GLOB_XLOAD_VARIABLES[$x][4], $txt, $_GLOB_XLOAD_VARIABLES[$x][11], $tLayout, $_GLOB_XLOAD_VARIABLES[$x][9], $_GLOB_XLOAD_VARIABLES[$x][8]) Next _DebugWrite("---------------------") If $_GLOB_XLOAD_VARIABLES[$x][23]=1 Then $_GLOB_XLOAD_VARIABLES[$x][17]+=1 Else _GDIPlus_GraphicsFillRect($_GLOB_XLOAD_VARIABLES[$x][4], Round($_GLOB_XLOAD_VARIABLES[$x][12]), Round($_GLOB_XLOAD_VARIABLES[$x][13]-($_GLOB_XLOAD_VARIABLES[$x][19]*2)), $_GLOB_XLOAD_VARIABLES[$x][20]+$_GLOB_XLOAD_VARIABLES[$x][21], $_GLOB_XLOAD_VARIABLES[$x][19]*5)
$tLayout=_GDIPlus_RectFCreate($_GLOB_XLOAD_VARIABLES[$x][12], $_GLOB_XLOAD_VARIABLES[$x][13]) $aInfo=_GDIPlus_GraphicsMeasureString($_GLOB_XLOAD_VARIABLES[$x][4], StringLeft($_GLOB_XLOAD_VARIABLES[$x][1], $_GLOB_XLOAD_VARIABLES[$x][15]), $_GLOB_XLOAD_VARIABLES[$x][11], $tLayout, $_GLOB_XLOAD_VARIABLES[$x][9]) $_GLOB_XLOAD_VARIABLES[$x][22]=DllStructGetData($aInfo[0], "Width")*0.95 _GDIPlus_GraphicsDrawStringEx($_GLOB_XLOAD_VARIABLES[$x][4], StringLeft($_GLOB_XLOAD_VARIABLES[$x][1], $_GLOB_XLOAD_VARIABLES[$x][15]), $_GLOB_XLOAD_VARIABLES[$x][11], $tLayout, $_GLOB_XLOAD_VARIABLES[$x][9], $_GLOB_XLOAD_VARIABLES[$x][8]) $_GLOB_XLOAD_VARIABLES[$x][16]=0 $_GLOB_XLOAD_VARIABLES[$x][21]=0 $_GLOB_XLOAD_VARIABLES[$x][15]+=1 EndIf Case 2 If $_GLOB_XLOAD_VARIABLES[$x][15]>=$_GLOB_XLOAD_VARIABLES[$x][20] Then $_GLOB_XLOAD_VARIABLES[$x][14]=3 $_GLOB_XLOAD_VARIABLES[$x][15]=170 $_GLOB_XLOAD_VARIABLES[$x][16]=0 $_GLOB_XLOAD_VARIABLES[$x][26]=$nPI/100 ContinueLoop EndIf _GDIPlus_GraphicsDrawLine($_GLOB_XLOAD_VARIABLES[$x][4], $_GLOB_XLOAD_VARIABLES[$x][12]+($_GLOB_XLOAD_VARIABLES[$x][20]/2)-($_GLOB_XLOAD_VARIABLES[$x][15]/2), $_GLOB_XLOAD_VARIABLES[$x][13]+$_GLOB_XLOAD_VARIABLES[$x][19]-2, $_GLOB_XLOAD_VARIABLES[$x][12]+($_GLOB_XLOAD_VARIABLES[$x][20]/2)+($_GLOB_XLOAD_VARIABLES[$x][15]/2), $_GLOB_XLOAD_VARIABLES[$x][13]+$_GLOB_XLOAD_VARIABLES[$x][19]-2, $_GLOB_XLOAD_VARIABLES[$x][5]) $_GLOB_XLOAD_VARIABLES[$x][15]+=13 Case 3 ;~ If $_GLOB_XLOAD_VARIABLES[$x][15]<=0 Then ;~ $_GLOB_XLOAD_VARIABLES[$x][16]+=1 ;~ If $_GLOB_XLOAD_VARIABLES[$x][16]>=30 Then ;~ ContinueLoop ;~ EndIf ;~ Return ;~ EndIf ;~ $_GLOB_XLOAD_VARIABLES[$x][15]-=5 ;~ _GDIPlus_PenSetColor($_GLOB_XLOAD_VARIABLES[$x][26], "0xFFFEFEFE") ;~ _GDIPlus_GraphicsDrawArc($_GLOB_XLOAD_VARIABLES[$x][4], 270-$_GLOB_XLOAD_VARIABLES[$x][15]/2, 200-$_GLOB_XLOAD_VARIABLES[$x][15]/2, $_GLOB_XLOAD_VARIABLES[$x][15], $_GLOB_XLOAD_VARIABLES[$x][15], 0, 360, $_GLOB_XLOAD_VARIABLES[$x][26]) ;~ Case 4 $_GLOB_XLOAD_VARIABLES[$x][15]+=Random($_GLOB_XLOAD_VARIABLES[$x][26]*0.8, $_GLOB_XLOAD_VARIABLES[$x][26]*1.2) $x1 = Cos($_GLOB_XLOAD_VARIABLES[$x][15] + $nPI / 2) * 150 / 2 $y1 = Sin($_GLOB_XLOAD_VARIABLES[$x][15] + $nPI / 2) * 150 / 2 $x2 = Cos($_GLOB_XLOAD_VARIABLES[$x][15] + $nPI / 2 + (2 * $nPI) / 3) * 150 / 2 $y2 = Sin($_GLOB_XLOAD_VARIABLES[$x][15] + $nPI / 2 + (2 * $nPI) / 3) * 150 / 2 $x3 = Cos($_GLOB_XLOAD_VARIABLES[$x][15] + $nPI / 2 + ((2 * $nPI) / 3) * 2) * 150 / 2 $y3 = Sin($_GLOB_XLOAD_VARIABLES[$x][15] + $nPI / 2 + ((2 * $nPI) / 3) * 2) * 150 / 2
_GDIPlus_GraphicsFillRect($_GLOB_XLOAD_VARIABLES[$x][4], 180, 120, 180, 180, $_GLOB_XLOAD_VARIABLES[$x][6])
_GDIPlus_GraphicsDrawLine($_GLOB_XLOAD_VARIABLES[$x][4], 270+$x1, 200+$y1, 270+$x2, 200+$y2, $_GLOB_XLOAD_VARIABLES[$x][5]) _GDIPlus_GraphicsDrawLine($_GLOB_XLOAD_VARIABLES[$x][4], 270+$x2, 200+$y2, 270+$x3, 200+$y3, $_GLOB_XLOAD_VARIABLES[$x][5]) _GDIPlus_GraphicsDrawLine($_GLOB_XLOAD_VARIABLES[$x][4], 270+$x3, 200+$y3, 270+$x1, 200+$y1, $_GLOB_XLOAD_VARIABLES[$x][5])
EndSwitch Next EndFunc
Func _xLoad_SetProgress($n, $perc) $_GLOB_XLOAD_VARIABLES[$n][26]=($nPI/300)*($perc/2) EndFunc
Func _DebugWrite($txt, $line=@ScriptLineNumber) ;~ ConsoleWrite("============>"&$line&@TAB&$txt) $txt=StringReplace($txt, @CRLF, @LF) $txt=StringReplace($txt, @CR, @LF) $split=StringSplit($txt, @LF) For $x=1 To $split[0] If $split[$x]<>"" Then ConsoleWrite(@LF&"===>"&@HOUR&":"&@MIN&":"&@SEC&"."&@MSEC&" - PID:"&@AutoItPID&" - "&$line&@TAB&"|"&$split[$x]) Next EndFunc
Func _xLoad_End($n) $_GLOB_XLOAD_VARIABLES[$n][0]=0 GUIDelete($_GLOB_XLOAD_VARIABLES[$n][2]) EndFunc Edited by »Master - 25/6/2012, 18:01
| | |
| |
|