Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/28/2018 in all areas

  1. Just check the File Encoding under menu option File/Encoding to see whether that is correct. Jos
    2 points
  2. I use the following udf, and RegKeyExists function as @kamiquasi points out you can test by using the @error return value. Func RegKeyExists($s_key) _RegRead($s_key, "") ; try to read default value Switch @error Case 1, 2 ; invalid root key | failed to open key Return SetError(@error, 0, 0) Case Else ; key exists Return SetError(0, 0, 1) EndSwitch
    2 points
  3. If I'm reading this right, you're just trying to see if KEY exists, and don't necessarily care about the value of '(Default)'? If that is the case, you should check the @error value after using RegRead. Instead of specifying a value name, you can specify "" (which is what '(Default)' is referenced as, regardless of locale/language). ; Check if 'UserConfig' for 'MySoftware' exists and, if so, parse its '(Default)' value. Local $defaultValue = RegRead("HKCU\Software\MySoftware\UserConfig","") Local $errorRegRead = @error ConsoleWrite("Error: "&$errorRegRead&@CRLF) If ($errorRegRead == 0) Then ConsoleWrite("Value of (Default): "&$defaultValue&@CRLF) ElseIf ($errorRegRead > 0) Then ConsoleWrite("Key does not exist OR key could not be accessed OR key trunk could not be accessed"&@CRLF) ElseIf ($errorRegRead < 0) Then ConsoleWrite("Value name does not exist OR value s not set OR value can not be accessed"&@CRLF) EndIf If you do need to check for a specific value of '(Default)', you can perform the usual tests on $defaultValue to see if it's blank or some value when the @error is 0 (zero). The RegRead help has all this info, but this might make it easier to understand
    2 points
  4. Zedna

    Resources UDF

    Link to pages with general resources description MSDN - Resources OverView & Reference You can embed any binary data into your AutoIt compiled EXE files in it's resources at compile time. As opposite to FileInstall() with resources you can use your embedded data directly without any temporary files on disk. If you wish you can save resources to disk with _ResourceSaveToFile() however. Adding data to resources can be done simply by AutoIt3Wrapper directive: #AutoIt3Wrapper_Res_File_Add=FileName, ResType, ResName As data can be used for example images,cursors,texts,sounds,videos,binary files etc. For loading/using data from resources at run time I made this tiny helper Resources UDF. Functions inside UDF: _ResourceGet($ResName, $ResType = $RT_RCDATA, $ResLang = 0, $DLL = -1) _ResourceGetAsString($ResName, $ResType = $RT_RCDATA, $ResLang = 0, $DLL = -1) _ResourceGetAsStringW($ResName, $ResType = $RT_RCDATA, $ResLang = 0, $DLL = -1) _ResourceGetAsBytes($ResName, $ResType = $RT_RCDATA, $ResLang = 0, $DLL = -1) _ResourceGetAsImage($ResName, $ResType = $RT_RCDATA, $DLL = -1) _ResourceGetAsBitmap($ResName, $ResType = $RT_RCDATA, $DLL = -1) _ResourceSaveToFile($FileName, $ResName, $ResType = $RT_RCDATA, $ResLang = 0, $CreatePath = 0, $DLL = -1) _ResourceSetImageToCtrl($CtrlId, $ResName, $ResType = $RT_RCDATA, $DLL = -1) _SetBitmapToCtrl($CtrlId, $hBitmap) _ResourcePlaySound($ResName, $Flag = 0, $DLL = -1) Notes: * to compile all script examples you must have installed Scite4AutoIt3 --> you must compile script by F7 from full Scite * for using #AutoIt3Wrapper_Res_File_Add directive you must have AutoIt3Wrapper at least version 2.0.1.22 (it's part of latest Scite4AutoIt3) * to compile all script examples must be apropriate resource data files in script directory (from resource_data.zip) * _ResourceGet() always returns pointer to data (for RT_BITMAP returns hBitmap), returning other types can be done by additional wrapper functions like _ResourceGetAsString() or _ResourceGetAsBytes() * _ResourceGetAsStringW() is for Unicode strings (Widechar) * you can use also #number instead of resource name, see examples * general supported resource types are listed in UDF as constants ($RT_BITMAP, $RT_RCDATA, ...) * information about playing video files (AVI) from resources is here thanks matrixnz * information/examples about using animated GIFs from resources is here and here thanks smashly/ProgAndy * information about running EXE files/DLL functions directly from resources is here thanks trancexx/Ward Known problems/limitations: * _ResourceGet() returns resource size (in bytes) in @extended macro but not for resource type RT_BITMAP * _ResourceSetImageToCtrl() works with "static/button" type of controls (picture,label,icon,button,checkbox,radiobutton,groupbox) * _ResourcePlaySound() plays only WAV files (not MP3 files) * _ResourceGetAsBytes() doesn't work for RT_BITMAP type because _ResourceGet() returns hBitmap instead of memory pointer in this case there could be used _ResourceGetAsImage() as workaround * _ResourceGet() has potential memory leak releasing of resources UnlockResource,FreeResource (opposite of LoadResource,LockResource) is not done because it must be done after using of resources at the end and not inside UDF * _GDIPlus_Startup() is called once at start of whole include --> no _GDIPlus_Shutdown() is called History: 2011-06-20 - fixed x64 compatibility (type: int->ptr) - internal change: FindResourceA -> FindResourceW (& type: str->wstr) - _SetBitmapToCtrl() --> $CtrlId parameter now supports also -1 (thanks guinness) - _WinAPI_LoadLibraryEx($DLL, $LOAD_LIBRARY_AS_DATAFILE) instead of _WinAPI_LoadLibrary($DLL) (thanks arcker) - added au3.user.calltips.api, au3.userudfs.properties (thanks guinness) - merged resource_au3.zip + resource_data.zip to one file resources.zip 2010-02-12 - all examples now use fixed #AutoIt3Wrapper_Res_File_Add directive from latest Scite4Autoit3 (no need for ResHacker.exe) - added support for buttons (also checkboxes,radiobuttons,groupboxes) in _ResourceSetImageToCtrl()/_SetBitmapToCtrl() thanks Melba 2009-08-25 - fixed corrupted topic (appeared after forum upgrade) - removed some AU3 tags from topic, note: all AU3 code is untouched inside attached ZIP 2008-11-27 - added _ResourceGetAsStringW() --> for Unicode strings (Widechar) 2008-11-10 - added two very simple examples 2008-08-14 - change: _GDIPlus_Startup() is called once at start of whole include--> no _GDIPlus_Shutdown() is called - fixed support for animated GIFs in _ResourceGetAsImage() --> removed_MemGlobalFree($hData) - used simpler UDF syntax (from WinAPI) instead of DllCall() where possible - added new example for animated GIF image 2008-07-08 - just corrected some typos in this topic (no code changes) 2008-06-25 - big thanks to ProgAndy for ideas,improvements! - added _ResourceGetAsImage(), _ResourceGetAsBitmap() - added optional $DLL parameter to all functions - for loading resources from external EXE,DLL files - fixed previous limitation in _ResourceSaveToFile() - now supports also RT_BITMAP type - new examples in resource_test.au3 2008-05-02 - added new RT,SND constants - fixed bad order of parameters ResName x ResType in FindResourceExA (thanks SmOke_N) - added DeleteObject of oldBmp from STM_SETIMAGE in _SetBitmapToCtrl (thanks ProgAndy) - added settinng SS_BITMAP style to control before STM_SETIMAGE in_SetBitmapToCtrl (support for labels) 2008-04-24 - added support for JPG,GIF,PNG in _ResourceSetImageToCtrl() using GDI+ - thanks ProgAndy - reverted all examples back from #AutoIt3Wrapper_Res_File_Add= to#AutoIt3Wrapper_run_after=ResHacker.exe -add - updated both ZIP archives 2007-10-16 - added _ResourcePlaySound() - thanks Larry - corrected local declaration of $struxt - was problem when Opt("MustDeclareVars",1) - updated resource_test.au3 and resource.au3 in resource_au3.zip 2007-09-14 - added optional parameter $CreatePath in _ResourceSaveToFile() - updated resource_test.au3 and resource.au3 in resource_au3.zip 2007-09-11 - in examples used new AutoIt3Wrapper directive#AutoIt3Wrapper_Res_File_Add from latest Scite4AutoIt3 (instead of #AutoIt3Wrapper_run_after=ResHacker.exe -add ...) - updated resource_test.au3 and resource_test_ie.au3 in resource_au3.zip 2007-09-05 - in #AutoIt3Wrapper_run_after=ResHacker.exe -add ... directive can be resource type in text form -->rcdata instead of 10, bitmap instead of 2 and so on (note: but for htmlmust be used 23 still) - updated only resource_test.au3 in resource_au3.zip 2007-09-04 - added description at top of this topic - added _ResourceSaveToFile() - source is also example for using _ResourceGetAsBytes() - more error checking in UDF and error codes are now differrent todistinguish possible problem - default ResType = 10 ($RT_RCDATA) in all functions - updated both ZIP archives 2007-08-29 - added TODO list - removed not used local variables in _ResourceSetImageToCtrl() - ziparchive not updated yet - revisited WWW links and TODO list and added list of functions 2007-08-10 - first version resource_test_min1.au3 - very simple example script of using UDF #AutoIt3Wrapper_Res_File_Add=image3.jpg, rt_rcdata, TEST_JPG_1 #include "resources.au3" $gui = GUICreate("Data from resources simple example 1",400,150) $pic1 = GUICtrlCreatePic("",0,0,400,150) _ResourceSetImageToCtrl($pic1, "TEST_JPG_1") ; set JPG image to picture control from resource GUISetState(@SW_SHOW) While 1 If GUIGetMsg() = -3 Then Exit WEnd resource_test.au3 - complex example script of using UDF #AutoIt3Wrapper_Res_File_Add=test_1.txt, rt_rcdata, TEST_TXT_1 #AutoIt3Wrapper_Res_File_Add=image1.bmp, rt_bitmap, TEST_BMP_1 #AutoIt3Wrapper_Res_File_Add=image2.bmp, rt_bitmap, TEST_BMP_2 #AutoIt3Wrapper_Res_File_Add=image3.jpg, rt_rcdata, TEST_JPG_3 #AutoIt3Wrapper_Res_File_Add=binary1.dat, rt_rcdata, TEST_BIN_1 #AutoIt3Wrapper_Res_File_Add=C:\WINDOWS\Media\tada.wav, sound, TEST_WAV_1 #include "resources.au3" $gui = GUICreate("Data from resources example",820,400) $pic1 = GUICtrlCreatePic("",0,0,400,300) $pic2 = GUICtrlCreatePic("",400,0,400,150) $pic3 = GUICtrlCreatePic("",400,150,400,150) $pic4 = GUICtrlCreatePic("",600,320,400,100) $label1 = GUICtrlCreateLabel("",20,320,380,100) $label2 = GUICtrlCreateLabel("",400,320,200,100) GUISetState(@SW_SHOW) ; get string from resource $string = _ResourceGetAsString("TEST_TXT_1") GUICtrlSetData($label1, $string) ; set BMP image to picture control from resource bitmap _ResourceSetImageToCtrl($pic1, "TEST_BMP_1", $RT_BITMAP) ; get bitmap from resource (as pointer) $hBmp = _ResourceGet("TEST_BMP_2", $RT_BITMAP) ; and use it for whatever you like _SetBitmapToCtrl($pic2, $hBmp) ; set JPG image to picture control from resource _ResourceSetImageToCtrl($pic3, "TEST_JPG_3") ; set image to picture control from external DLL resource _ResourceSetImageToCtrl($pic4, "#14355", $RT_BITMAP, @SystemDir & "\shell32.dll") ; get/use picture from resources as hImage type $size1 = _ResourceGetImageSize("TEST_BMP_1", $RT_BITMAP) $size2 = _ResourceGetImageSize("TEST_JPG_3") GUICtrlSetData($label2, $size1 & @CRLF & $size2) ; save binary data or another type (image) from resource to file and get its size in bytes $size1 = _ResourceSaveToFile(@ScriptDir & "\binary_data1.dat", "TEST_BIN_1") $size2 = _ResourceSaveToFile(@ScriptDir & "\binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP) ; save binary data from resource to file (create not existing directory) _ResourceSaveToFile("C:\Dir1\SubDir2\binary_data1.dat", "TEST_BIN_1", $RT_RCDATA, 0, 1) _ResourceSaveToFile("C:\Dir1\SubDir2\binary_data2.bmp", "TEST_BMP_1", $RT_BITMAP, 0, 1) ; play WAV from resource (sync/async) _ResourcePlaySound("TEST_WAV_1") _ResourcePlaySound("TEST_WAV_1", $SND_ASYNC) While 1 If GUIGetMsg() = -3 Then Exit WEnd Func _ResourceGetImageSize($ResName, $ResType = 10) ; $RT_RCDATA = 10 ; get/use picture from resources as hImage type $hImage = _ResourceGetAsImage($ResName, $ResType) $width = _GDIPlus_ImageGetWidth ($hImage) $height = _GDIPlus_ImageGetHeight($hImage) Return "Size of " & $ResName & " is: " & $width & "x" & $height EndFunc resources.zip - UDF + examples + sample resource data for examples Previous downloads: 7195 resources.zip
    1 point
  5. @Spinwiz, I guess it is actually pretty simple to still support WinXP as it is just Tidy and Au3Stripper having this issue because PellesC 9 isn't compatible with WinXP. I can easily keep on compiling them with PellesC 6 as I still have that as well. Will fix this in the next version coming out soon so you can test it them when you wish. (Or try the current Beta recompiled versions) Jos
    1 point
  6. Nine

    [Solved] _Crypt_HashFile()

    Return SetError(@error, 0, StringUpper(StringReplace($HashFile, "0x", ""))) replace it by Return SetError(@error, 0, StringTrimLeft($HashFile, 2)) and comparing a string with 0, not a good idea If ($iHASH = "") Or ($iHASH = 0) Then Return SetError(1, 0, "") change to simple If $iHASH = "" Then Return SetError(1, 0, "") Also _Crypt_HashFile does a _Crypt_startup and shutdown
    1 point
  7. iamtheky

    SMS UDF

    'mobile carrier SMS gateway' is all the keywords i can think of. maybe check this list too: https://github.com/mfitzp/List_of_SMS_gateways/blob/master/legacy.md
    1 point
  8. devolve much kids? Mindless bickering is my bag, yall can sod off.
    1 point
  9. Thanks guys yeah i was pretty stupid... It is just when we do somthing too much time we sometime forget to do the easyer thing first.... Totaly forget about using the @error flag... So obvius after reading it... Happy new year.
    1 point
  10. Yes. You could do something like this: #include <Memory.au3> Local $tStruct1=DllStructCreate("int;int;") DllStructSetData($tStruct1,1,10) DllStructSetData($tStruct1,2,20) Local $tStruct2=DllStructCreate("int;int;") DllStructSetData($tStruct2,1,30) DllStructSetData($tStruct2,2,40) Local $tStructArray=DllStructCreate("int;int;int;int;");with size $tStruct1+$tStruct2 _MemMoveMemory($tStruct1,$tStructArray,DllStructGetSize($tStruct1)) ;copy $tStruct1 to new structure _MemMoveMemory($tStruct2,DllStructGetPtr($tStructArray)+DllStructGetSize($tStruct1),DllStructGetSize($tStruct2)) ;append $tStruct2 ConsoleWrite(DllStructGetData($tStructArray,1) & @CRLF) ConsoleWrite(DllStructGetData($tStructArray,2) & @CRLF) ConsoleWrite(DllStructGetData($tStructArray,3) & @CRLF) ConsoleWrite(DllStructGetData($tStructArray,4) & @CRLF) ;or Local $tStructArray=DllStructCreate("int;int;int;int;");with size $tStruct1+$tStruct2 Local $tStruct1=DllStructCreate("int;int;",DllStructGetPtr($tStructArray)) DllStructSetData($tStruct1,1,100) DllStructSetData($tStruct1,2,200) Local $tStruct2=DllStructCreate("int;int;",DllStructGetPtr($tStructArray)+DllStructGetSize($tStruct1)) DllStructSetData($tStruct2,1,300) DllStructSetData($tStruct2,2,400) ConsoleWrite(DllStructGetData($tStructArray,1) & @CRLF) ConsoleWrite(DllStructGetData($tStructArray,2) & @CRLF) ConsoleWrite(DllStructGetData($tStructArray,3) & @CRLF) ConsoleWrite(DllStructGetData($tStructArray,4) & @CRLF) Saludos
    1 point
  11. After some trying i found a workaround: Dim $player[] Dim $sub[] $player.test1 = 1 $player.test2 = $sub $player.test2.child1 = "org" $player.test2.childext = $sub $player.test2.childext.child1 = "org2" $player.a = $player ; make a temporary copy of the whole map inside an unused key of the map to be copied. ; This also forces the submaps to get their unique copies and all references to 'root' $player are cut. $playerold = $player.a ; So $playerold will recieve a independent copy of $player MapRemove($player, "a") ; Temporary copy not needed any more ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF); original nested value in $player $playerold.test2.child1 = "changed" ; edit a nested value in $playerold ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF) ; original nested value in $player changed ConsoleWrite("---------------------" & @CRLF) ConsoleWrite("player.test2.childext.child1 : "& $player.test2.childext.child1 & @CRLF); original level2 nested value in $player $playerold.test2.childext.child1 = "changed2" ; edit a level2 nested value in $playerold ConsoleWrite("player.test2.child1 : "& $player.test2.child1 & @CRLF); original level1 nested value in $player stayed the same ConsoleWrite("player.test2.childext.child1 : "& $player.test2.childext.child1 & @CRLF); original level2 nested value in $player changed
    1 point
  12. Interestingly enough, the DIR cmd also does not return the compressed (size on disk) size. I could be off base here, but I suspect it may have to do with the underlying API call. According to the MSDN article for the GetFileSize function, it is stated that, "...The GetFileSize function retrieves the uncompressed size of a file. Use the GetCompressedFileSize function to obtain the compressed size of a file." Perhaps the underlying API call isn't using that specific function, but I at least got a clue that it takes additional consideration to obtain the compressed size. Looking at the function, it is specifically for files, which makes sense if you think about it as folders themselves do not have "sizes"--let's not get into how directories are stored in the File System right now... I pieced together a simple function to recursively collect the compressed file sizes of a files within a directory using the GetCompressedFileSize function above, which I referenced from another post on the forum authored by Ascend4nt. #include <File.au3> #include <WinAPI.au3> $sPath = "C:\Test" $iDirSize = _DirGetCompressedSize($sPath) Msgbox(0,$sPath,$iDirSize) Func _DirGetCompressedSize($sPath) Local $aFileList = _FileListToArrayRec($sPath,Default,$FLTAR_FILES,$FLTAR_RECUR) Local $iDirSize = 0 If Not IsArray($aFileList) Then Return SetError(1,0,0) For $iFile = 1 to $aFileList[0] $iDirSize += _FileGetCompressedSize($sPath & "\" & $aFileList[$iFile]) Next Return $iDirSize EndFunc Func _FileGetCompressedSize($sFile) If Not IsString($sFile) Or $sFile='' Then Return SetError(1,0,-1) Local $aRet=DllCall('kernel32.dll','dword','GetCompressedFileSizeW','wstr',$sFile,'dword*',0) If @error Then Return SetError(2,0,-1) #cs ; ------------------------------------------------------------------------------------------------------------------- ; Per MSDN, a return of 0 in FileSizeHigh AND a return of INVALID_FILE_SIZE (0xFFFFFFFF) in FileSizeLow means failure ; The size of a file on disk will NEVER be INVALID_FILE_SIZE, which is an odd # (4,294,967,295 bytes to be exact), ; however on regular (uncompressed, non-sparse file) files, this IS possible. ; This requires a third check using GetLastError API call. Non-zero means the call failed. ; ------------------------------------------------------------------------------------------------------------------- #ce ; Size is 'INVALID_FILE_SIZE' and GetLastError returns something other than 'NO_ERROR' (0)? If $aRet[2]=0 And $aRet[0]=0xFFFFFFFF And _WinAPI_GetLastError()<>0 Then Return SetError(3,0,-1) Local $stFileSize64=DllStructCreate("uint64"),$stFileSizePts=DllStructCreate("dword[2]",DllStructGetPtr($stFileSize64)) DllStructSetData($stFileSizePts,1,$aRet[0],1) DllStructSetData($stFileSizePts,1,$aRet[2],2) Return DllStructGetData($stFileSize64,1) EndFunc In my testing, the value still showed to be larger than what the folder properties was showing, but marginally. Still much closer than what the raw file size is. At least it gives you something to play with.
    1 point
  13. 1 point
  14. With this attitude you might as well give up scripting now; you will never be any good at it. This forum is dedicated to helping people who actually want to learn. This is not a place where you put in a request and someone does it all for you; if you are unwilling to put in any effort you will not be successful. Reading the help file is effort. Trying different things and working to figure out how things work is effort. Complaining because people won't do it all for you is not going to get you anywhere.
    1 point
  15. Subz

    IMDb Top 250 extracter

    You're scraping web data so you need some basic html knowledge, I normally use Chrome and inspect each element that you need to capture, you need to identify unique information, for example <div id="xyz"> is better than <div class="xyz"> since id should only be used once per page (if coded correctly). Class names are normally used throughout the document, however in most instances, people will use class names like in the example I posted above so that all titles have a class name of "titleColumn", making it easy identify. If you look at the link you posted and inspect the elements of the page you'll notice it doesn't use tables, but is using divs. Each title has a class name named "lister-item-content", you'll note the heading "h3" is the title and holds the url. So start with: $oDivs = _IETagNameGetCollection($oIE, "div") Loop and look for $oDiv.ClassName = "lister-item-content" _IETagNameGetCollection($oDiv, "h3") $oH3.InnerText will be your title Use the code I posted above to get the links. If you encounter any issues post your code and we can assist.
    1 point
  16. I think that a little bit of effort from your side should be showed. No-one is here to code for you, as it is stated in the Forum etiquette.
    1 point
  17. _WinAPI_GetStartupInfo #include <WinAPISys.au3> $tSTARTUPINFO = _WinAPI_GetStartupInfo ( ) For $i = 1 To 18 ConsoleWrite(DllStructGetData($tSTARTUPINFO, $i) & @LF) Next
    1 point
×
×
  • Create New...