Leaderboard
Popular Content
Showing content with the highest reputation on 07/08/2024 in all areas
-
Sure, I will get my crystal ball to read your mind. Define what name are you talking about.1 point
-
It should be easy to adapt to your current code, just don't create new resources each time the slider is moving. Edit: here is an example of how you can create the checkerboard #include <GDIPlus.au3> _GDIPlus_Startup() Global $hDisplay = _GDIPlus_BitmapCreateFromScan0(178, 146) Global $hGraphics1 = _GDIPlus_ImageGetGraphicsContext($hDisplay) Global $hColor = _GDIPlus_BitmapCreateFromScan0(178, 146) Global $hGraphics2 = _GDIPlus_ImageGetGraphicsContext($hColor) Global $hTransparent = CreateTransparentLayer(178, 146) Global $hGUI, $cPic, $cSlider, $hSlider, $cDummy $hGUI = GUICreate('Example', 198, 250) $cPic = GUICtrlCreatePic('', 10, 10, 178, 146) $cSlider = GUICtrlCreateSlider(10, 165, 178, 40) $hSlider = GUICtrlGetHandle($cSlider) $cColor = GUICtrlCreateInput('D62828', 10, 215, 178, 25, 0x01) $cDummy = GUICtrlCreateDummy() GUICtrlSetLimit($cSlider, 255, 0) GUICtrlSetFont($cColor, 12) GUICtrlSetData($cSlider, 127) GUISetState(@SW_SHOW, $hGUI) GUIRegisterMsg(0x0114, 'WM_HSCROLL') UpdateColor() While True Switch GUIGetMsg() Case $cDummy If GUICtrlRead($cDummy) = $cSlider Then UpdateColor() Case -3 ExitLoop EndSwitch WEnd _GDIPlus_GraphicsDispose($hGraphics1) _GDIPlus_GraphicsDispose($hGraphics2) _GDIPlus_BitmapDispose($hTransparent) _GDIPlus_BitmapDispose($hColor) _GDIPlus_BitmapDispose($hDisplay) _GDIPlus_Shutdown() Func UpdateColor() Local $sColor = GUICtrlRead($cColor) Local $iAlpha = GUICtrlRead($cSlider) _GDIPlus_GraphicsDrawImageRect($hGraphics1, $hTransparent, 0, 0, 178, 146) _GDIPlus_GraphicsClear($hGraphics2, '0x' & Hex($iAlpha, 2) & $sColor) _GDIPlus_GraphicsDrawImageRect($hGraphics1, $hColor, 0, 0, 178, 146) ImageToCtrl($hDisplay, $cPic) GUICtrlSetTip($cSlider, $iAlpha) EndFunc Func ImageToCtrl($hBitmap, $cCtrl) Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($cCtrl, 0x0172, 0, $hHBITMAP)) _WinAPI_DeleteObject($hHBITMAP) EndFunc Func CreateTransparentLayer($iWidth, $iHeight, $iSquareSize = 10, $iColor1 = 0xFFFFFFFF, $iColor2 = 0xFF808080) Local $hLayer = _GDIPlus_BitmapCreateFromScan0($iSquareSize * 2, $iSquareSize * 2) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hLayer) Local $hBrush = _GDIPlus_BrushCreateSolid($iColor1) _GDIPlus_GraphicsClear($hContext, $iColor2) _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iSquareSize, $iSquareSize, $hBrush) _GDIPlus_GraphicsFillRect($hContext, $iSquareSize, $iSquareSize, $iSquareSize, $iSquareSize, $hBrush) Local $hTexture = _GDIPlus_TextureCreate($hLayer) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hLayer) $hLayer = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) $hContext = _GDIPlus_ImageGetGraphicsContext($hLayer) _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iWidth, $iHeight, $hTexture) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BrushDispose($hTexture) Return $hLayer EndFunc Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Switch $lParam Case $hSlider GUICtrlSendToDummy($cDummy, $cSlider) EndSwitch EndFunc Changing CV_CreateCheckerboardBitmap() with CreateTransparentLayer() and the lag is already gone (using your current code without any further adaptation). Of course there are other things that can be improved but right now your function is the killer with so many loops and drawing operations. Add CreateTransparentLayer() to your current code and change this line Local $g_hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap(CV_CreateCheckerboardBitmap($CV_RECTWIDTH, $CV_RECTHEIGHT, 5)) with Local $g_hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap(CreateTransparentLayer($CV_RECTWIDTH, $CV_RECTHEIGHT, 5))1 point
-
Well I can be like a dog with a bone sometimes. I worry at it until I succeed. I finally got aria2 to work, and yes it was Win 7 32 bit related. Another search on my socket error, eventually brought me to the following posted issue. https://github.com/aria2/aria2/issues/1801 So going by that I grabbed a static version of aria2, and tried that. That failed with a certificate error. So as I had also read how to provide the certificate on the command-line, I did that ... and whamo it worked. $params = $aria2 & ' -c -d "' & $downfold & '" -o "' & $file & '" -x ' & $threads & ' --ca-certificate="' & $cert & '" "' & $URL & '"' $pid = RunWait($params, "", @SW_SHOW) I'll provide the full script, once I have tidied a few things up, but could not contain my excitement right now, so had to share. Anyway, once again a BIG THANKS to my buddy @TheDcoder for his original suggestion and command-line and helpful comments along the way at various stages. We got there in the end ... what a journey.1 point
-
@TheSaint You forgot to mention your bud who gave you the idea of using curl with byte ranges 😢 In any case, the vast majority of people won't need to use curl to do this sort of crippled multi-threaded downloading, there's a much better program for that called aria2 and it's a dedicated CLI downloader program and supports multi-threaded downloading natively... so it doesn't have to combine the separate parts later on and cause double the wear and tear as it would with curl1 point
-
Here is a small UDF to create simple toggle buttons. I made this for one of my projects but I decided to make it available for those who might find it useful for their projects. It has no other dependencies except GDI+. Basically call _GDIPlus_Startup() before using any other function from this UDF and _GDIPlus_Shutdown() after you properly deleted all controls created with this UDF. Colors and sizes are customizable and there is a picture control that is associated with each toggle button so you can use other AutoIt functions with these buttons, like GUICtrlSetCursor(), GUICtrlSetTip(), etc. Here is a simple example: #include <ToggleButton.au3> _GDIPlus_Startup() $mAdminOn = GUICtrlToggle_CreateTheme(0xFF2C6E49, 0x30B5C99A, 0xFFB5C99A, 5, 2) $mAdminOff = GUICtrlToggle_CreateTheme(0xFF800F2F, 0x30F45B69, 0xFFF45B69, 5, 2) $hMain = GUICreate('Toggle Button UDF', 300, 200) GUICtrlCreateLabel('Admin mode', 10, 10, 80, 25, 0x200) ; SS_CENTERIMAGE GUICtrlSetFont(-1, 10, 500, 0, 'Segoe UI') $mHToggle = GUICtrlCreateToggle($hMain, 90, 10, 50, 25) GUICtrlSetTip(GUICtrlToggle_CtrlID($mHToggle), 'Click me') GUICtrlToggle_SetTheme($mHToggle, $mAdminOff) $mVToggle = GUICtrlCreateToggle($hMain, 200, 20, 40, 170, $TOGGLE_VERTICAL) GUICtrlSetTip(GUICtrlToggle_CtrlID($mVToggle), 'Click me multiple times') GUISetState() While True Switch GUIGetMsg() Case $mHToggle['ID'] ToggleState($mHToggle) If GUICtrlToggle_State($mHToggle) Then GUICtrlToggle_SetTheme($mHToggle, $mAdminOn) Else GUICtrlToggle_SetTheme($mHToggle, $mAdminOff) EndIf Case $mVToggle['ID'] ToggleState($mVToggle) $iSwitchSize = GUICtrlToggle_SwitchSize($mVToggle) $iSwitchSize += 1 If $iSwitchSize > 10 Then $iSwitchSize = 3 GUICtrlToggle_SwitchSize($mVToggle, $iSwitchSize) GUICtrlToggle_SwitchColor($mVToggle, 0xFF000000 + Random(0, 0xFFFFFF, 1)) Case -3 ; GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUICtrlDeleteToggle($mVToggle) GUICtrlDeleteToggle($mHToggle) _GDIPlus_Shutdown() Enjoy! Edit: added a little bit of code to detect the background color of the parent window, if it's not provided. ToggleButton.au31 point
-
[UDF] Google oAuth 2.0 with AutoIt.
Parsix reacted to argumentum for a topic
yes and no. The spaces is the problem. patch this: Func _JsonValue($sString, $sStart, $sEnd, $iMode = 0, $bCase = False) $sString = StringStripWS($sString,8) $sStart = StringStripWS($sStart,8) $sEnd = StringStripWS($sEnd,8) and that should take care of it.1 point -
I have found it at Russian. $oHTTP = ObjCreate('WinHttp.WinHttpRequest.5.1') $oHTTP.SetProxy(2, "прокси:порт") $oHTTP.Open('GET', 'https://www.test.com/', False) $oHTTP.SetCredentials("Логин", "Пароль", 0) The script is connected through a proxy, therefore has asked as to connect to mail my script through a proxy. It can be made?1 point
-
Here this function it is necessary to send the message on mail, through a proxy. Help me please. Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $s_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 1) $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr($s_Body, "<") And StringInStr($s_Body, ">") Then $objEmail.HTMLBody = $s_Body Else $objEmail.Textbody = $s_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) If FileExists($S_Files2Attach[$x]) Then $objEmail.AddAttachment($S_Files2Attach[$x]) Else $i_Error_desciption = $i_Error_desciption & @LF & 'File not found to attach: ' & $S_Files2Attach[$x] SetError(1) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort If $s_Username <> "" Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf $objEmail.Configuration.Fields.Update $objEmail.Send If @error Then SetError(2) EndIf EndFunc ;==>_INetSmtpMailCom1 point
-
Gmail API send email ;======================================================================================================================= ; Date: 2018-02-12, 17:52 ; ; Description: Send email using API to single or group of receipients. ; ; Function(s): gmailUsersMessagesSend() -> example usage ; ; Param(s): $sClientId Your client_id from *json file ; $sClientSecret Your client_secret from *json file ; $sRefreshToken Refresh token received from oAuth2GetAccessToken()[2] ; $sYourGmailAdress You gmail email adress ; $aRecipient Receipients: can be single without array or sepatared by comma "email1,email2" ; $sSubject Message Subject. ; $sBody Message body in text ; $sBodyHtml Message body in Html ; $sAttachment Attachment: string or array | Put path to file ex. [@ScriptDir & "\test.png"] ;======================================================================================================================= #Include <Gmail API.au3> Local $sClientId = "167204758184-vpeues0uk6b0g4jrnv0ipq5fapoig2v8.apps.googleusercontent.com" Local $sClientSecret = "cWalvFr3WxiE6cjUkdmKEPo8" Local $sRefreshToken = "34wSsq5sdfcoH-Rl-dfldfLffqxq2fhdPL1K-sf" Local $sYourGmailAdress = "youremail@gmail.com" Local $aRecipient = ["friend1@gmail.com", "friend2@yahoo.com"] Local $sSubject = "Testing Gmail API with Autoit" Local $sBody = "Hello there. Just testing..." & @CRLF Local $sBodyHtml = '<meta charset="utf-8"><h2>AutoIt v3<br></h2>' Local $sAttachment = Default Local $aToken = oAuth2RefreshAccessToken($sRefreshToken, $sClientId, $sClientSecret) If Not IsArray($aToken) Then except("<none>", "Failed to get access token. Exiting..", 1) Exit EndIf $aToken = $aToken[0] Local $aRet = gmailUsersMessagesSend($aRecipient, $sSubject, $sBody & $sBodyHtml, $sYourGmailAdress, $aToken, "Bearer", Default, $sAttachment) If Not IsArray($aRet) Then except("<none>", "Failed to send an email.", 2) EndIf ConsoleWrite("Message Sent Sucessfully!" & @CRLF) ConsoleWrite("MessageId: " & $aRet[0] & @CRLF) ConsoleWrite("ThreadId: " & $aRet[0] & @CRLF) Local $aLabelsIds = $aRet[2] ConsoleWrite("Sent message labels_ids: " & @CRLF) For $sLabel = 0 To UBound($aLabelsIds) - 1 ConsoleWrite("Label: " & $aLabelsIds[$sLabel] & @CRLF) Next1 point
-
function that returns a literal description of the duration (or date difference) between given dates. UDF and example: ; UDF #include <Date.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DateDuration ; Description ...: Returns a literal description of the duration (or date difference) between given dates. ; Syntax ........: _DateDuration($sDateOld, $sDateNew[, $iApproxLevel = 6]) ; Parameters ....: $sDateOld - The older date. ; $sDateNew - The newer date. ; $iApproxLevel - [optional] amount of elements to return. Default is 6 (all elements). ; Return values .: Success - Returns a string representing the difference between the given dates. ; Failure - Returns an empty string and sets @error to 1 if dates are identical or reversed. ; Author ........: orbs ; Modified ......: ; Remarks .......: Dates should be formatted by the AutoIt calculable date format: "YYYY/MM/DD hh:nn:ss" or "YYYY/MM/DD". ; The returned string is in English, and formatted literally. Examples: ; "2 years, 3 months, 14 days, 20 hours, 41 minutes and 16 seconds" (all elements present) ; "2 years, 24 days, 15 hours, 37 minutes and 33 seconds" (no months difference) ; "9 days, 5 hours, 42 minutes and 37 seconds" (no years or months differences) ; "4 months and 26 days" (there may be hours, minutes or seconds differernces, but parameter $iApproxLevel=2) ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _DateDuration($sDateOld, $sDateNew, $iApproxLevel = 6) Local $sResult = '' Local $aResult[0][2] Local $iResult = 0 Local $iDiffCurr = 0 Local $aElement[6][2] = [['Y', 'year'], ['M', 'month'], ['D', 'day'], ['h', 'hour'], ['n', 'minute'], ['s', 'second']] Local $iElement = 0 For $iElement = 0 To 5 $iDiffCurr = _DateDiff($aElement[$iElement][0], $sDateOld, $sDateNew) If $iDiffCurr <= 0 Then ContinueLoop Else ReDim $aResult[UBound($aResult) + 1][2] $aResult[$iResult][0] = $iDiffCurr $aResult[$iResult][1] = $aElement[$iElement][1] If $iDiffCurr > 1 Then $aResult[$iResult][1] &= 's' EndIf $iResult += 1 $sDateOld = _DateAdd($aElement[$iElement][0], $iDiffCurr, $sDateOld) Next Local $iReturnElementCount = ($iApproxLevel < UBound($aResult) ? $iApproxLevel : UBound($aResult)) If $iReturnElementCount = 0 Then Return SetError(1, '', '') ; identical dates or $sDateOld is newer than sDateNew If $iReturnElementCount = 1 Then Return $aResult[0][0] & ' ' & $aResult[0][1] ; only one element to return, no need for an elaborate string composition For $iResult = 0 To $iReturnElementCount - 2 $sResult &= ($aResult[$iResult][0] & ' ' & $aResult[$iResult][1] & ', ') Next $sResult = StringTrimRight($sResult, 2) ; remove last comma and whitespace $sResult &= (' and ' & $aResult[$iResult][0] & ' ' & $aResult[$iResult][1]) Return $sResult EndFunc ;==>_DateDuration ; Example Global $sDateOld = _NowCalc() Global $sDateNew = _DateAdd('s', Random(0, 100000000, 1), $sDateOld) Global $iApproxLevel = 3 ; change this in range 1 to 6 Global $sDateDiff = _DateDuration($sDateOld, $sDateNew, $iApproxLevel) ConsoleWrite('old date = ' & $sDateOld & @CRLF) ConsoleWrite('new date = ' & $sDateNew & @CRLF) ConsoleWrite('duration = ' & $sDateDiff & @CRLF) example output: old date = 2016/12/21 23:21:45 new date = 2017/06/09 23:22:00 duration = 5 months, 19 days and 15 seconds the text of last line ("5 months, 19 days and 15 seconds") is the return value of the function. enjoy!1 point
-
Version 1.0
1,083 downloads
This .au3 file will take the trouble out of trying to gain your dropbox oauth_access_token and oauth_access_token_secret by doing it for you. when first run the program it will create an empty folder on your desktop. As you progress through the application it will create text files as needed. Be sure to follow each of the message box's instructions as it is vital that each step be completed before moving onto the next. Enjoy1 point