Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/16/2015 in all areas

  1. jguinch

    Firefox configuration

    Hello ! Here is a small function which allows you to make changes in the Firefox configuration file (of the user running the script) Warning : to make changes into the configuration file, Firefox must be stopped Here you can find some settings in this webpage : http://kb.mozillazine.org/About:config_entries Examples : ; Changes the start page _FF_Config("browser.startup.homepage", "http://www.autoitscript.com/forum") ; Set a manual proxy _FF_Config("network.proxy.type", 1) ; Sets the proxy in manual mode _FF_Config("network.proxy.http", "192.168.1.10") ; Sets the http proxy name/IP _FF_Config("network.proxy.http_port", 3128) ; Sets the http proxy port _FF_Config("network. proxy. autoconfig_url") ; Remove the proxy url ; Allow popups _FF_Config("dom.disable_open_during_load", false) Also, you can use _FF_GetProfileList() to retrieve the list of Firefox profiles for the current user. Now, the two functions : #include <File.au3> ; needed for _PathFull ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FF_Config ; Description ...: Configures Mozilla Firefox ; Syntax ........: _FF_Config($sSettingName[, $sSettingValue = Null[, $sProfileName = ""]]) ; Parameters ....: $sSettingName - Name of the setting to add, change or delete. ; $sSettingValue - [optional] Value of the setting. Default is Null = deletes the line. ; $sProfileName - [optional] Name of the Firefox profile. Default is "" = all Firefox profiles ; Return values .: Success - Returns 1 ; Failure - Returns 0 and set @error to : ; 1 : Unable to list the Firefox profiles ; 2 : Unable to load the specified Firefox profile ; 3 : Firefox is running ; Author ........: jguinch ; =============================================================================================================================== Func _FF_Config($sSettingName, $sSettingValue = Null, $sProfileName = "") Local $sFFConfigFile = "prefs.js" Local $sContent, $aProfiles = _FF_GetProfileList(), $iError = 0, $hPrefs If @error Then Return SetError(@error, 0, 0) If ProcessExists("firefox.exe") Then Return SetError(3, 0, 0) If IsString($sSettingValue) Then $sSettingValue = '"' & $sSettingValue & '"' If IsBool($sSettingValue) Then $sSettingValue = StringLower($sSettingValue) For $i = 1 To $aProfiles[0][0] If $sProfileName <> "" AND $aProfiles[$i][0] <> $sProfileName Then ContinueLoop $sContent = FileRead($aProfiles[$i][1] & "\" & $sFFConfigFile) If @error Then Return SetError(2, 0, 0) If $sSettingValue = Null Then $sNewContent = StringRegExpReplace($sContent, '(?mi)^\Quser_pref("' & $sSettingName & '"\E\V+\R', '') Else $sNewContent = StringRegExpReplace($sContent, '(?mi)^\Quser_pref("' & $sSettingName & '", \E\K.+(?=\);$)', $sSettingValue) If NOT @extended Then $sNewContent = StringRegExpReplace($sContent, ";\K\v*$", @CRLF & 'user_pref("' & $sSettingName & '", ' & $sSettingValue & ');' & @CRLF) EndIf $hPrefs = FileOpen($aProfiles[$i][1] & "\" & $sFFConfigFile, 2) If $hPrefs = -1 Then Return SetError(2, 0, 0) FileWrite($hPrefs, $sNewContent) FileClose($hPrefs) Next Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FF_GetProfileList ; Description ...: List the Firefox profiles in a 2D array ; Syntax ........: _FF_GetProfileList() ; Parameters ....: None ; Return values .: Success - Returns a 2D array (see remarks) ; Failure - Returns 0 and set @error to 1 (unable to list the Firefox profiles) ; Author ........: jguinch ; Remarks........: The array returned is two-dimensional and is made up as follows: ; $aArray[0][0] : Number of profiles ; $aArray[0][1] : Default profile index in the array ; $aArray[1][0] : 1st profile name ; $aArray[1][1] : 1st profile path ; ... ; $aArray[n][0] : nth profile name ; $aArray[n][1] : nth profile path ; =============================================================================================================================== Func _FF_GetProfileList() Local $sProfileName, $sIsRelative, $sProfilePath, $aResult[10][2] = [[0]] Local $sFFAppDataPah = @AppDataDir & "\Mozilla\Firefox" Local $sProfiles = $sFFAppDataPah & "\profiles.ini" Local $aSections = IniReadSectionNames($sProfiles) If @error OR NOT IsArray($aSections) Then Return SetError(1, 1, 0) For $i = 1 To $aSections[0] If $aSections[$i] <> "General" Then $sProfileName = IniRead($sProfiles, $aSections[$i], "Name", "") $sIsRelative = IniRead($sProfiles, $aSections[$i], "IsRelative", "") $sProfilePath = IniRead($sProfiles, $aSections[$i], "Path", "") If $sIsRelative = "" OR $sProfilePath = "" OR $sProfileName = "" Then ContinueLoop If Number($sIsRelative) = 1 Then $sProfilePath = _PathFull( @AppDataDir & "\Mozilla\Firefox\" & StringReplace($sProfilePath, "/", "\") ) If NOT FileExists($sProfilePath & "\prefs.js") Then ContinueLoop $aResult[0][0] += 1 If $aResult[0][0] = UBound($aResult) Then Redim $aResult[ UBound($aResult) * 2][2] If Number(IniRead($sProfiles, $aSections[$i], "Default", "error")) = 1 Then $aResult[0][1] = $aResult[0][0] $aResult[ $aResult[0][0] ][0] = $sProfileName $aResult[ $aResult[0][0] ][1] = $sProfilePath EndIf Next If NOT $aResult[0][1] AND $aResult[0][0] > 0 Then $aResult[0][1] = 1 Redim $aResult [ $aResult[0][0] + 1 ][2] Return $aResult EndFunc
    1 point
  2. JohnOne

    Exe - Au3 Error!

    Looks a bit odd to me at first glance, since the error you are getting comes from within a function which appears never to be even called. Searched "_Start " instead of "_Start"
    1 point
  3. This might help you: https://autoit.de/index.php/Thread/83074-Just-4-Fun-WAV-Generator German only.
    1 point
  4. Seems to me like you're not interested in anything anyone has to say, I'm wondering why your question was not just "Does FF expose COM methods?" It does not, there would be a UDF that uses it easily found if it did. So why not just do that?
    1 point
  5. You could directly try Scripting.Dictionary , see here
    1 point
  6. Melba23

    While statement help

    Estimize, Add an ExitLoop after running the function: While 1 If $bVar = True Then Func_1() ExitLoop EndIf WendNow you will wait until the variable is True and then just run the function once. M23
    1 point
  7. I've found most of the settings I need to change are in the prefs.js file in each Firefox users profile. I've had great success with this script: https://www.autoitscript.com/forum/topic/169753-firefox-configuration Hope this helps, -Mike Update: Using the above script, this command allowed me to change from true to false...I assume the method to toggle back is obvious. _FF_Config("gfx.downloadable_fonts.enabled", false) Make sure you quit Firefox before attempting to make the change.
    1 point
  8. Glad to be of service
    1 point
  9. Then please have a look at functions _IEGetObjById and _IEAction to click on the returned element.
    1 point
  10. Welcome to AutoIt and the forum! Which browser do you run? AutoIt comes with an UDF (User Defined Functions library) for Internet Explorer. But there are other UDFs for Firefox and Chrome as well. Does clicking on a row mean you want to open an URL?
    1 point
  11. I think the best approach is to avoid memory leaks. Means: Release storage when it is no longer used. Set unused arrays to "" to release the memory, set unused objects to 0 to drop a connection, application or whatever.
    1 point
  12. wolf9228

    ASM BinarySearch

    Project to search for binary data in three different ways using assembly language Three ways - Search for a binary - Search for a binary using the callback function - Search for a binary using the data structure Find very fast .. Greetings Project Files ASM_BinarySearch.zip ASM_BinarySearch.au3 #include <WinAPI.au3> Global $MsvcrtDll = _WinAPI_LoadLibrary( "msvcrt.dll" ) Global $Mmove = _WinAPI_GetProcAddress($MsvcrtDll,"memmove") Global $Malloc = _WinAPI_GetProcAddress($MsvcrtDll,"malloc") Global $FreeMemy = _WinAPI_GetProcAddress($MsvcrtDll,"free") Global $DwordSize=DllStructGetSize(DllStructCreate("DWORD")) Global $PointerSize=DllStructGetSize(DllStructCreate("PTR")) Global $AddressBinarySearch = LoadBinarySearch() Global $AddressBinarySearchPtr = DllStructGetPtr($AddressBinarySearch) Global $AddressCallbackBinarySearch = LoadCallbackBinarySearch() Global $AddressCallbackBinarySearchPtr = DllStructGetPtr($AddressCallbackBinarySearch) Global $AddressXBinarySearch = LoadXBinarySearch() Global $AddressXBinarySearchPtr = DllStructGetPtr($AddressXBinarySearch) Func BinarySearch($DataPtr,$SubDataPtr,$DataPtrSize,$SubDataPtrSize,$Step = 1) ; $Step Loop Step if ($SubDataPtrSize < 1) Or ($DataPtrSize < 1) Or ($SubDataPtrSize > $DataPtrSize) Then Return SetError(1,0,0) Local $MaxPosition = ($DataPtrSize - $SubDataPtrSize) $Return = DllCallAddress("DWORD",$AddressBinarySearchPtr,"DWORD",$MaxPosition, _ "DWORD",$DataPtrSize,"DWORD",$SubDataPtrSize,"PTR",$DataPtr,"PTR",$SubDataPtr,"DWORD",$Step) if @error Then Return SetError(2,0,0) Return $Return[0] ; Return FindPosition // OffSetPosition = FindPosition - 1 EndFunc Func CallbackBinarySearch($DataPtr,$SubDataPtr,$CbFuncName,$DataPtrSize,$SubDataPtrSize,$Step = 1) ; $Step Loop Step ;$CbFuncName ;Func CallbackFunc($FindPosition,$OffSetPosition,$DataPtr,$SubDataPtr,$DataPtrSize,$SubDataPtrSize) ;MsgBox(0,"OffSetPosition = " & $OffSetPosition ,"FindPosition = " & $FindPosition) ;Return 1 ;return ;0 ; Stop ;Other Ways : Continue ;EndFunc if ($SubDataPtrSize < 1) Or ($DataPtrSize < 1) Or ($SubDataPtrSize > $DataPtrSize) Then Return SetError(1,0,False) Local $RegCallbackFunc = DllCallbackRegister($CbFuncName,"DWORD","DWORD;DWORD;PTR;PTR;DWORD;DWORD") if @error Then Return SetError(2,0,False) Local $CkFuncPtr = DllCallbackGetPtr($RegCallbackFunc) Local $MaxPosition = ($DataPtrSize - $SubDataPtrSize) Local $StepTest = $Step >= $SubDataPtrSize $Return = DllCallAddress("DWORD",$AddressCallbackBinarySearchPtr,"DWORD",$MaxPosition,"DWORD", _ $DataPtrSize,"DWORD",$SubDataPtrSize,"PTR",$DataPtr,"PTR",$SubDataPtr,"PTR",$CkFuncPtr,"DWORD",$Step,"DWORD",$StepTest) if @error Then DllCallbackFree($RegCallbackFunc) Return SetError(3,0,False) EndIf DllCallbackFree($RegCallbackFunc) Return True ; Return BOOL EndFunc Func XBinarySearch($DataPtr,$SubDataPtr,$DataPtrSize,$SubDataPtrSize,$Step = 1) ; $Step Loop Step if ($SubDataPtrSize < 1) Or ($DataPtrSize < 1) Or ($SubDataPtrSize > $DataPtrSize) Then Return SetError(1,0,False) Local $tagReturnStruct = "DWORD ArrayCount;PTR PositionArray" Local $ReturnStruct = DllStructCreate($tagReturnStruct) Local $RtStructPtr = DllStructGetPtr($ReturnStruct) Local $MaxPosition = ($DataPtrSize - $SubDataPtrSize) Local $StepTest = $Step >= $SubDataPtrSize Local $Return = DllCallAddress("DWORD",$AddressXBinarySearchPtr,"DWORD",$MaxPosition,"DWORD",$DataPtrSize, _ "DWORD",$SubDataPtrSize,"PTR",$DataPtr,"PTR",$SubDataPtr,"PTR",$RtStructPtr,"DWORD",$Step,"DWORD",$StepTest) if @error Then Return SetError(2,0,0) Local $ArrayCount = DllStructGetData($ReturnStruct,1) Local $PosonArray = DllStructGetData($ReturnStruct,2) if ($ArrayCount = 0) Then Return SetError(3,0,0) Local $tagReturnStruct = "DWORD ArrayCount;DWORD PositionArray[" & $ArrayCount & "]" Local $ReturnStruct = DllStructCreate($tagReturnStruct) Local $NewPosonArray = DllStructGetPtr($ReturnStruct,2) DllStructSetData($ReturnStruct,1,$ArrayCount) DllCallAddress("ptr:cdecl",$Mmove,"ptr",$NewPosonArray,"ptr",$PosonArray,"int",($ArrayCount * $DwordSize)) DllCallAddress("none:cdecl",$FreeMemy,"ptr",$PosonArray) Return $ReturnStruct ; Return Struct of FindPosition // tagStruct = "DWORD ArrayCount;DWORD PositionArray[" & ArrayCount & "]" EndFunc Func LoadBinarySearch() Local $TA,$TB,$TC,$Start,$JGEnd,$JZTC,$TBJNZ,$JMPTA,$JMPStart,$End Local $OffSetMaxPosition = $PointerSize Local $OffSetDataPtrSize = ($OffSetMaxPosition + $DwordSize) Local $OffSetSubDataPtrSize = ($OffSetDataPtrSize + $DwordSize) Local $OffSetDataPtr = ($OffSetSubDataPtrSize + $DwordSize) Local $OffSetSubDataPtr = ($OffSetDataPtr + $PointerSize) Local $OffSetStep = ($OffSetSubDataPtr + $PointerSize) For $i = 1 To 2 $_ASMCode = "0x" $_ASMCode &= "BF" & HexBinary(0) ;mov edi,0 $_ASMCode &= "8B7424" & Hex($OffSetSubDataPtrSize,2) ;mov esi,[esp + $OffSetSubDataPtrSize] $_ASMCode &= "8B5C24" & Hex($OffSetDataPtr,2) ;mov ebx,[esp + $OffSetDataPtr] $_ASMCode &= "8B4424" & Hex($OffSetSubDataPtr,2) ;mov eax,[esp + $OffSetSubDataPtr] ; $Start: // $Start = BinaryLen($_ASMCode) $_ASMCode &= "BA" & HexBinary(0) ;mov edx,0 ; TA: // $TA = BinaryLen($_ASMCode) $_ASMCode &= "3BF2";CMP esi,edx $_ASMCode &= "74" & Hex(($TC - $JZTC),2) ;JZ $TC; $JZTC = BinaryLen($_ASMCode) $_ASMCode &= "8A2C10" ;mov CH,[eax + edx]; $_ASMCode &= "3A2C13" ;CMP CH,[ebx + edx] $_ASMCode &= "75" & Hex(($TB - $TBJNZ),2) ;JNZ TB $TBJNZ = BinaryLen($_ASMCode) $_ASMCode &= "83C2" & Hex(1,2) ;add edx,1 $JMPTA = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPTA - $TA) + 5)) ;JMP TA ; TB: // $TB = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetStep,2) ;add edi,[esp + $OffSetStep] $_ASMCode &= "3B7C24" & Hex($OffSetMaxPosition,2) ;CMP edi,[esp + $OffSetMaxPosition] $_ASMCode &= "7F" & Hex(($End - $JGEnd),2) ;JG End $JGEnd = BinaryLen($_ASMCode) $_ASMCode &= "035C24" & Hex($OffSetStep,2) ;add ebx,[esp + $OffSetStep] $JMPStart = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStart - $Start) + 5)) ;JMP Start ; TC: // $TC = BinaryLen($_ASMCode) $_ASMCode &= "83C7" & Hex(1,2) ;add edi,1 $_ASMCode &= "8BC7" ;mov eax,edi $_ASMCode &= "C2" & Hex((($PointerSize * 2) + ($DwordSize * 4)),2) & Hex(0,2) ;ret (($PointerSize * 2) + ($DwordSize * 3)) & "00" // Args Size ; End: // $End = BinaryLen($_ASMCode) $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex((($PointerSize * 2) + ($DwordSize * 4)),2) & Hex(0,2) ;ret (($PointerSize * 2) + ($DwordSize * 3)) & "00" // Args Size Next $Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]") DllStructSetData($Address,1,$_ASMCode) Return $Address EndFunc Func LoadCallbackBinarySearch() Local $TA,$TB,$TC,$Start,$JGEnd,$JZTC,$TBJNZ,$JMPTA,$JMPStartA,$JMPStartB,$End,$JZEnd,$JGEnd2,$JZTD,$TD,$JGEnd3,$JMPStartC Local $OffSetMaxPosition = $PointerSize Local $OffSetDataPtrSize = ($OffSetMaxPosition + $DwordSize) Local $OffSetSubDataPtrSize = ($OffSetDataPtrSize + $DwordSize) Local $OffSetDataPtr = ($OffSetSubDataPtrSize + $DwordSize) Local $OffSetSubDataPtr = ($OffSetDataPtr + $PointerSize) Local $OffSetCkFuncPtr = ($OffSetSubDataPtr + $PointerSize) Local $OffSetStep = ($OffSetCkFuncPtr + $PointerSize) Local $OffSetStepTest = ($OffSetStep + $DwordSize) For $i = 1 To 2 $_ASMCode = "0x" $_ASMCode &= "BF" & HexBinary(0) ;mov edi,0 $_ASMCode &= "8B7424" & Hex($OffSetMaxPosition,2) ;mov esi,[esp + $OffSetMaxPosition] $_ASMCode &= "8B5C24" & Hex($OffSetDataPtr,2) ;mov ebx,[esp + $OffSetDataPtr] $_ASMCode &= "8B4C24" & Hex($OffSetSubDataPtr,2) ;mov ecx,[esp + $OffSetSubDataPtr] ; $Start: // $Start = BinaryLen($_ASMCode) $_ASMCode &= "BA" & HexBinary(0) ;mov edx,0 ; TA: // $TA = BinaryLen($_ASMCode) $_ASMCode &= "3B5424" & Hex($OffSetSubDataPtrSize,2) ;CMP edx,[esp + $OffSetSubDataPtrSize] $_ASMCode &= "74" & Hex(($TC - $JZTC),2) ;JZ $TC; $JZTC = BinaryLen($_ASMCode) $_ASMCode &= "8A2413" ;mov AH,[ebx + edx] $_ASMCode &= "3A2411" ;CMP AH,[ecx + edx] $_ASMCode &= "75" & Hex(($TB - $TBJNZ),2) ;JNZ TB $TBJNZ = BinaryLen($_ASMCode) $_ASMCode &= "83C2" & Hex(1,2) ;add edx,1 $JMPTA = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPTA - $TA) + 5)) ;JMP TA ; TB: // $TB = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetStep,2) ;add edi,[esp + $OffSetStep] $_ASMCode &= "3BFE" ;CMP edi,esi $_ASMCode &= "7F" & Hex(($End - $JGEnd),2) ;JG End $JGEnd = BinaryLen($_ASMCode) $_ASMCode &= "035C24" & Hex($OffSetStep,2) ;add ebx,[esp + $OffSetStep] $JMPStartA = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStartA - $Start) + 5)) ;JMP Start ; TC: // $TC = BinaryLen($_ASMCode) $_ASMCode &= "8B4424" & Hex($OffSetCkFuncPtr,2) ;mov eax,[esp + $OffSetCkFuncPtr] $_ASMCode &= "FF7424" & Hex($OffSetSubDataPtrSize,2) ;push [esp + $OffSetSubDataPtrSize] $_ASMCode &= "FF7424" & Hex($OffSetDataPtrSize,2) ;push [esp + $OffSetDataPtrSize] $_ASMCode &= "FF7424" & Hex($OffSetSubDataPtr,2) ;push [esp + $OffSetSubDataPtr] $_ASMCode &= "FF7424" & Hex($OffSetDataPtr,2) ;push [esp + $OffSetDataPtr] $_ASMCode &= "57" ;push edi; $_ASMCode &= "83C7" & Hex(1,2) ;add edi,1 $_ASMCode &= "57" ;push edi; $_ASMCode &= "83EF" & Hex(1,2) ;sub edi,1 $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "83F8" & Hex(0,2);CMP eax,0 $_ASMCode &= "74" & Hex(($End - $JZEnd),2) ;JZ $End; $JZEnd = BinaryLen($_ASMCode) $_ASMCode &= "8B4424" & Hex($OffSetStepTest,2) ;mov eax,[esp + $OffSetStepTest] $_ASMCode &= "83F8" & Hex(1,2);CMP eax,1 $_ASMCode &= "74" & Hex(($TD - $JZTD),2) ;JZ $TD; $JZTD = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetSubDataPtrSize,2) ;add edi,[esp + $OffSetSubDataPtrSize] $_ASMCode &= "3BFE" ;CMP edi,esi $_ASMCode &= "7F" & Hex(($End - $JGEnd3),2) ;JG End $JGEnd3 = BinaryLen($_ASMCode) $_ASMCode &= "035C24" & Hex($OffSetSubDataPtrSize,2) ;add ebx,[esp + $OffSetSubDataPtrSize] $_ASMCode &= "8B4C24" & Hex($OffSetSubDataPtr,2) ;mov ecx,[esp + $OffSetSubDataPtr] $JMPStartC = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStartC - $Start) + 5)) ;JMP Start ; TD: // $TD = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetStep,2) ;add edi,[esp + $OffSetStep] $_ASMCode &= "3BFE" ;CMP edi,esi $_ASMCode &= "7F" & Hex(($End - $JGEnd2),2) ;JG End $JGEnd2 = BinaryLen($_ASMCode) $_ASMCode &= "035C24" & Hex($OffSetStep,2) ;add ebx,[esp + $OffSetStep] $_ASMCode &= "8B4C24" & Hex($OffSetSubDataPtr,2) ;mov ecx,[esp + $OffSetSubDataPtr] $JMPStartB = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStartB - $Start) + 5)) ;JMP Start ; End: // $End = BinaryLen($_ASMCode) $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex((($PointerSize * 3) + ($DwordSize * 5)),2) & Hex(0,2) ;ret (($PointerSize * 3) + ($DwordSize * 5)) & "00" // Args Size Next $Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]") DllStructSetData($Address,1,$_ASMCode) Return $Address EndFunc Func LoadXBinarySearch() Local $TA,$TB,$TC,$TD,$Start,$JGEnd,$JZTC,$TBJNZ,$JMPTA,$JMPStartA,$JMPStartB Local $JMPStartC ,$End,$JZEnd,$JZTD,$TE,$JZTE,$JMPStartD,$TF,$JZTF,$JMPStartE Local $OffSetMaxPosition = $PointerSize Local $OffSetDataPtrSize = ($OffSetMaxPosition + $DwordSize) Local $OffSetSubDataPtrSize = ($OffSetDataPtrSize + $DwordSize) Local $OffSetDataPtr = ($OffSetSubDataPtrSize + $DwordSize) Local $OffSetSubDataPtr = ($OffSetDataPtr + $PointerSize) Local $OffSetRtStPtr = ($OffSetSubDataPtr + $PointerSize) Local $OffSetStep = ($OffSetRtStPtr + $PointerSize) Local $OffSetStepTest = ($OffSetStep + $DwordSize) For $i = 1 To 2 $_ASMCode = "0x" $_ASMCode &= "BF" & HexBinary(0) ;mov edi,0 ;$Start: // $Start = BinaryLen($_ASMCode) $_ASMCode &= "8B4424" & Hex($OffSetMaxPosition,2) ;mov eax,[esp + $OffSetMaxPosition] $_ASMCode &= "3BF8" ;CMP edi,eax $_ASMCode &= "0F8F" & HexBinary(($End - $JGEnd)) ;JG End $JGEnd = BinaryLen($_ASMCode) $_ASMCode &= "BE" & HexBinary(0) ;mov esi,0 ; TA: // $TA = BinaryLen($_ASMCode) $_ASMCode &= "8B4424" & Hex($OffSetSubDataPtrSize,2) ;mov eax,[esp + $OffSetSubDataPtrSize] $_ASMCode &= "3BF0" ;CMP esi,eax $_ASMCode &= "74" & Hex(($TC - $JZTC),2) ;JZ $TC; $JZTC = BinaryLen($_ASMCode) $_ASMCode &= "8B5C24" & Hex($OffSetDataPtr,2) ;mov ebx,[esp + $OffSetDataPtr] $_ASMCode &= "03DF" ;add ebx,edi $_ASMCode &= "03DE" ;add ebx,esi $_ASMCode &= "8A0B" ;mov CL,[ebx]; $_ASMCode &= "8B5C24" & Hex($OffSetSubDataPtr,2) ;mov ebx,[esp + $OffSetSubDataPtr] $_ASMCode &= "03DE" ;add ebx,esi $_ASMCode &= "8A2B" ;mov CH,[ebx]; $_ASMCode &= "3ACD" ;CMP CL,CH $_ASMCode &= "75" & Hex(($TB - $TBJNZ),2) ;JNZ TE $TBJNZ = BinaryLen($_ASMCode) $_ASMCode &= "83C6" & Hex(1,2) ;add esi,1 $JMPTA = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPTA - $TA) + 5)) ;JMP TA ; TB: // $TB = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetStep,2) ;add edi,[esp + $OffSetStep] $JMPStartA = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStartA - $Start) + 5)) ;JMP Start ; TC: // $TC = BinaryLen($_ASMCode) $_ASMCode &= "8B4424" & Hex($OffSetRtStPtr,2) ;mov eax,[esp + $OffSetRtStPtr] $_ASMCode &= "8B00" ;mov eax,[eax] $_ASMCode &= "83F8" & Hex(0,2);CMP eax,0 $_ASMCode &= "74" & Hex(($TD - $JZTD),2) ;JZ $TD $JZTG = BinaryLen($_ASMCode) $_ASMCode &= "83C7" & Hex(1,2) ;add edi,1 $_ASMCode &= "8B4424" & Hex($OffSetRtStPtr,2) ;mov eax,[esp + $OffSetRtStPtr] $_ASMCode &= "8B00" ;mov eax,[eax] $_ASMCode &= "83C0" & Hex(1,2) ;add eax,1 $_ASMCode &= "B9" & HexBinary($DwordSize) ;mov ecx,$DwordSize $_ASMCode &= "F7E1" ;MUL ecx; $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($Malloc) ;mov eax,$Malloc $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "83C4" & Hex($DwordSize,2) ;add esp,$DwordSize $_ASMCode &= "8BD8" ;mov ebx,eax $_ASMCode &= "8B4424" & Hex($OffSetRtStPtr,2) ;mov eax,[esp + $OffSetRtStPtr] $_ASMCode &= "8B00" ;mov eax,[eax] $_ASMCode &= "B9" & HexBinary($DwordSize) ;mov ecx,$DwordSize $_ASMCode &= "F7E1" ;MUL ecx; $_ASMCode &= "50" ;push eax $_ASMCode &= "8B4424" & Hex(($OffSetRtStPtr + $DwordSize),2) ;mov eax,[esp + ($OffSetRtStPtr + $DwordSize)] $_ASMCode &= "83C0" & Hex($DwordSize,2) ;add eax,$DwordSize $_ASMCode &= "8B00" ;mov eax,[eax] $_ASMCode &= "50" ;push eax $_ASMCode &= "53" ;push ebx $_ASMCode &= "B8" & HexBinary($Mmove) ;mov eax,$Mmove $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "83C4" & Hex((($PointerSize * 2) + $DwordSize),2) ;add esp,(($PointerSize * 2) + $DwordSize) $_ASMCode &= "8B4424" & Hex($OffSetRtStPtr,2) ;mov eax,[esp + $OffSetRtStPtr] $_ASMCode &= "83C0" & Hex($DwordSize,2) ;add eax,$DwordSize $_ASMCode &= "8B00" ;mov eax,[eax] $_ASMCode &= "50" ;push eax $_ASMCode &= "B8" & HexBinary($FreeMemy) ;mov eax,$FreeMemy $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "83C4" & Hex($PointerSize,2) ;add esp,$PointerSize $_ASMCode &= "8B4424" & Hex($OffSetRtStPtr,2) ;mov eax,[esp + $OffSetRtStPtr] $_ASMCode &= "8B00" ;mov eax,[eax] $_ASMCode &= "B9" & HexBinary($DwordSize) ;mov ecx,$DwordSize $_ASMCode &= "F7E1" ;MUL ecx; $_ASMCode &= "893C03" ;mov [ebx + eax],edi $_ASMCode &= "8B4424" & Hex($OffSetRtStPtr,2) ;mov eax,[esp + $OffSetRtStPtr] $_ASMCode &= "8000" & Hex(1,2) ;add [eax],1 $_ASMCode &= "83C0" & Hex($DwordSize,2) ;add eax,$DwordSize $_ASMCode &= "8918" ;mov [eax],ebx $_ASMCode &= "83EF" & Hex(1,2) ;sub edi,1 $_ASMCode &= "8B4424" & Hex($OffSetStepTest,2) ;mov eax,[esp + $OffSetStepTest] $_ASMCode &= "83F8" & Hex(1,2);CMP eax,1 $_ASMCode &= "74" & Hex(($TF - $JZTF),2) ;JZ $TF; $JZTF = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetSubDataPtrSize,2) ;add edi,[esp + $OffSetSubDataPtrSize] $JMPStartE = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStartE - $Start) + 5)) ;JMP Start ; TF: // $TF = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetStep,2) ;add edi,[esp + $OffSetStep] $JMPStartB = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStartB - $Start) + 5)) ;JMP Start ; $TD: // $TD = BinaryLen($_ASMCode) $_ASMCode &= "83C7" & Hex(1,2) ;add edi,1 $_ASMCode &= "BB" & HexBinary($DwordSize) ;mov ebx,$DwordSize $_ASMCode &= "53" ;push ebx $_ASMCode &= "B8" & HexBinary($Malloc) ;mov eax,$Malloc $_ASMCode &= "FFD0" ;call eax $_ASMCode &= "83C4" & Hex($DwordSize,2) ;add esp,$DwordSize $_ASMCode &= "8938" ;mov [eax],edi $_ASMCode &= "8B5C24" & Hex($OffSetRtStPtr,2) ;mov ebx,[esp + $OffSetRtStPtr] $_ASMCode &= "C603" & Hex(1,2) ;mov [ebx],1 $_ASMCode &= "83C3" & Hex($DwordSize,2) ;add ebx,$DwordSize $_ASMCode &= "8903" ;mov [ebx],eax $_ASMCode &= "83EF" & Hex(1,2) ;sub edi,1 $_ASMCode &= "8B4424" & Hex($OffSetStepTest,2) ;mov eax,[esp + $OffSetStepTest] $_ASMCode &= "83F8" & Hex(1,2);CMP eax,1 $_ASMCode &= "74" & Hex(($TE - $JZTE),2) ;JZ $TE; $JZTE = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetSubDataPtrSize,2) ;add edi,[esp + $OffSetSubDataPtrSize] $JMPStartD = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStartD - $Start) + 5)) ;JMP Start ; $TE: // $TE = BinaryLen($_ASMCode) $_ASMCode &= "037C24" & Hex($OffSetStep,2) ;add edi,[esp + $OffSetStep] $JMPStartC = BinaryLen($_ASMCode) $_ASMCode &= "E9" & HexBinary(-(($JMPStartC - $Start) + 5)) ;JMP Start ; End: // $End = BinaryLen($_ASMCode) $_ASMCode &= "B8" & HexBinary(0) ;mov eax,0 $_ASMCode &= "C2" & Hex((($PointerSize * 3) + ($DwordSize * 5)),2) & Hex(0,2) ;ret (($PointerSize * 3) + ($DwordSize * 3)) & "00" // Args Size Next $Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]") DllStructSetData($Address,1,$_ASMCode) Return $Address EndFunc Func HexBinary($Value) Return Hex(Binary($Value)) EndFunc ColorSearch.au3 #include <WinAPI.au3> #include <Memory.au3> #include <Color.au3> #include <ScreenCapture.au3> #include "ASM_BinarySearch.au3" Global $itagRGBQUAD = "BYTE rgbBlue;BYTE rgbGreen;BYTE rgbRed;BYTE rgbReserved" Global $RgbSize = DllStructGetSize(DllStructCreate($itagRGBQUAD)) $hGUI = GUICreate("Color Gui",20,20,@DesktopWidth - 20,@DesktopHeight - 100) GUISetBkColor(0xFF80FF, $hGUI) GUISetState(@SW_SHOW, $hGUI) MsgBox(0,"PixelSearch","PixelSearch") $hTimer = TimerInit() $Pos1 = PixelSearch(0 , 0, @DesktopWidth, @DesktopHeight,0xFF80FF) ;0xFFFFFF $iDiff1 = TimerDiff($hTimer) MsgBox(0,"nPixelSearch","nPixelSearch") $hTimer = TimerInit() $Pos2 = nPixelSearch(0, 0, @DesktopWidth, @DesktopHeight,0xFF80FF) ;0xFFFFFF $iDiff2 = TimerDiff($hTimer) if IsArray($Pos1) And IsArray($Pos2) Then $Text1 = String($Pos1[0] & " " & $Pos1[1] & " PixelSearch Time ==> " & $iDiff1) $Text2 = String($Pos2[0] & " " & $Pos2[1] & " nPixelSearch Time ==> " & $iDiff2) MsgBox(0,"PixelSearch",$Text1 & @CRLF & $Text2) EndIf MsgBox(0,"nPixelSearch","nPixelSearch") $hTimer = TimerInit() $Pos2 = nPixelSearch(0, 0, @DesktopWidth, @DesktopHeight,0xFF80FF) ;0xFFFFFF $iDiff2 = TimerDiff($hTimer) MsgBox(0,"PixelSearch","PixelSearch") $hTimer = TimerInit() $Pos1 = PixelSearch(0 , 0, @DesktopWidth, @DesktopHeight,0xFF80FF) ;0xFFFFFF $iDiff1 = TimerDiff($hTimer) if IsArray($Pos1) And IsArray($Pos2) Then $Text1 = String($Pos1[0] & " " & $Pos1[1] & " PixelSearch Time ==> " & $iDiff1) $Text2 = String($Pos2[0] & " " & $Pos2[1] & " nPixelSearch Time ==> " & $iDiff2) MsgBox(0,"PixelSearch",$Text1 & @CRLF & $Text2) EndIf Func nPixelSearch($left = 0,$top = 0,$right = -1,$bottom = -1,$Color = 0,$bCursor = False) Local $hBmp = _ScreenCapture_Capture("",$left,$top,$right,$bottom,$bCursor) if Not($hBmp) Then Return SetError(1,0,0) Local $aCoord = BmpSearchColor($hBmp,$Color) _WinAPI_DeleteObject($hBmp) if Not IsArray($aCoord) Then Return SetError(2,0,0) Return $aCoord EndFunc Func BmpSearchColor($hBmp,$Color) Local $BitsStruct = GetBitsStruct($hBmp) if @error Then Return SetError(1,0,0) Local $BitsStringPtr = DllStructGetPtr($BitsStruct,"RGBQUAD") Local $BitsSize = DllStructGetData($BitsStruct,"SIZE") Local $biWidth = DllStructGetData($BitsStruct,"WIDTH") Local $biHeight = DllStructGetData($BitsStruct,"HEIGHT") Local $iColor = DllStructCreate("BYTE RGB[3]") DllStructSetData($iColor,1,$Color) $iColorPtr = DllStructGetPtr($iColor) $FindPosition = BinarySearch($BitsStringPtr,$iColorPtr,$BitsSize,3,4) ;$SubDataPtrSize = 3 // $Step = $RgbSize = 4 // ; $Step Is Loop Step if @error Then Return SetError(2,0,0) Local $OffSetPosition = $FindPosition - 1 $OffSetPosition /= $RgbSize ; $RgbSize = 4 /// 4byte = 1pixel $X = Mod($OffSetPosition,$biWidth) ; Get left $Y = (($OffSetPosition - $X) / $biWidth) ; Get top Local $aCoord[2] $aCoord[0] = $X $aCoord[1] = $Y Return $aCoord EndFunc Func GetBitsStruct( $hBmp , $L = -1 , $T = -1 , $W = -1 , $H = -1 ) Local $SizeArray = GetImageSize($hBmp) if @error Then Return SetError(1,0,0) Local $biWidth = $SizeArray[0] Local $biHeight = $SizeArray[1] if ($L < 0) Then $L = 0 if ($T < 0) Then $T = 0 if ($W < 0) Then $W = ($biWidth - $L) if ($H < 0) Then $H = ($biHeight - $T) if ($L >= $biWidth Or (($L + $W) > $biWidth)) Then $L = 0 if ($T >= $biHeight Or (($T + $H) > $biHeight)) Then $T = 0 Local $vRgbSize = ($RgbSize * ($biWidth * $biHeight)) Local $vStBits = DllStructCreate("INT WIDTH;INT HEIGHT;INT SIZE;BYTE RGBQUAD[" & ($vRgbSize) & "]") DllStructSetData($vStBits ,"WIDTH",$biWidth) DllStructSetData($vStBits,"HEIGHT",$biHeight) DllStructSetData($vStBits,"SIZE",$vRgbSize) GetBitmapBits($hBmp,DllStructGetPtr($vStBits,"RGBQUAD"),$vRgbSize) if @error Then Return SetError(2,0,0) if ($L = 0 And $T = 0 And $W = $biWidth And $H = $biHeight) Then Return $vStBits Local $nRgbSize = ($RgbSize * ($W * $H)) , $ColusCount = $W Local $nStBits = DllStructCreate("INT WIDTH;INT HEIGHT;INT SIZE;BYTE RGBQUAD[" & ($nRgbSize) & "]") DllStructSetData($nStBits ,"WIDTH",$W) DllStructSetData($nStBits,"HEIGHT",$H) DllStructSetData($nStBits,"SIZE",$nRgbSize) For $RowIndex = 0 To ($H - 1) Local $nStBPtr = GetPointerAtRowPos($nStBits,$RowIndex) ; Move Ptr To First BYTE Of Row => $RowIndex Local $vStBPtr = GetPointerAtRowPos($vStBits,($RowIndex + $T)) + ($L * $RgbSize) ; Move Ptr To First BYTE Of Row => ($RowIndex + $T) ; + ($L * $RgbSize) Move PointerAtRowPos From left to right + ($L * $RgbSize) _MemMoveMemory($vStBPtr,$nStBPtr,($RgbSize * ($ColusCount - 1))) ;Size Of One Row In $nStBPtr Next Return $nStBits EndFunc Func GetBitmapBits($hbmp,$lpvBits,$cbBuffer) $BytesNu = DllCall("Gdi32.dll","LONG","GetBitmapBits","ptr" _ ,$hbmp,"LONG",$cbBuffer,"ptr",$lpvBits) if @error Or Not($BytesNu[0]) Then SetError(1,0,0) Return SetError(0,0,$BytesNu[0]) EndFunc Func GetPointerAtRowPos($StBits,$RowIndex) if Not IsDllStruct($StBits) Then Return SetError(1,0,0) Local $ColusCount = DllStructGetData($StBits,"WIDTH") Local $RowsCount = DllStructGetData($StBits,"HEIGHT") If ($RowIndex < 0 Or $RowIndex > ($RowsCount -1)) Then Return SetError(2,0,0) Local $StBitsPtr = DllStructGetPtr($StBits,"RGBQUAD") Local $PointerAtRowPos = ($StBitsPtr + (($RowIndex * $ColusCount) * $RgbSize)) Return $PointerAtRowPos EndFunc Func GetImageSize($hBmp) Local $ntagBITMAPINFO = "DWORD biSize;LONG biWidth;LONG biHeight;USHORT biPlanes;" & _ "USHORT biBitCount;DWORD biCompression;DWORD biSizeImage;LONG biXPelsPerMeter;" & _ "LONG biYPelsPerMeter;DWORD biClrUsed;DWORD biClrImportant;BYTE RGBQUAD[4]" Local $vBITMAPINFO = DllStructCreate($ntagBITMAPINFO) DllStructSetData($vBITMAPINFO,"biSize",(DllStructGetSize($vBITMAPINFO) - $RgbSize)) Local $hDC = _WinAPI_CreateCompatibleDC(0) if Not($hDC) Then _WinAPI_DeleteDC($hDC) Return SetError(1,0,0) EndIf $Return = _WinAPI_GetDIBits($hDC,$hBmp,0,0,0,DllStructGetPtr($vBITMAPINFO),0) if Not($Return) Then _WinAPI_DeleteDC($hDC) Return SetError(2,0,0) EndIf _WinAPI_DeleteDC($hDC) Local $biWidth = DllStructGetData($vBITMAPINFO,"biWidth") Local $biHeight = DllStructGetData($vBITMAPINFO,"biHeight") Local $SizeArray[2] $SizeArray[0] = $biWidth $SizeArray[1] = $biHeight Return $SizeArray EndFunc CallbackBinarySearch.au3 #include <WinAPI.au3> #include <Memory.au3> #include <Color.au3> #include <ScreenCapture.au3> #include "ASM_BinarySearch.au3" $Text = "" $SubText = "Autoit" For $i = 1 To 10000 $Text &= "1" Next $Text &= "Autoit" & "Autoit" & "Autoit" $Len1 = StringLen($Text) $Len2 = StringLen($SubText) $St1 = DllStructCreate("CHAR[" & $Len1 & "]") DllStructSetData($St1,1,$Text) $Ptr1 = DllStructGetPtr($St1) $St2 = DllStructCreate("CHAR[" & $Len2 & "]") DllStructSetData($St2,1,$SubText) $Ptr2 = DllStructGetPtr($St2) $Return = CallbackBinarySearch($Ptr1,$Ptr2,"CallbackFunc",$Len1,$Len2) MsgBox(0,"Return",$Return) Func CallbackFunc($FindPosition,$OffSetPosition,$DataPtr,$SubDataPtr,$DataPtrSize,$SubDataPtrSize) MsgBox(0,"OffSetPosition = " & $OffSetPosition ,"FindPosition = " & $FindPosition) Return 1 ;return ;0 ; Stop ;Other Ways : Continue EndFunc XBinarySearch.au3 #include <WinAPI.au3> #include <Memory.au3> #include <Color.au3> #include <ScreenCapture.au3> #include "ASM_BinarySearch.au3" $Text = "" $SubText = "Autoit" For $i = 1 To 10000 $Text &= "1" Next $Text &= "Autoit" & "Autoit" & "Autoit" $Len1 = StringLen($Text) $Len2 = StringLen($SubText) $St1 = DllStructCreate("CHAR[" & $Len1 & "]") DllStructSetData($St1,1,$Text) $Ptr1 = DllStructGetPtr($St1) $St2 = DllStructCreate("CHAR[" & $Len2 & "]") DllStructSetData($St2,1,$SubText) $Ptr2 = DllStructGetPtr($St2) $ReturnStruct = XBinarySearch($Ptr1,$Ptr2,$Len1,$Len2) For $i = 1 To DllStructGetData($ReturnStruct,"ArrayCount") $FindPosition = DllStructGetData($ReturnStruct,"PositionArray",$i) MsgBox(0,"Msg","FindPosition = " & $FindPosition) Next
    1 point
×
×
  • Create New...