Jump to content

smashly

Active Members
  • Posts

    1,612
  • Joined

  • Last visited

Profile Information

  • Member Title

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

smashly's Achievements

Universalist

Universalist (7/7)

14

Reputation

  1. Thank you for taking the time to read my post and or any feedback provided. I found a function that hashes an input string. But even simple bit operations always have me lost even in AutoIt native code. Most parts of the algorithm function seem easy enough translate. But the starting bit #define has me lost in how to translate it. I gather the hashing function was used in asm (I'm sorta clueless as you can tell). Most cases I can translate what I need from MSDN for native win api functions to AutoIt. But I don't have an easy reference to compare or to translate the code below. #define ROR(val, shift) ((val << (0x20 - shift)) | (val >> shift)) #define ROL(val, shift) ((val >> (0x20 - shift)) | (val << shift)) #define INIT_VAL 0xABCDEFAB unsigned long hash32(char *str,unsigned long init) { unsigned long i, m, len, c; unsigned long k[3]; len = strlen(str); k[2] = k[1] = k[0] = init + len + 0xDEADBEEF; if ( len ) { if ( len > 12 ) { m = ((unsigned long long)(len - 13) * 0xAAAAAAAB >> 35) + 1; while ( m-- ) { for ( i = 0; i < 12; i++ ) { c = str[i]; if (c - 0x41 <= 0x19) c += 0x20; k[(11 - i) / 4] += c << ((i % 4) * 8); } k[2] = (k[2] - k[0]) ^ ROL(k[0], 4); k[0] += k[1]; k[1] = (k[1] - k[2]) ^ ROL(k[2], 6); k[2] += k[0]; k[0] = (k[0] - k[1]) ^ ROL(k[1], 8); k[1] += k[2]; k[2] = (k[2] - k[0]) ^ ROL(k[0], 16); k[0] += k[1]; k[1] = (k[1] - k[2]) ^ ROR(k[2], 13); k[2] += k[0]; k[0] = (k[0] - k[1]) ^ ROL(k[1], 4); k[1] += k[2]; str += 12; len -= 12; } } for ( ; len > 0; len-- ) { c = str[len - 1]; if (c - 0x41 <= 0x19) c += 0x20; k[(11 - (len - 1)) / 4] += c << (( (len - 1) % 4) * 8); } k[0] = (k[0] ^ k[1]) - ROL(k[1], 14); k[2] = (k[2] ^ k[0]) - ROL(k[0], 11); k[1] = (k[1] ^ k[2]) - ROR(k[2], 7); k[0] = (k[0] ^ k[1]) - ROL(k[1], 16); k[2] = (k[2] ^ k[0]) - ROL(k[0], 4); k[1] = (k[1] ^ k[2]) - ROL(k[2], 14); k[0] = (k[0] ^ k[1]) - ROR(k[1], 8); } return k[0]; }
  2. Hi, Thank You for taking the time to read my post. Could someone please post a brief example of using StringRegExpReplace() to replace a word at a specific count. For example I'm trying to replace only the 2nd instance of the word "Dog" with "Turtle" in the string below. $sStr = "CatDogMouseBirdHorseDogBirdHorseMouseBirdDogAnt"
  3. Hi,#include <GDIPlus.au3> #include <WinAPI.au3> Global $sSaveImage = @ScriptDir & "Colors.jpg" Global $iImageSize = 200, $iSquareSize = 10 Global $hBMP, $hImage, $hGraphic, $hBrush, $iX = 0, $iY = 0 _GDIPlus_Startup() $hBMP = _WinAPI_CreateBitmap($iImageSize, $iImageSize, 1, 32) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) $hBrush = _GDIPlus_BrushCreateSolid() For $i = 1 To ($iImageSize * $iImageSize) Step $iSquareSize _GDIPlus_BrushSetSolidColor($hBrush, Random(0xFF000000, 0xFFFFFFFF, 1)) _GDIPlus_GraphicsFillRect($hGraphic, $iX, $iY, $iSquareSize, $iSquareSize, $hBrush) If $iX >= $iImageSize Then $iX = 0 $iY += $iSquareSize Else $iX += $iSquareSize EndIf Next _GDIPlus_ImageSaveToFile($hImage, $sSaveImage) _WinAPI_DeleteObject($hBMP) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() If FileExists($sSaveImage) Then ShellExecute($sSaveImage)
  4. Hi, #include <GUIConstantsEx.au3> $Form1 = GUICreate("Hung", 131, 273, 192, 114) $Label1 = GUICtrlCreateLabel("Combo Retarget Loot", 16, 16, 105, 17) $Button1 = GUICtrlCreateButton("ComRe", 16, 40, 99, 25) $Label2 = GUICtrlCreateLabel("Combo Loot", 32, 80, 61, 17) $Label3 = GUICtrlCreateLabel("Bm3 Retarget Loot", 16, 152, 93, 17) $Button2 = GUICtrlCreateButton("ComLo", 16, 112, 99, 25) $Button3 = GUICtrlCreateButton("Bm3Re", 16, 176, 99, 25) $Label4 = GUICtrlCreateLabel("Bm3 Loot", 40, 216, 49, 17) $Button4 = GUICtrlCreateButton("Bm3Lo", 16, 240, 99, 25) GUISetState(@SW_SHOW, $Form1) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 If GUICtrlRead($Button1) = "ComRe" Then AdlibRegister("ComRe", 500) GUICtrlSetData($Button1, "STOP") Else AdlibUnRegister("ComRe") GUICtrlSetData($Button1, "ComRe") EndIf EndSwitch WEnd Func ComRe() Send("5") Send("z") Send("0") EndFunc ;==>ComRe Cheers
  5. Hi, Quote from help file if using 64bit os eg:#include <GuiConstantsEx.au3> _Main() Func _Main() Local $sHKLM, $aValue, $sReturn $sHKLM = "HKLMSOFTWARESMUDO" If Not StringInStr(@OSArch, "X86") Then $sHKLM = StringReplace($sHKLM, "HKLM", "HKLM64") $aValue = StringSplit("AssetTag|ClientVersion|ServerVersion|Division|Hardware|Language", "|", 2) GUICreate("Support Information", 300, 350, (@DesktopWidth - 300) / 2, (@DesktopHeight - 350) / 2) For $i = 0 To UBound($aValue) - 1 $sReturn = RegRead($sHKLM, $aValue[$i]) If StringInStr($aValue[$i], "Language") Then $sReturn = StringLeft($sReturn, StringInStr($sReturn, Chr(32))) GUICtrlCreateLabel($aValue[$i] & ":" & @TAB & $sReturn, 10, ($i * 20) + 10, 280, 20) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSwitch WEnd EndFunc ;==>_Main
  6. The game rules are bs even if they are simple and needed. My opinion is irrelevant and it's not my given right to be a member of the forums, it's a privilege which can be revoked at any time. Yeah I'm an "enthusiastically stupid user wishes to challenge the status quo", so revoke my privilege permanently please. As I can't beat it and I don't want to bow to it and I'm definitely not joining it. Farewell.
  7. Hi, I know it's not what you want to hear, but I think you'll have probs with members jumping on you due to it's game related. I'm aware its not to automate a game, but the rules have really got out of hand when it it comes to anything game related. What makes it worse is members snowball on the rules until the topic gets locked. It all turns into a baited flame fest, usually by the op being baited until he/she snaps then and then baiter is made out to be the one in the right due to the op topic was borderline to start with and the baiter has been here longer. If you can avoid mentioning a third party game in your topic, and make your code generic so it doesn't look like it's to do with a third party game you'll probably get away with help and answers without the whole above scenario happening. Good luck
  8. Hi, Thank you for sharing. You could make your scripts into 1 function. #RequireAdmin $iPreviousValue = _Toggle_UAC() If Not @error Then ConsoleWrite("-> _Toggle_UAC() @error: " & @error & @LF) ConsoleWrite("-> Previous UAC Value: " & $iPreviousValue & @LF) ConsoleWrite("-> Current UAC Value: " & _Toggle_UAC(-3) & @LF) Else ConsoleWrite("-> _Toggle_UAC() @error: " & @error & @LF) EndIf ; #FUNCTION# ==================================================================================================================== ; Name...........: _Toggle_UAC ; Description ...: Toggle or Force UAC Off or On or Query UAC current setting without changing. ; Syntax.........: _Toggle_UAC([$iValue = -2]) ; Parameters ....: $iValue - [Optional] Default is -2, see below for explanations and other values. ; -1 = Toggle the current UAC to the oposite of what it is currently. ; If UAC is curently disabled then It will be enabled using 1, ; Prompt the Consent Admin to enter his or her user name and password ; (or another valid admin) when an operation requires elevation of privilege. ; -2 = Toggle the current UAC to the oposite of what it is currently. ; If UAC is curently disabled then It will be enabled using 2, ; Admin Approval Mode to select either "Permit" or "Deny" an operation that requires elevation of privilege. ; -3 = Return the current UAC value found in the registry, don't change anything. ; 0 = Set UAC to 0 Allow the Consent Admin to perform an operation that requires elevation without consent or credentials. ; 1 = Set UAC to 1 Prompt the Consent Admin to enter his or her user name and password ; (or another valid admin) when an operation requires elevation of privilege. ; 2 = Set UAC to 2 Admin Approval Mode to select either "Permit" or "Deny" an operation that requires elevation of privilege. ; Return values .: Success - Value that was found in the registry before changinging and @error 0, Return could be as follows: ; 0 = UAC was disabled ; 1 = UAC was Prompt the Consent Admin to enter his or her user name and password ; 2 = UAC was Admin Approval Mode to select either "Permit" or "Deny" ; Failure - -1 and @error ; @error 1 = Current user is not Admin ; @error 2 = OS is not Vista or Win 7 ; @error 3 = Reading the the registry key failed, check @extended for the returned error from RegRead() as to why it failed. ; @error 4 = Writing the registry keyname value failed, check @extended for the returned error from RegWrite() as to why it failed. ; @error 5 = $iValue parameter not valid ; Author ........: AlienStar ; Modified.......: smashly ; Remarks .......: ; Related .......: ; Link ..........: http://msdn.microsoft.com/en-us/library/cc232761%28v=prot.10%29.aspx ; Example .......: ; =============================================================================================================================== Func _Toggle_UAC($iValue = -2) If Not IsAdmin() Then Return SetError(1, 0, -1) If Not StringInStr("WIN_VISTA|WIN_7", @OSVersion) Then Return SetError(2, 0, -1) Local $sHKLM, $sName, $iReadValue, $iNewValue $sHKLM = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem" $sName = "ConsentPromptBehaviorAdmin" $iReadValue = RegRead($sHKLM, $sName) If @error Then Return SetError(3, @error, -1) Switch $iValue Case -1, -2 Switch $iReadValue Case 0 $iNewValue = Abs($iValue) Case Else $iNewValue = 0 EndSwitch Case -3 Return SetError(0, 0, $iReadValue) Case 0, 1, 2 $iNewValue = $iValue Case Else Return SetError(5, 0, -1) EndSwitch RegWrite($sHKLM, $sName, "REG_DWORD", $iNewValue) If @error Then Return SetError(4, @error, -1) Return SetError(0, 0, $iReadValue) EndFunc ;==>_Toggle_UACI haven't tried the code I modded of yours, but it's just to give you an idea of what I mean. Cheers
  9. Hi, Sorry to raise a dead dog, but some one pm'd for a working link so I just updated the the first post with a new link. Not sure how long it'll last or what the host is like. But help yourselves Cheers
  10. Yes, but you'd need to write and call the mixer api functions found in Winmm.dll. You can check out the mixer functions at MSDN: http://msdn.microsoft.com/en-us/library/dd756704%28v=VS.85%29.aspx I'm pretty sure someone may have already written most the functions in autoit, but I don't have a link to the thread sorry.
  11. Hi, That's a nice Grey Scale example taietel. Another way if your not after grey scale and you still want some color but a grey or any other color overlay. #include <GDIPlus.au3> Global $sLoadImage, $sFinalImage, $hImage, $hGraphics, $hBrush _GDIPlus_Startup() $sLoadImage = @ScriptDir&"\test.jpg" $sFinalImage = @ScriptDir&"\test_grey.jpg" $hImage = _GDIPlus_ImageLoadFromFile($sLoadImage) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) $hBrush = _GDIPlus_BrushCreateSolid(0xC0C0C0C0) ; Grey _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage), $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageSaveToFile($hImage, $sFinalImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() ShellExecute($sFinalImage) Cheers
  12. Hi, Use the flag parameter in control send. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Global $hGui, $iInput, $iButton ShellExecute("notepad.exe") $hGui = GUICreate("", 217, 157, 192, 124, -1, $WS_EX_TOPMOST) $iInput = GUICtrlCreateInput("^^2233^^", 50, 65, 121, 21, $ES_UPPERCASE) $iButton = GUICtrlCreateButton("Send", 60, 96, 97, 20) GUISetState(@SW_SHOW, $hGui) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $iButton ControlSend("[CLASS:Notepad]", "", "[CLASSNN:Edit1]", GUICtrlRead($iInput) & @CR, 1); flag 1, keys are sent raw. GUICtrlSetData($iInput, "") EndSwitch WEnd
  13. Hi, Your better off using PsaltyDS version, since mac address is hex value. In your mock up mac address string you have 0t-z4, a mac address will not have t or z. mac address will only contain 0 to 9 and A to F. Hence PsaltyDS using [:xdigit:] for a search pattern is the better method. Global $sBogusMacAddress, $sMacAddress $sBogusMacAddress = "77.10.119.232 - 255.255.254.0 - 00-15-46-5b-0t-z4 -27/09/2011 8:30:52 AM -D- PC0005.test.local" MsgBox(64, "$sBogusMacAddress", _MacAddressFromString($sBogusMacAddress)) $sMacAddress = "77.10.119.232 - 255.255.254.0 - 00-15-46-5b-0F-F4 -27/09/2011 8:30:52 AM -D- PC0005.test.local" MsgBox(64, "$sMacAddress", _MacAddressFromString($sMacAddress)) Func _MacAddressFromString($sString) Local $aSRE $aSRE = StringRegExp($sString, "[[:xdigit:]]{2}-[[:xdigit:]]{2}-[[:xdigit:]]{2}-[[:xdigit:]]{2}-[[:xdigit:]]{2}-[[:xdigit:]]{2}", 1) If IsArray($aSRE) Then Return "Found Mac Address: " & $aSRE[0] Return "No Mac Address found." EndFunc Cheers
×
×
  • Create New...