Leaderboard
Popular Content
Showing content with the highest reputation on 06/05/2014 in all areas
-
vPaint - GDI+ image editor
BBs19 reacted to scintilla4evr for a topic
Hello everyone! As always, I'm proud to present you vPaint. It's an image editor. It uses GDI+ as its drawing library. I want to thank to all members of this forum. Without you, this app wouldn't be ever written. Thank you for everything. Download: vPaint 4 image editor1 point -
Your public IP (STUN protocol)
coffeeturtle reacted to trancexx for a topic
Usually you get IP info by connecting to some site that echoes your IP address. The bad thing about that method is almost proverbial need of site administrators to make changes to sites or their policies requiring from you to frequently update your code. Another issue could be caching thingy of the Inet approach. I did some reading about alternative ways to get public IP, and initially tried with SMTP. This Works great but it's kind of slow and on top of that some ISPs tend to block users on port 25 to prevent spam. Then further reading lead me to STUN protocol documentation. STUN servers are made to resolve and echo users' IP addresses, and are often used by VoIP services. The protocol is extremly simple and everything happens very quickly. Client connects (it's UDP so you Know what Imean), sends request, server replies, client parses the response and IP is there. RFC5389 describes STUN in details, so knock yourself out, if you are that crazy. I have found some implementations written in c++ and c sharp, but OMG, some people are just to stubborn and love to write incomprehensible idiotic hundreds of thousands kilobytes of code for something as simple as STUN. That went nowhere for me and gave me only the pain, so I just fall back to RFC and wrote my own client based on documentation. Function is called STUN_GetMyIP() and you can find example of usage in this little script. It's UDP this and UDP that: STUN.au3 If something wouldn't work, do say.1 point -
This is a really crude way of reading a simple (I mean simple) INI file and not having to read and write all the time using the INI functions. I know something like this already exists by AZJIO, but I wanted to target the newbie market. It uses no global variables (the enums are only there so I don't have to worry about what 0,1,2 actually means) and only 2 static variables, filepath and dictionary. Enjoy! #include <FileConstants.au3> #include <StringConstants.au3> Global Const $VARGETTYPE_BINARY = 'Binary', _ $VARGETTYPE_BOOL = 'Bool', _ $VARGETTYPE_DOUBLE = 'Double', _ $VARGETTYPE_INT32 = 'Int32', $VARGETTYPE_INT64 = 'Int64', _ $VARGETTYPE_PTR = 'Ptr', _ $VARGETTYPE_STRING = 'String' Global Const $SETTINGS_DATATYPE_BINARY = '(binary)', _ $SETTINGS_DATATYPE_BOOL = '(bool)', _ $SETTINGS_DATATYPE_DOUBLE = '(double)', _ $SETTINGS_DATATYPE_INT = '(int)', _ $SETTINGS_DATATYPE_PTR = '(ptr)', _ $SETTINGS_DATATYPE_STRING = '(string)' Global Const $SETTINGS_GUID = 'D6FFD9DF-F1B7-4C07-89C3-F8B597EEC1CF' Global Enum $SETTINGS_ASSOC, $SETTINGS_DUMP, $SETTINGS_FILEPATH, $SETTINGS_ID, $SETTINGS_MAX, $SETTINGS_GET, $SETTINGS_SET, $SETTINGS_SHUTDOWN, $SETTINGS_STARTUP Global Enum $SETTINGS_KEY, $SETTINGS_DATATYPE, $SETTINGS_VALUE Example() ; Useful if you only have a single settings file for the application. Func Example() Local $hSettings = _Settings(@ScriptDir & '\Settings.ini') ; Start the settings by passing the filepath that returns a settings object. ConsoleWrite(_Settings_Get($hSettings, 'Language', 'None') & @CRLF) ; Get the language key value of the settings object. ConsoleWrite(_Settings_Set($hSettings, 'Language', 'English') & @CRLF) ; Set the language key value to English using the settings object. ConsoleWrite(_Settings_Set($hSettings, 'Number', 100) & @CRLF) ; Set the int key value to 100 using the settings object. ConsoleWrite(_Settings_Get($hSettings, 'Language', 'None') & @CRLF) ; Get the language key value of the settings object. ConsoleWrite(_Settings_Get($hSettings, 'Int', 'None') & @CRLF) ; Get the int key value of the settings object. _Settings_Dump($hSettings) ; Dump the settings object to disk. ConsoleWrite(_Settings_FilePath($hSettings) & @CRLF) ; Get the filepath of the settings object. EndFunc ;==>Example ; Useful if you only Func Example_Static() If _Settings_Static(@ScriptDir & '\Settings_Static.ini') Then; Start the settings by passing the filepath. This returns either true or false. ConsoleWrite(_Settings_Static_Get('Language', 'None') & @CRLF) ; Get the language key value. ConsoleWrite(_Settings_Static_Set('Language', 'English') & @CRLF) ; Set the language key value to English. ConsoleWrite(_Settings_Static_Set('Number', 100) & @CRLF) ; Set the int key value to 100. ConsoleWrite(_Settings_Static_Get('Language', 'None') & @CRLF) ; Get the language key value. ConsoleWrite(_Settings_Static_Get('Int', 'None') & @CRLF) ; Get the int key value _Settings_Static_Dump() ; Dump the settings to disk. ConsoleWrite(_Settings_Static_FilePath() & @CRLF) ; Get the filepath of the settings. EndIf EndFunc ;==>Example_Static Func _Settings($sFilePath) Local $aSettings[$SETTINGS_MAX] If _AssociativeArray_Startup($aSettings[$SETTINGS_ASSOC], False) Then Local $aSRE = StringRegExp(FileRead($sFilePath), '(?:^|\R)([^=]+)=(\(\w+\))([^\r\n]*)', $STR_REGEXPARRAYGLOBALMATCH), _ $vValue = 0 For $i = 0 To UBound($aSRE) - 1 Step 3 $vValue = $aSRE[$i + $SETTINGS_VALUE] Switch $aSRE[$i + $SETTINGS_DATATYPE] Case $SETTINGS_DATATYPE_BINARY $vValue = Binary($vValue) Case $SETTINGS_DATATYPE_BOOL $vValue = (($vValue == 'True') ? True : False) Case $SETTINGS_DATATYPE_DOUBLE $vValue = Number($vValue) Case $SETTINGS_DATATYPE_INT $vValue = Int($vValue) Case $SETTINGS_DATATYPE_PTR $vValue = Ptr($vValue) Case Else $vValue = String($vValue) EndSwitch $aSettings[$SETTINGS_ASSOC].Item($aSRE[$i]) = $vValue Next $aSettings[$SETTINGS_FILEPATH] = $sFilePath $aSettings[$SETTINGS_ID] = $SETTINGS_GUID ; Set the GUID if the associative array was created successfully. Else $aSettings = Null ; Set to Null if an error occurred. EndIf Return $aSettings EndFunc ;==>_Settings Func _Settings_Dump(ByRef $aSettings) Local $bReturn = False If __Settings_IsAPI($aSettings) And $aSettings[$SETTINGS_DUMP] Then Local $aItems = $aSettings[$SETTINGS_ASSOC].Items(), $aKeys = $aSettings[$SETTINGS_ASSOC].Keys(), _ $iItemsUBound = UBound($aItems) If $iItemsUBound = UBound($aKeys) Then $bReturn = True Local $sData = '' For $i = 0 To UBound($aItems) - 1 Switch VarGetType($aItems[$i]) Case $VARGETTYPE_BINARY $aItems[$i] = $SETTINGS_DATATYPE_BINARY & $aItems[$i] Case $VARGETTYPE_BOOL $aItems[$i] = $SETTINGS_DATATYPE_BOOL & $aItems[$i] Case $VARGETTYPE_DOUBLE $aItems[$i] = $SETTINGS_DATATYPE_DOUBLE & $aItems[$i] Case $VARGETTYPE_INT32, $VARGETTYPE_INT64 $aItems[$i] = $SETTINGS_DATATYPE_INT & $aItems[$i] Case $VARGETTYPE_PTR $aItems[$i] = $SETTINGS_DATATYPE_PTR & $aItems[$i] Case Else $aItems[$i] = $SETTINGS_DATATYPE_STRING & $aItems[$i] EndSwitch $sData &= $aKeys[$i] & '=' & $aItems[$i] & @CRLF Next _SetFile($sData, $aSettings[$SETTINGS_FILEPATH], True) EndIf EndIf Return $bReturn EndFunc ;==>_Settings_Dump Func _Settings_FilePath(ByRef $aSettings) Return __Settings_IsAPI($aSettings) ? $aSettings[$SETTINGS_FILEPATH] : Null EndFunc ;==>_Settings_FilePath Func _Settings_Get(ByRef $aSettings, $sKey, $sDefault) If __Settings_IsAPI($aSettings) Then If $aSettings[$SETTINGS_ASSOC].Exists($sKey) Then $sDefault = $aSettings[$SETTINGS_ASSOC].Item($sKey) EndIf EndIf Return $sDefault EndFunc ;==>_Settings_Get Func _Settings_Set(ByRef $aSettings, $sKey, $sValue) Local $bReturn = False If __Settings_IsAPI($aSettings) Then $bReturn = True $aSettings[$SETTINGS_ASSOC].Item($sKey) = $sValue $aSettings[$SETTINGS_DUMP] = True EndIf Return $bReturn EndFunc ;==>_Settings_Set Func _Settings_Static($sFilePath) _Settings_Static_Dump() ; Dump the previous contents to disk. Return __Settings_Static($sFilePath, Null, $SETTINGS_STARTUP) EndFunc ;==>_Settings_Static Func _Settings_Static_Dump() Return __Settings_Static(Null, Null, $SETTINGS_DUMP) EndFunc ;==>_Settings_Static_Dump Func _Settings_Static_FilePath() Return __Settings_Static(Null, Null, $SETTINGS_FILEPATH) EndFunc ;==>_Settings_Static_FilePath Func _Settings_Static_Get($sKey, $sDefault) Return __Settings_Static($sKey, $sDefault, $SETTINGS_GET) EndFunc ;==>_Settings_Static_Get Func _Settings_Static_Set($sKey, $sValue) Return __Settings_Static($sKey, $sValue, $SETTINGS_SET) EndFunc ;==>_Settings_Static_Set Func _Settings_Static_Shutdown() _Settings_Static_Dump() ; Dump the previous contents to disk. Return __Settings_Static(Null, Null, $SETTINGS_SHUTDOWN) EndFunc ;==>_Settings_Static_Shutdown Func __Settings_Static($sKey, $sValue, $iAction) Local Static $hSettings = Null Local $vReturn = False Switch $iAction Case $SETTINGS_DUMP $vReturn = _Settings_Dump($hSettings) Case $SETTINGS_FILEPATH $vReturn = _Settings_FilePath($hSettings) Case $SETTINGS_GET ; Getter $vReturn = _Settings_Get($hSettings, $sKey, $sValue) Case $SETTINGS_SET ; Setter $vReturn = _Settings_Set($hSettings, $sKey, $sValue) Case $SETTINGS_SHUTDOWN $vReturn = True $hSettings = Null Case $SETTINGS_STARTUP $vReturn = True $hSettings = _Settings($sKey) EndSwitch Return $vReturn EndFunc ;==>__Settings_Static Func __Settings_IsAPI(ByRef $aSettings) Return UBound($aSettings) = $SETTINGS_MAX And $aSettings[$SETTINGS_ID] = $SETTINGS_GUID EndFunc ;==>__Settings_IsAPI Func _AssociativeArray_Startup(ByRef $aArray, $bIsCaseSensitive = False) ; Idea from MilesAhead. Local $bReturn = False $aArray = ObjCreate('Scripting.Dictionary') If IsObj($aArray) Then $aArray.CompareMode = ($bIsCaseSensitive ? 0 : 1) $bReturn = True EndIf Return $bReturn EndFunc ;==>_AssociativeArray_Startup Func _SetFile(ByRef $sString, $sFilePath, $bOverwrite = False, $iMode = Default) Local $hFileOpen = FileOpen($sFilePath, ($bOverwrite ? $FO_OVERWRITE : $FO_APPEND) + (IsDefault($iMode) ? 0 : $iMode)), _ $iError = 2 If $hFileOpen > -1 Then $iError = (FileWrite($hFileOpen, $sString) ? 0 : 1) FileClose($hFileOpen) EndIf Return SetError($iError, 0, $hFileOpen > -1) EndFunc ;==>_SetFile Func IsDefault($vDefault) Return $vDefault = Default EndFunc ;==>IsDefault1 point
-
I prefer it as it is now, Au3Check shouting at me when I make a stupid mistakes. You don't know how often though?!1 point
-
Ascend4nt, You are beginning to make a habit of "interpreting" my feelings - kindly stick to your interpreting your own from now on please. M231 point
-
Yes, I was on the right track!1 point
-
czardas: Hey, as long as it works, and doesn't take advantage of undocumented quirks of a language, you can do whatever you like! But make sure you and whoever else needs to read it will be able to understand it. Comment and document the behavior and logic where necessary. As guinness has mentioned, the implementation is up to you, but providing consistent/intelligent behavior and interface will be key to having it accepted by others.1 point
-
I feel generous today... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #include <GuiMenu.au3> #include <IE.au3> Global const $twitchURL = "http://www.twitch.tv/" Global $twitch_ID = "snejkipl"; Global $isVisible = 1; Global $fullUrl = $twitchURL & $twitch_ID Global $LastMessage = "" Global $width = 800, $height = 600 Global $Form1 = GUICreate("Twitch Chat details for: " & $twitch_ID, $width, $height) Global $hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 0, 0, $width, $height, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) GUISetState(@SW_SHOW) AppedSystemMessage("Please wait while I start IE..." & @CRLF) Global $oIE = _IECreate("about:blank", 0, $isVisible); GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlRichEdit_SetEventMask($hRichEdit, $ENM_LINK) _GUICtrlRichEdit_AutoDetectURL($hRichEdit, True) AppedSystemMessage("Please wait while I load up: " & $fullUrl & @CRLF) _IENavigate($oIE, $fullUrl); AppedSystemMessage("Please wait while the chat loads up..." & @CRLF) While 1 Sleep(100) _CheckForMessages() WEnd Func _CheckForMessages() If NOT IsObj($oIE) Then Return $chatObject = _IEGetObjById($oIE, "chat") If NOT IsObj($chatObject) Then Return $divsInChat = _IETagNameGetCollection($chatObject, "div") if IsObj($divsInChat) Then $addMessages = False for $oneDivInChat in $divsInChat if StringInStr($oneDivInChat.classname, "ember-view chat-line") Then $allSpans = _IETagNameGetCollection($oneDivInChat, "span") if IsObj($allSpans) Then $curMessage = ""; $stringColor = "0x00000000"; for $oneSpan in $allSpans Switch $oneSpan.classname case "timestamp" $curMessage &= "<" & $oneSpan.innertext & "> " case "from" if ($oneSpan.innertext = "jtv") Then $stringColor = "0x00C3C3C3" Else $curMessage &= $oneSpan.innertext & ": " $pulledColor = StringReplace(StringReplace($oneSpan.style.getAttribute('color'), "rgb(", ""), ")", ""); $splitCol = StringSplit($pulledColor, ',') if ($splitCol[0] >= 3) Then $stringColor = "0x00" & Hex(Number(StringStripWS($splitCol[3], 3)), 2) & Hex(Number(StringStripWS($splitCol[2], 3)), 2) & Hex(Number(StringStripWS($splitCol[1], 3)), 2) EndIf case "message" if (StringLen(StringStripWS($oneSpan.innertext, 3)) > 0) AND (String($oneSpan.innertext) <> "0") Then $curMessage &= $oneSpan.innertext $allSpans2 = _IETagNameGetCollection($oneSpan, "span") if IsObj($allSpans2) Then for $oneSpan2 in $allSpans2 if StringInStr($oneSpan2.classname, "emoticon") Then $curMessage &= "[" & StringReplace($oneSpan2.classname, "emoticon ", "") & "]" Next EndIf EndSwitch Next if (StringLen($LastMessage) = 0 OR $addMessages) Then AppendUserMessage($curMessage & @CRLF, $stringColor) $LastMessage = $curMessage Else if $LastMessage = $curMessage then $addMessages = True EndIf EndIf EndIf Next EndIf EndFunc func AppendUserMessage($sText, $iColor) _GUICtrlRichEdit_AppendTextColor($hRichEdit, $sText, $iColor) EndFunc Func AppedSystemMessage($sText) _GUICtrlRichEdit_AppendTextColor($hRichEdit, $sText, 0x00C3C3C3) EndFunc Func _GUICtrlRichEdit_AppendTextColor($hWnd, $sText, $iColor) Local $iLength = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) Local $iCp = _GUICtrlRichEdit_GetCharPosOfNextWord($hWnd, $iLength) _GUICtrlRichEdit_AppendText($hWnd, $sText) _GUICtrlRichEdit_SetSel($hWnd, $iCp-1, $iLength + StringLen($sText)) _GUICtrlRichEdit_SetCharColor($hWnd, $iColor) _GuiCtrlRichEdit_Deselect($hWnd) EndFunc Func WM_SYSCOMMAND($hWnd, $iMsg, $WParam, $LParam) Switch $hWnd Case $Form1 Switch $WParam Case $SC_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) _IEQuit($oIE) Exit EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam) #forceref $hWnd, $iMsg, $iWparam Local $hWndFrom, $iCode, $tNMHDR, $tEnLink, $cpMin, $cpMax, $tMsgFilter $tNMHDR = DllStructCreate($tagNMHDR, $iLparam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hRichEdit Select Case $iCode = $EN_LINK $tMsgFilter = DllStructCreate($tagMSGFILTER, $iLparam) If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then $tEnLink = DllStructCreate($tagENLINK, $iLparam) $cpMin = DllStructGetData($tEnLink, "cpMin") $cpMax = DllStructGetData($tEnLink, "cpMax") ShellExecute(_GUICtrlRichEdit_GetTextInRange($hRichEdit, $cpMin, $cpMax)); EndIf EndSelect EndSwitch Return $GUI_RUNDEFMSG EndFunc EDIT : I just realized, that twitch chat is powered by IRC. And there are plenty of IRC scripts in here. You just need to get the correct parameters (server, port, channel...). You can also build a chat bot with mIRC:1 point
-
Or you could use an array...it depends on your comfortability level. #include <MsgBoxConstants.au3> Local $aOutcomes[10] = [1, 2, 100, 24, 8, 90, 76, 65, 7, 99], _ $iOutcome = 9 If $iOutcome >= 0 And $iOutcome < UBound($aOutcomes) Then MsgBox($MB_SYSTEMMODAL, '', $aOutcomes[$iOutcome]) EndIf1 point
-
No, your $ActualWindowsSens is always 0, therefore you do not execute any of the Case. I think you want to use Switch on $WindowsSensInput? The Switch Case then evaluates the value of that variable and executes the code below, all your following IF testing is then not needed..1 point
-
Not quite... You don't need the IFs - the CASE does the IF work for you. Switch $WindowSensInput Case 1 ;Checks if $WindowSensInput = 1 $ActualWindowSens = 0.031 Case 2 ;Checks if $WindowSensInput = 2 $ActualWindowSens = 0.222 Case 3 ;Checks if $WindowSensInput = 3 $ActualWindowSens = 0.333 ; Case n ;Checks if $WindowSensInput = n ; $ActualWindowSens = whatever Case Else ;Checks if $WindowSensInput = any other value not stated Msgbox(16,"Error","Your value is outside the range allowed") EndSwitch1 point
-
Switch $var1 Case 1 $var2 = 0.03 Case 2 $var2 = 0.7 Case 3 $var2 = 0.7 EndSwitch1 point
-
Well OK ... with my Stack UDF I kind of bent the rules because instead of adding to the top, I add to the bottom (it's internally easier as I don't have to shift down one every time). So I then provided a ToArray() method which "visually" outputs the Stack as you would expect (last in on top). So I guess use my Stack/Queue UDF as an example, internally do what you feel is easier for you, but output to the user/developer with the proper convention. It's a little late so I hope this made some sense to you. I am surprised this isn't in Dev Chat as Chat is well...I think I have made my opinion known about this section already.1 point
-
If you know the address of the xml then you can get its text without using _IE* (faster) Here is an example $sXML = BinaryToString(InetRead("http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml")) Msgbox(0,"content", $sXML) $clouds = StringRegExpReplace($sXML, '(?is).*<clouds.*?name="([^"]+).*', '$1') Msgbox(0,"clouds", $clouds)1 point
-
InetRead problem
coffeeturtle reacted to sahsanu for a topic
Change function _IEBodyReadHTML by _IEDocReadHTML and you should get the expected result: #include <String.au3> #include <IE.au3> Local $oIE = _IECreate("http://www.cesarsway.com/channel/dog-training", 0, 0) Local $HTMLCODE = _IEDocReadHTML($oIE) ClipPut($HTMLCODE) If Not @error Then $TITLE = _StringBetween($HTMLCODE, "<title>", "</title>") If IsArray($TITLE) Then $TITLE1 = $TITLE[0] Else $TITLE1 = "missing title" EndIf MsgBox(0, "", $TITLE1) EndIf1 point -
Function priority, AdLib, reentrance, and mutexes
toasterking reacted to wolflake for a topic
I'd like to say thank you for "documenting" this because I have an adlib calling a function that might not finish before the adlib triggered to call it again. Now I know that it will be ok because it won't be interupted by the next adlib call.1 point -
normalnie szczęka opada, zaskakujące, dzięki normally jaw-dropping, surprising, thanks mLipok edit: AutoIt just surprised me again, still amazes me1 point
-
Found this in my collection: ;another fast hack by UEZ 2011 #include <GDIPlus.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() Global Const $SC_DRAGMOVE = 0xF012 Global Const $W = -1 Global Const $H = 200 Global Const $hGUI = GUICreate("GDI+ Test by UEZ 2011", $W, $H, -1, -1, $WS_POPUP, $WS_EX_LAYERED) Global Const $hGUI_Child = GUICreate("", $W, $H, 0, 0, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED + $WS_EX_TOOLWINDOW, $hGUI) GUISetBkColor(0xABCDEF, $hGUI_Child) GUISwitch($hGUI_Child) Global Const $idButton = GUICtrlCreateButton("Exit", 40, 20, 100, 40) GUICtrlSetOnEvent(-1, "_Exit") Global Const $idLabel = GUICtrlCreateLabel("TEST LABEL HERE!!!", 110, 140, 180, 20) GUICtrlSetFont(-1, 14, 400, 0, "Times New Roman", 3) GUICtrlSetColor(-1, 0xF0F0FF) GUICtrlSetBkColor(-1, -2) _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0xABCDEF, 0xFF) GUISetState(@SW_SHOW, $hGUI_Child) GUISetState(@SW_SHOW, $hGUI) _SetGuiRoundCorners($hGUI, 40, False, True, True, False) Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hBitmap = _CreateCustomBk($hGUI, 0x550555) Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _CreateCustomGroupPic($hContext, 100, 100, 200, 75, 0xff0000) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $W, $H) SetTransparentBitmap($hGUI, $hBitmap, 0xD0) GUISetOnEvent(-3, "_Exit") GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") While Sleep(2 ^ 16) WEnd Func _Exit() _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI_Child) GUIDelete($hGUI) Exit EndFunc ;==>_Exit Func _CreateCustomBk($hGUI, $hexColor, $alpha = "0xAA") Local $iWidth = _WinAPI_GetClientWidth($hGUI) Local $iHeight = _WinAPI_GetClientHeight($hGUI) Local $oBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($oBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Local $hBrush = _GDIPlus_BrushCreateSolid($alpha & Hex($hexColor, 6)) _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2, $iWidth - 6, $iHeight - 6, $hBrush) _GDIPlus_BrushSetSolidColor($hBrush, 0x22FFFFFF) Local $iTimes = Round($iWidth / 50) Local $aPoints[5][2] $aPoints[0][0] = 4 $aPoints[1][1] = $iHeight $aPoints[2][1] = $iHeight $aPoints[4][1] = 0 $aPoints[3][1] = 0 For $i = 0 To $iTimes Local $Random1 = Random(0, $iWidth, 1) Local $Random2 = Random(30, 50, 1) $aPoints[1][0] = $Random1 $aPoints[2][0] = $Random1 + $Random2 $aPoints[4][0] = $aPoints[1][0] + 50 $aPoints[3][0] = $aPoints[2][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) $aPoints[1][0] -= $Random2 / 10 $aPoints[2][0] = $Random1 + $Random2 - ($Random2 / 10 * 2) $aPoints[3][0] = $aPoints[2][0] + 50 $aPoints[4][0] = $aPoints[1][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) Next _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) Return $oBitmap EndFunc ;==>_CreateCustomBk Func _CreateCustomGroupPic($hGraphics, $ix, $iy, $Width, $iHeight, $hexColor, $alpha = "0x55") _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Local $hBrush = _GDIPlus_BrushCreateSolid($alpha & Hex($hexColor, 6)) _GDIPlus_GraphicsFillRect($hGraphics, $ix, $iy, $Width, $iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2, $Width - 4, $iHeight - 4, $hBrush) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>_CreateCustomGroupPic Func _SetGuiRoundCorners($hGUI, $iEllipse, $iLeftUp = True, $iLeftDown = True, $iRightUp = True, $iRightDown = True) Local $hCornerRgn Local $aGuiSize = WinGetPos($hGUI) Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $aGuiSize[2], $aGuiSize[3], $iEllipse, $iEllipse) If $iLeftUp = False Then $hCornerRgn = _WinAPI_CreateRectRgn(0, 0, $aGuiSize[2] / 2, $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iLeftDown = False Then $hCornerRgn = _WinAPI_CreateRectRgn(0, $aGuiSize[3] / 2, $aGuiSize[2] / 2, $aGuiSize[3]) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightUp = False Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, 0, $aGuiSize[2], $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightDown = False Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, $aGuiSize[3] / 2, $aGuiSize[2] - 1, $aGuiSize[3] - 1) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf _WinAPI_SetWindowRgn($hGUI, $hRgn) EndFunc ;==>_SetGuiRoundCorners Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetTransparentBitmap Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Screenshot: Br, UEZ1 point
-
Please use code tags when you're posting something that large, add [code ] and [/code ] before and after the code, remove the spaces in the tags to make them work.1 point