Leaderboard
Popular Content
Showing content with the highest reputation on 09/14/2013 in all areas
-
No it doesn't speak, I lied. That is impossible. It's about setting animated GIF (and every other type of images) to a GUI control. How is this done for animated GIF? Few simple steps: - created ImageList of GIF Bitmaps retrieved from gif file/resource - created Pic control - every now and then another image is displayed. This is determined by frame delay time - see gif specification somewhere. That's it. All that takes time and could potentially block our gui/script. That's why flying assembly is used. Animation is done in another thread different from one AutoIt's code is executed in. Nothing stops animation but you. Animation works both for x64 and x86. Also it works for all kind of images not only GIFs. That means you can use it to display PNGs, BMPs, JPGs, etc... All of them from resources too. Example: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GIFAnimation.au3" Opt("MustDeclareVars", 1) ; Start by choosing GIF to display Global $sFile = FileOpenDialog("Choose Image", "", "(*.gif;*.png;*.jpg;*.tiff;*.bmp;*.jpeg)", -1, "") If @error Then Exit ; Make GUI Global $hGui = GUICreate("GIF Animation", 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW) ; Add some buttons Global $hButton = GUICtrlCreateButton("&Pause animation", 50, 450, 100, 25) Global $hButton1 = GUICtrlCreateButton("&Delete Control", 200, 450, 100, 25) Global $hButton2 = GUICtrlCreateButton("&Open Image", 350, 450, 100, 25) ; Make GIF Control Global $hGIF = _GUICtrlCreateGIF($sFile, "", 10, 10) If @extended Then GUICtrlSetState($hButton, $GUI_DISABLE) GUICtrlSetTip($hGIF, "Image") ; Additional processing of some windows messages (for example) GUIRegisterMsg(133, "_Refresh") ; WM_NCPAINT GUIRegisterMsg(15, "_ValidateGIFs") ; WM_PAINT Global $iPlay = 1 ; Show it GUISetState() ; Loop till end While 1 Switch GUIGetMsg() Case -3 Exit Case $hButton If $iPlay Then If _GIF_PauseAnimation($hGIF) Then $iPlay = 0 GUICtrlSetData($hButton, "Resume animation") EndIf Else If _GIF_ResumeAnimation($hGIF) Then $iPlay = 1 GUICtrlSetData($hButton, "Pause animation") EndIf EndIf Case $hButton1 _GIF_DeleteGIF($hGIF) Case $hButton2 $sFile = FileOpenDialog("Choose gif", "", "(*.gif;*.png;*.jpg;*.tiff;*.bmp;*.jpeg)", -1, "", $hGui) If Not @error Then _GIF_DeleteGIF($hGIF); delete previous $hGIF = _GUICtrlCreateGIF($sFile, "", 10, 10) If @extended Then GUICtrlSetState($hButton, $GUI_DISABLE) Else GUICtrlSetState($hButton, $GUI_ENABLE) EndIf GUICtrlSetTip($hGIF, "Image") $iPlay = 1 GUICtrlSetData($hButton, "Pause animation") EndIf EndSwitch WEnd Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GIF_RefreshGIF($hGIF) EndFunc ;==>_Refresh Func _ValidateGIFs($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _GIF_ValidateGIF($hGIF) EndFunc ;==>_ValidateGIFs It should be 0% cpu. Download from here if you want to impress chicks: http://code.google.com/p/gif-animation/downloads/list There are 8 examples in there. GIF files are downloaded automatically if some example script needs it. Mostly from photobucket.com. Some examples work without classic download. Required data is get with InetRead(). That's mighty cool. So, download, open ZIP, grab folder inside and place it where you want. Run examples and that's it. Word or two about main function, _GUICtrlCreateGIF(). It can handle all sorts of input. Will display Images that are passed as binary, resource identifiers, strings, file names, ... everything. If it's valid image all works. For example, all this is valid: ; Pass GIF File path/name _GUICtrlCreateGIF("Some.gif", "", 10, 10) ; Binary data _GUICtrlCreateGIF($bGIF, "", 10, 10,) ; PE Resource (file GIF.dll, Type: GIF, Name: 4) _GUICtrlCreateGIF("GIF.dll", "GIF;4", 10, 10, 100, 120) ; PE Resource (file @AutoItExe, Type: RES, Name: BLAH, Language: 1033) _GUICtrlCreateGIF(@AutoItExe, "RES;BLAH;1033", 10, 10) ; PE Resource (file "explorer.exe", Type: 2, Name: 6801) _GUICtrlCreateGIF("explorer.exe", "2;6801", 10, 10) ;<- BITMAP ; PE Resource (file @AutoItExe, Type: RC_DATA, Name: PNG) _GUICtrlCreateGIF(@AutoItExe, "10;PNG", 10, 10) ; GIF string _GUICtrlCreateGIF(FileRead("Some.gif"), "", 10, 10) ____________________________________________1 point
-
Hi, This UDF originaly started in this thread, on the latest post you can find rasim's examples and my initial BlockInputEx udf example. But eventualy i improved the UDF and i thought that it would be better to place it here, in Examples forum. This UDF supports few features that built-in BlockInput() function does not. Here is a quick "features list" if you can call it like this : Block seperately mouse or keyboard input.Block specific keyboard/mouse keys/clicks. [+] Not only hex keys are supported, string keys (such as {ENTER}) is also valid.Block all keyboard/mouse keys *except* specific keys/events.Block keys by CLASS Name (see UDF documentation).Block inputs only for specific window.BlockInput does not re-enables input after pressing Ctrl+Alt+Del.Note: This UDF, same as built-in BlockInput function, can not block Ctrl+Alt+Del, however, it will not re-enable the input. Example #1 (hWindows usage): #include <BlockInputEx.au3> ;================== hWindows usage Example ================== HotKeySet("{ESC}", "_Quit") ;This will trigger an exit (on any window except the window of Notepad). Run(@WindowsDir & "\Notepad.exe", "", @SW_MAXIMIZE) WinWait("[REGEXPCLASS:Notepad.*]") $hNotepad_Wnd = WinGetHandle("[REGEXPCLASS:Notepad.*]") ControlSetText($hNotepad_Wnd, "", "", _ "Now try to input some keys in here..." & @CRLF & _ "Well, that's the idea, you can't, don't you?" & @CRLF & @CRLF & ":)") ;Here we block *All* keyboard keys for specific window (in this case the Notepad's window). _BlockInputEx(3, "", "", $hNotepad_Wnd) ;This is only for testing, so if anything go wrong, the script will exit after 10 seconds. AdlibRegister("_Quit", 10000) While 1 Sleep(100) WEnd Func _Quit() Exit EndFuncExample #2 (CLASSes usage): #include <BlockInputEx.au3> ;================== CLASSes usage Example ================== HotKeySet("{ESC}", "_Quit");This will trigger an exit ;Here we block Numeric keyboard keys, "Test" string (every char in this group), and UP / DOWN arrow keys. _BlockInputEx(3, "", "[:NUMBER:]|[Test]|{UP}|{DOWN}") ;This is only for testing, so if anything go wrong, the script will exit after 10 seconds. AdlibRegister("_Quit", 10000) While 1 Sleep(100) WEnd Func _Quit() Exit EndFuncDownload (In the archive there is 11 nice examples including the two above): BlockInputEx_UDF_1.8.zip BlockInputEx_UDF_1.6.zip _BlockInputEx_UDF_1.5.zip _BlockInputEx_UDF_1.4.zip _BlockInputEx_UDF_1.3.zip _BlockInputEx_UDF_1.2.zip _BlockInputEx_UDF_1.1.zip _BlockInputEx_UDF.zip Enjoy! ================================================================= ChangeLog:1 point
-
Notify - New version 17 Mar 22
pixelsearch reacted to Melba23 for a topic
[NEW VERSION] - 17 Mar 22 Added: A new function _Notify_Size which allows you to adjust the size of the notification from its default 160x40. Please read the function header to see the max/min sizes that you can set for the width and height - the function returns informative @error/@extended values if these are not respected. Regardless of the size set, each notification will still display only 2 lines of text with the size of font used set automatically by the UDF. New UDF in the zip below. Previous changes: Changelog.txt A while ago I was asked to help port an AHK UDF to AutoIt. This was not too difficult and I found it useful myself (as a replacement for ConsoleWrite when debugging compiled scripts among other things). I have been polishing it for a while and thought I might release it in case it proves useful to anyone else. The notifications produced by Notify are small 2-line boxes that pop out of the edge of the display one above the other (you can select which side and in which direction they appear) - you can have as many as you want although only as many as can fit on your display will appear, the others will appear as soon as there is room. You can select whether they will retract after a certain time and/or when clicked. Colours and font are user-definable, and you can add an icon or image (bmp, jpg, gif or png) if you wish. When a notification retracts, the others move to leave space for more (you can select a smoooth slide or an instant move) - run the examples to see them in action. If you find the default sizing of the notifications is not to your liking you can change it by amending these values in the UDF (lines #354-356): ; Set default auto-sizing Notify dimensions Local $iNotify_Width_max = 300 Local $iNotify_Width_min = 150 Local $iNotify_Height = 40 A zip containing the UDF, example scripts and my StringSize UDF (which is also required): Notify.zip As usual happy for comments and/or compliments. M231 point -
Hotkeyset problem ...
Alexxander reacted to DW1 for a topic
Sounds like _IsPressed() would work better for what you need #include <Misc.au3> ;~ HotKeySet('a', 'a') Global $i = 0 While 1 If _IsPressed(41) Then a() Sleep(10) WEnd Func a() $i += 1 ConsoleWrite('a' & $i & @CRLF) While _IsPressed(41) Sleep(10) WEnd EndFunc ;==>a1 point -
Ok then try this ;Coded by UEZ 2013 -> This program requires AutoIt version 3.3.9.21 or higher! #AutoIt3Wrapper_Autoit3Dir=c:\Program Files (x86)\AutoIt3\Beta #include <GDIPlus.au3> #include <Memory.au3> _GDIPlus_Startup() Global $sFile = StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI\msoobe.jpg") Global $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global $hBitmap = _GDIPlus_ImageResize($hImage, 10, 7) Global $bImage = _GDIPlus_StreamImage2BinaryString($hBitmap) ConsoleWrite("Error: " & @error & @LF) MsgBox(0, "Binary", $bImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func _GDIPlus_StreamImage2BinaryString($hBitmap, $sFormat = "JPG", $iQuality = 80, $bSave = False, $sFilename = "Converted.jpg") ;coded by UEZ 2013 build 2013-09-14 Local $sImgCLSID, $tGUID, $tParams Switch $sFormat Case "JPG" $sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat) $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Local $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $iQuality) ;quality 0-100 Local $pData = DllStructGetPtr($tData) $tParams = _GDIPlus_ParamInit(1) _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, $pData) Case "PNG", "BMP", "GIF", "TIF" $sImgCLSID = _GDIPlus_EncodersGetCLSID($sFormat) $tGUID = _WinAPI_GUIDFromString($sImgCLSID) Case Else Return SetError(1, 0, 0) EndSwitch Local $hStream = _WinAPI_CreateStreamOnHGlobal() ;http://msdn.microsoft.com/en-us/library/ms864401.aspx If @error Then Return SetError(2, 0, 0) _GDIPlus_ImageSaveToStream($hBitmap, $hStream, DllStructGetPtr($tGUID), DllStructGetPtr($tParams)) If @error Then Return SetError(3, 0, 0) _GDIPlus_BitmapDispose($hBitmap) Local $hMemory = _WinAPI_GetHGlobalFromStream($hStream) ;http://msdn.microsoft.com/en-us/library/aa911736.aspx If @error Then Return SetError(4, 0, 0) Local $iMemSize = _MemGlobalSize($hMemory) If Not $iMemSize Then Return SetError(5, 0, 0) Local $pMem = _MemGlobalLock($hMemory) $tData = DllStructCreate("byte[" & $iMemSize & "]", $pMem) Local $bData = DllStructGetData($tData, 1) _WinAPI_ReleaseStream($hStream) ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221473(v=vs.85).aspx _MemGlobalFree($hMemory) If $bSave Then Local $hFile = FileOpen($sFilename, 18) If @error Then Return SetError(6, 0, $bData) FileWrite($hFile, $bData) FileClose($hFile) EndIf Return $bData EndFunc ;==>_GDIPlus_StreamImage2BinaryString Requires AutoIt version 3.3.9.21 or higher! Br, UEZ1 point
-
I assume you are looking for something like this here: Br, UEZ1 point
-
Predefined Area for Pixelsearch
ChristianGeissenhoener reacted to BrewManNH for a topic
#include <Array.au3> Global $sl[5][5] = [[0,63,227,212,396], [0,218,227,366,393], [0,372,227,520,396], [0,63,409,212,578], [0,218,409,366,578]] _ArrayDisplay($sl) For $Loop = 1 to 5 PixelSearch($sl[$Loop][1], $sl[$Loop][2], $sl[$Loop][3], $sl[$Loop][4], $sl[$Loop][5]) Next Much more reasonable to use the arrays correctly.1 point -
. hi there $i and $j are loop counts, the matrices are called "arrays", and the rest is math. arrays index a variable, you have one with the name aray[0], the next is array[1] and so on. for every gui you create you have to define the font again GUISetFont(20, 400, "", $font). this does not work with system windows, like inputbox and msgbox. they are like windows does them. but instead you can create your own inputbox gui, that is the better way. you are completely right, $msg returns the control that is actuated in the gui. the gui traps that click and gives out the control id for you to use it. there are other more advanced ways to do it, but that is ten steps ahead. now you learn guis, arrays and functions. please don't feel bad, but this is the way to learn it, study examples and you understand, and as far as i can say, you seem to understand a lot more than other newbies E.1 point
-
How to disable any hotkeyset button ?
tbodine88 reacted to somdcomputerguy for a topic
HotKeySet("{Esc}", "captureEsc") - Assigns the ESC key to the function captureEsc HotKeySet("{Esc}") - Cancel (or unregister) the previous assignment From the help file..1 point