17 posts in this topic
So I thought it would be cool to use my Gravatar account to display my gravatar in a local GUI.
I use this code:
#cs ---------------------------------------------------------------------------- AutoIt Version: 188.8.131.52 Author: Skysnake Script Function: Example to download avatar from Gravatar and display locally #ce ---------------------------------------------------------------------------- ; Script Start ; includes #include <Crypt.au3> #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ; declare Global vars Global $md5GraMail = '' ; will store email for Grvatar request request GravatarLogin() GetAvatar() Func GravatarLogin() ; get the email required for downloading the Gravatar Local $sGraMail = InputBox("Get Gravatar", "What is your email registered with Gravatar?", "firstname.lastname@example.org", "", -1, -1, 0, 0) ; from http://en.gravatar.com/site/implement/hash/ ; make the hash ; Local $dHash = _Crypt_HashData(GUICtrlRead($g_idInputEdit), $g_iAlgorithm) ; Create a hash of the text entered $md5GraMail = _Crypt_HashData(StringLower(StringStripWS($sGraMail, 8)), $CALG_MD5) ; lose the left two '0x' chars and convert to lower case $md5GraMail = StringLower(StringTrimLeft($md5GraMail, 2)) ; Display the result. MsgBox($MB_SYSTEMMODAL, "", $sGraMail & @CRLF & "md5 " & $md5GraMail, 15) EndFunc ;==>GravatarLogin ; example from Help file: /html/functions/InetGet.htm ; Download a file in the background. ; Wait for the download to complete. Func GetAvatar() ; Save the downloaded file to the temporary folder. Local $sFilePath = _WinAPI_GetTempFileName(@TempDir) ; from http://en.gravatar.com/site/implement/images/ ; <img src="https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50" /> ; Download the file in the background with the selected option of 'force a reload from the remote site.' ; the next THREE options are alternatives ; Gravatar sample from here http://en.gravatar.com/site/implement/images/ ; 1 ;Local $hDownload = InetGet("https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; the normal code, should show user avatar ; 2 Local $hDownload = InetGet("https://www.gravatar.com/avatar/" & $md5GraMail & "?d=retro", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; my email hardcoded, downloads, but does not show avatar ; 3 ;Local $hDownload = InetGet("https://www.gravatar.com/avatar/cac637b47c9fecc8aa1dcdf71e7a4cc8", $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) ; Wait for the download to complete by monitoring when the 2nd index value of InetGetInfo returns True. Do Sleep(250) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) ; Retrieve the number of total bytes received and the filesize. Local $iBytesSize = InetGetInfo($hDownload, $INET_DOWNLOADREAD) Local $iFileSize = FileGetSize($sFilePath) ; Close the handle returned by InetGet. InetClose($hDownload) ; Display details about the total number of bytes read and the filesize. MsgBox($MB_SYSTEMMODAL, "", "The total download size: " & $iBytesSize & @CRLF & _ "The total filesize: " & $iFileSize, 1) Local $MyGravatar = @ScriptDir & "\Gravatar.jpg" FileCopy($sFilePath, $MyGravatar) MsgBox(0, "Now showing!", $MyGravatar, 5) ; make gui and show file GUICreate("My Gravatar in a GUI " & $MyGravatar, 350, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) ; will create a dialog box that when displayed is centered Local $idPic = GUICtrlCreatePic($MyGravatar, 50, 50, 80, 80) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;FileDelete($MyGravatar) ; Delete the file. FileDelete($sFilePath) EndFunc ;==>GetAvatar Now, here is the issue.
If I use the example from the Gravatar site, located here:
Then this code 205e460b479e2e5b48aec07710c08d50 downloads this pic (not me)
AND it displays correctly.
However, If I download my own Gravatar, I see the image in the @Script folder, BUT IT DOES NOT DISPLAY. The same with the retro image. To be clear, this image downloads, but is not displayed.
I guess it has something to do with the format of my gravatar. Or that the display funtion GUICtrlCreatePic() does not like my gravatar.
I would be grateful if someone would be willing to test this and may offer a suggestion or two...
I was looking around the forum if there were some customizable solutions about creating a PDF from "0" to something like a report...
What I'd like to do is something with a header ( 2 logos and a title ), with a table which contains data read from a file
At the moment, I was working with HTML, since I know it and it's very simple to do a table with some data inside...
But know, I'm a bit stuck about the exporting the HTML page to PDF... And, here too, if someone knows how to do it, please, I'm here listening
Please tell me, who knows how to apply and cancel styles in RTF?
The following code does not work:
#include <GuiRichEdit.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("RichEdit Style", 500, 500, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Test", 20,40,460,400) GUISetState(@SW_SHOW, $hGUI) Sleep(3000) GUICtrlSetStyle($hRichEdit, $ES_RIGHT) Sleep(3000) GUICtrlSetStyle($hRichEdit, -1) Sleep(3000) Thanks!
I created a UDF that I have been using to replace GUICtrlSetOnEvent, not using Opt("GUIOnEventMode").
AutoIt's GUICtrlSetOnEvent function only supports mouse clicks without parameters at this moment, this UDF works on the same premise but gives the user some more flexibility, in just 61 lines of code.
Here is an example of what A callback will look like
Func MyCallBackFunction(Const $wParam, ByRef $iCtrlId, ByRef $uData, ByRef $hWnd) Switch $wParam Case $WM_HOVERIN ConsoleWrite("Entering control; attached data = " & $uData & @CRLF) Case $WM_HOVEROUT ConsoleWrite("Leaving control" & @CRLF) Case $WM_LBUTTONDOWN ConsoleWrite("Left mousebutton DOWN" & @CRLF) Case $WM_LBUTTONUP ConsoleWrite("Left mousebutton UP" & @CRLF) Case $WM_MBUTTONDOWN ConsoleWrite("Middle mousebutton DOWN" & @CRLF) Case $WM_MBUTTONUP ConsoleWrite("Middle mousebutton UP" & @CRLF) Case $WM_RBUTTONDOWN ConsoleWrite("Right mousebutton DOWN" & @CRLF) Case $WM_RBUTTONUP ConsoleWrite("Right mousebutton UP" & @CRLF) EndSwitch EndFunc
More examples can be found in the zip file.
Good 2 know
GuiDelete($hWnd) used together with $WM_LBUTTONUP will cause the AutoIt script to crash $WM_HOVERIN and $WM_HOVEROUT ARE NOT real Windows Message codes and will only work with with this UDF Your callback functions MUST have 4 parameters assigned to it. That's about it.
Feel free to pitch some improvements.
A small tool from me opens certain text files and displays the content in some sort of "preview", by chance a user selected a file that is "large" ~ 10 MB. (of course my test files are small enough :-) )
But this takes very long (~ 4 secs on that pc), first I thought it is reading the file but I stripped it down to the edit control update.
I extracted the issue to a sample au3 attached and a sample large file. The log lines are from the dummy1.au3.
(11:19:40.352) - -->Line0017): openfile
(11:19:40.461) - -->Line0021): closefile
(11:19:40.461) - -->Line0022): update ctrlfile start
(11:19:45.581) - -->Line0024): update ctrlfile done
I see that reading the file is fast enough( 109ms) , but the edit control update takes long (5120 ms).
Question: Based on the dummy1, is there a chance to speed up? I'm open to accept also other advices, the purpose of the edit is just to display the file and allow scrolling.
I thought about reading only a certain amount of lines and if the user scrolls read the rest.....or so.
Or is it just like this by design. Or what is more likely, what is wrong on my code?
Of course my real app displays now in the mean time something like "Loading...." but that does not solve it.
And yes, I used FS. Found something similar, but the thread was drifting apart from the issue without solving it...