Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/29/2019 in all areas

  1. mmm I see. Check this example: #include <WinAPICom.au3> #include <Process.au3> #include <Array.au3> Opt("MustDeclareVars", 1) Global Const $CLSCTX_INPROC_SERVER = 0x01 + 0x02 + 0x04 + 0x10 Global Enum $eRender, $eCapture, $eAll, $EDataFlow_enum_count Global Enum $AudioSessionStateInactive, $AudioSessionStateActive, $AudioSessionStateExpired Global Const $eMultimedia = 1 Global Const $sCLSID_MMDeviceEnumerator = "{BCDE0395-E52F-467C-8E3D-C4579291692E}" Global Const $sIID_IMMDeviceEnumerator = "{A95664D2-9614-4F35-A746-DE8DB63617E6}" Global Const $sTagIMMDeviceEnumerator = _ "EnumAudioEndpoints hresult(int;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(int;int;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr)" Global Const $sIID_IAudioMeterInformation = "{C02216F6-8C67-4B5B-9D00-D008E73E0064}" Global Const $sTagIAudioMeterInformation = "GetPeakValue hresult(float*);" & _ "GetMeteringChannelCount hresult(dword*);" & _ "GetChannelsPeakValues hresult(dword;float*);" & _ "QueryHardwareSupport hresult(dword*);" Global Const $sIID_IMMDevice = "{D666063F-1587-4E43-81F1-B948E807363F}" Global Const $sTagIMMDevice = _ "Activate hresult(clsid;dword;ptr;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(wstr*);" & _ "GetState hresult(dword*)" Global Const $sIID_IAudioSessionManager2 = "{77aa99a0-1bd6-484f-8bc7-2c654c9a9b6f}" Global Const $sTagIAudioSessionManager = "GetAudioSessionControl hresult(ptr;dword;ptr*);" & _ "GetSimpleAudioVolume hresult(ptr;dword;ptr*);" Global Const $sTagIAudioSessionManager2 = $sTagIAudioSessionManager & "GetSessionEnumerator hresult(ptr*);" & _ "RegisterSessionNotification hresult(ptr);" & _ "UnregisterSessionNotification hresult(ptr);" & _ "RegisterDuckNotification hresult(wstr;ptr);" & _ "UnregisterDuckNotification hresult(ptr)" Global Const $sIID_IAudioSessionEnumerator = "{e2f5bb11-0570-40ca-acdd-3aa01277dee8}" Global Const $sTagIAudioSessionEnumerator = "GetCount hresult(int*);GetSession hresult(int;ptr*)" Global Const $sIID_IAudioSessionControl = "{f4b1a599-7266-4319-a8ca-e70acb11e8cd}" Global Const $sTagIAudioSessionControl = "GetState hresult(int*);GetDisplayName hresult(wstr*);" & _ "SetDisplayName hresult(wstr);GetIconPath hresult(wstr*);" & _ "SetIconPath hresult(wstr;ptr);GetGroupingParam hresult(ptr*);" & _ "SetGroupingParam hresult(ptr;ptr);RegisterAudioSessionNotification hresult(ptr);" & _ "UnregisterAudioSessionNotification hresult(ptr);" Global Const $sIID_IAudioSessionControl2 = "{bfb7ff88-7239-4fc9-8fa2-07c950be9c6d}" Global Const $sTagIAudioSessionControl2 = $sTagIAudioSessionControl & "GetSessionIdentifier hresult(wstr*);" & _ "GetSessionInstanceIdentifier hresult(wstr*);" & _ "GetProcessId hresult(dword*);IsSystemSoundsSession hresult();" & _ "SetDuckingPreferences hresult(bool);" Global $g_bExit = Not False Global $g_bIsRunning = False ;Program To start and Program to Close Global $_gAppToRun = "notepad.exe" Global $g_AppToFinish = "notepad.exe" HotKeySet("{ESC}", "_Exit") _WinAPI_CoInitialize() Local $aApp = 0 While $g_bExit $aApp = _GetAppsPlayingSound() _RunCloseAppIfSoundPlayingByProcessName("chrome.exe",$aApp) Sleep(100) WEnd _WinAPI_CoUninitialize() Func _RunCloseAppIfSoundPlayingByProcessName($sProcessName, $aApp) If Not $g_bIsRunning Then If _ArraySearch($aApp, $sProcessName)>-1 Then ShellExecute($_gAppToRun) $g_bIsRunning = True EndIf EndIf If $g_bIsRunning Then If _ArraySearch($aApp, $sProcessName)=-1 Then ProcessClose($g_AppToFinish) $g_bIsRunning = False EndIf EndIf EndFunc ;==>_RunCloseAppIfSoundPlayingByProcessName Func _Exit() $g_bExit = False EndFunc ;==>_Exit Func _GetAppsPlayingSound() Local $pIMMDevice = 0 Local $oMMDevice = 0 Local $pIAudioSessionManager2 = 0 Local $oIAudioSessionManager2 = 0 Local $pIAudioSessionEnumerator = 0 Local $oIAudioSessionEnumerator = 0 Local $nSessions = 0 Local $oMMDeviceEnumerator = 0 Local $aApp[0] Local $pIAudioSessionControl2 = 0 Local $oIAudioSessionControl2 = 0 Local $oIAudioMeterInformation = 0 Local $ProcessID = 0 Local $fPeakValue = 0 Local $iState = 0 Local $iVolume = 0 Local $oErrorHandler = 0 $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") $oMMDeviceEnumerator = ObjCreateInterface($sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $sTagIMMDeviceEnumerator) If @error Then Return $aApp If SUCCEEDED($oMMDeviceEnumerator.GetDefaultAudioEndpoint($eRender, $eMultimedia, $pIMMDevice)) Then ;eRender $oMMDevice = ObjCreateInterface($pIMMDevice, $sIID_IMMDevice, $sTagIMMDevice) $oMMDevice.Activate($sIID_IAudioSessionManager2, $CLSCTX_INPROC_SERVER, 0, $pIAudioSessionManager2) $oIAudioSessionManager2 = ObjCreateInterface($pIAudioSessionManager2, $sIID_IAudioSessionManager2, $sTagIAudioSessionManager2) $oIAudioSessionManager2.GetSessionEnumerator($pIAudioSessionEnumerator) $oIAudioSessionEnumerator = ObjCreateInterface($pIAudioSessionEnumerator, $sIID_IAudioSessionEnumerator, $sTagIAudioSessionEnumerator) $oIAudioSessionEnumerator.GetCount($nSessions) For $i = 0 To $nSessions - 1 $oIAudioSessionEnumerator.GetSession($i, $pIAudioSessionControl2) $oIAudioSessionControl2 = ObjCreateInterface($pIAudioSessionControl2, $sIID_IAudioSessionControl2, $sTagIAudioSessionControl2) $oIAudioSessionControl2.GetState($iState) If $iState = $AudioSessionStateActive Then $oIAudioSessionControl2.GetProcessId($ProcessID) $oIAudioMeterInformation = ObjCreateInterface($pIAudioSessionControl2, $sIID_IAudioMeterInformation, $sTagIAudioMeterInformation) $oIAudioSessionControl2.AddRef $oIAudioMeterInformation.GetPeakValue($fPeakValue) If $fPeakValue > 0 Then ReDim $aApp[UBound($aApp) + 1][2] $aApp[UBound($aApp) - 1][0] = _ProcessGetName($ProcessID) $aApp[UBound($aApp) - 1][1] = $fPeakValue EndIf EndIf $fPeakValue = 0 $iState = 0 $ProcessID = 0 $oIAudioMeterInformation = 0 $oIAudioSessionControl2 = 0 Next $oIAudioSessionEnumerator = 0 $oIAudioSessionManager2 = 0 $oMMDevice = 0 $oMMDeviceEnumerator = 0 If UBound($aApp) = 0 Then $aApp = 0 Return $aApp Else Return $aApp EndIf EndFunc ;==>_GetAppsPlayingSound Func SUCCEEDED($hr) Return ($hr >= 0) EndFunc ;==>SUCCEEDED ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc Saludos
    2 points
  2. Hello. You said you have broken your head trying to do it but as far I can see the code is exactly as I wrote it years ago... Saludos
    2 points
  3. Thanks Nine, it works perfectly, also thanks Nagasa
    1 point
  4. Subz

    RegEnumVal Error -1 :(

    Maybe something like: #include <Array.au3> Global $aRegRun[0][3] _RegRunValues("HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run") _RegRunValues("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run") _RegRunValues("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Run") _ArrayDisplay($aRegRun) Func _RegRunValues($cKey) Local $i = 1, $sSubKey While 1 $sSubKey = RegEnumVal($cKey, $i) If @error Then ExitLoop _ArrayAdd($aRegRun, $cKey & "|" & $sSubKey & "|" & RegRead($cKey, $sSubKey)) $i += 1 WEnd EndFunc
    1 point
  5. Nine

    combinations generator

    Here to start you up : Global $Line = 0 HotKeySet ("[ESC]","_Exit") FileDelete ("Test.txt") Local $Set[11][3] = [[0,2,4],[5,9,7],[5,9,7],[0,2,4],[1,3,""],[0,2,4],[1,3,""],[5,9,7],[6,8,""],[5,9,7],[0,2,4]] Combi("", -1, Ubound($Set,1)) Func Combi($Str, $Ind, $MaxLen) if StringLen($Str) = $MaxLen Then $Line += 1 FileWriteLine("Test.txt", "Line " & StringFormat("%05i", $Line) & " : Combination = " & $Str) Return EndIf $Ind += 1 For $j = 0 to Ubound ($Set,2) - ($Set[$Ind][2]=""?2:1) Combi($Str & $Set[$Ind][$j], $Ind, $MaxLen) Next EndFunc Func _Exit () Exit EndFunc Recursion is a nice thing, but it is not the fastest. Maybe adding a progress bar. And using file handle will greatly increase the speed...
    1 point
  6. Jos

    Hold Key and release

    No you don't and I asked nicely not to, but the fact remain you simply report or move on without you needing to ask. So we are done here. Please don't waste my time and the space here when you can't be honest. *click* Jos
    1 point
  7. Hence you don't need it.
    1 point
  8. No problem, I'd suggest reading the Autoit help file thoroughly, it has a lot of information and useful examples.
    1 point
  9. I found this article and enjoyed it so much I had play with some code since the numbers are small enough. https://thatsmaths.com/2016/08/11/a-toy-example-of-rsa-encryption/ Standard Encryption's vs RSA Encryption (Public Key Encryption) Fundamental Differences If you read that and couldn't immediately clarify the difference then let me blow your mind because its simple: STANDARD ENCRYPTION'S: ORIGINAL_DATA + Password(or KEY) = Encrypted DATA Then to decrypt -> Encrypted DATA + (SAME Password(or SAME KEY)) = ORIGINAL_DATA RSA: ORIGINAL_DATA + Password(or PUBLIC_KEY) = Encrypted DATA Then to decrypt -> Encrypted DATA + (DIFFERENT Password(or PRIVATE_KEY)) = ORIGINAL_DATA Are we all caught up? Did the colors help? I think they did That's crazy right? Don't answer. It is. And crazier its used EVERY TIME we make a secure connection to a server over the internet. But here's the craziest part to me that I recently got clarity on from the toy example and that is the simplicity of this very very very very important algorithm that has yet to be cracked (fingers crossed): Mod($vData ^ $key, $n) So ya. That's it. That's the magic algorithm. 3 values. Oh and $n is also a shared known value that will be in the certificate with the public key that your browser reads when it makes a connection: That's just mind blowing to me so couldn't resist getting something going in AUT. After playing with this code, I got a much better understanding of how its not just that algorithm that makes this whole thing possible. The numbers that we pick to form the public key and n are just as important and also how important it is to be random! Let me know if you have any problems. Enjoy! #include <array.au3> _Toy_RSA_Example() ;https://thatsmaths.com/2016/08/11/a-toy-example-of-rsa-encryption/ Func _Toy_RSA_Example() Local $p, $q, $n, $nT, $e, $d Local $aPublicKeys, $aCrypt, $sDecrypt, $sMsg ;Pick two random primes (they will be between 1000-10000) $p = _GetRandomPrime() $q = _GetRandomPrime() $sMsg = 'p= %i \t\t| Prime 1 - [NOT SHARED!]\nq= %i \t\t| Prime 2 - [NOT SHARED!]\n' ;Calculate lowest common multiple $nT = _LCM($p - 1, $q - 1) $sMsg &= 'nT= %i \t| _LCM(p - 1,q - 1) - [NOT SHARED!]\n' ;Calculate n. This is a shared number $n = $p * $q $sMsg &= 'n= %i \t| p * q - [Shared]\n' ;Get a small random list of possible public keys to pick from. Only searching for 100ms $aPublicKeys = _GetPublicKeys($nT) _ArrayDisplay($aPublicKeys, "Possible Public Keys Found") ;Pick a random public (encryption) key from array $e = $aPublicKeys[Random(1, $aPublicKeys[0], 1)] $sMsg &= 'e= %i \t| Public (Encryption) Key - [Shared]\n' ;Generate our private (decryption) key $d = _GetPrivateKey($e, $nT) $sMsg &= 'd= %i \t| Private (Decryption) Key - [NOT SHARED!]\n' ;format our msg (rsa details) to encrypt $sMsg = StringFormat($sMsg, $p, $q, $nT, $n, $e, $d) ;encrypt message $aCrypt = _RSA($sMsg, $e, $n) _ArrayDisplay($aCrypt, 'Encrypted RSA messsage') ;Decrypt array back $sDecrypt = _RSA($aCrypt, $d, $n) MsgBox(0, 'Decrypted RSA messsage', $sDecrypt) EndFunc ;==>_Toy_RSA_Example ;Function will perfrom Mod($v ^ $key, $n) on each char/element. ;Excepts Arrays or Strings. If input is array a string is returned and vice versa. Func _RSA($vDat, $key, $n) Local $bIsStr = IsString($vDat) If $bIsStr Then $vDat = StringToASCIIArray($vDat) For $i = 0 To UBound($vDat) - 1 $vDat[$i] = _Modular($vDat[$i], $key, $n) Next Return $bIsStr ? $vDat : StringFromASCIIArray($vDat) EndFunc ;==>_RSA ;algorithm is from the book "Discrete Mathematics and Its Applications 5th Edition" by Kenneth H. Rosen. Func _Modular($iBase, $iExp, $iMod) ; Mod($v ^ $key, $n) Local $iPower = Mod($iBase, $iMod) Local $x = 1 For $i = 0 To (4 * 8) - 1 If BitAND(0x00000001, BitShift($iExp, $i)) Then $x = Mod(($x * $iPower), $iMod) EndIf $iPower = Mod(($iPower * $iPower), $iMod) Next Return $x EndFunc ;==>_Modular ;Generate a "random" list of possible valid public keys to choose from based on $nT Func _GetPublicKeys($nT, $iMs = 100) Do Local $aKeys[10000] = [0], $iTime = TimerInit() Local $i = (Mod(@SEC, 2) ? Int($nT / 2) : Int($nT / 4)) ; randomize where we start Do If _IsPrime($i) And _IsCoPrime($i, $nT) Then $aKeys[0] += 1 $aKeys[$aKeys[0]] = $i EndIf $i += (Mod(@MSEC, 2) ? 1 : 100) ; randomize step size Until ($i >= ($nT - 1)) Or (TimerDiff($iTime) > $iMs) ReDim $aKeys[$aKeys[0] + 1] Until $aKeys[0] > 5 ; Ive seen 200+ returned sometimes and 0 on others. Make sure we have at least a few choices Return $aKeys EndFunc ;==>_GetPublicKeys ;https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/ - _ModInverse(a,m) Func _GetPrivateKey($a, $m) If ($m = 1) Then Return 0 ; Local $t, $q, $y = 0, $x = 1, $m0 = $m While ($a > 1) $q = Int($a / $m) ;q is quotient $t = $m ; $m = Mod($a, $m) ;m is remainder now, process same as Euclid's algo $a = $t ; $t = $y ; $y = $x - $q * $y ;Update y and x $x = $t ; WEnd Return $x < 0 ? $x + $m0 : $x EndFunc ;==>_GetPrivateKey ;Pick the next nearest prime from a random number (or number you cho0se) Func _GetRandomPrime($iStart = Default) Local $iPrime = ($iStart = Default ? Random(1000, 10000, 1) : $iStart) Do $iPrime += 1 Until _IsPrime($iPrime) Return $iPrime EndFunc ;==>_GetRandomPrime #Region Math Functions Func _IsPrime($n) For $i = 2 To (Int($n ^ 0.5) + 1) If Mod($n, $i) = 0 Then Return False Next Return True EndFunc ;==>_IsPrime Func _IsCoPrime($a, $b) Return _GCD($a, $b) = 1 EndFunc ;==>_IsCoPrime Func _GCD($iX, $iY) Local $iM While 1 $iM = Mod($iX, $iY) If $iM = 0 Then Return $iY $iX = $iY $iY = $iM WEnd EndFunc ;==>_GCD Func _LCM($iX, $iY) Return ($iX * $iY) / _GCD($iX, $iY) EndFunc ;==>_LCM #EndRegion Math Functions You should get a message box displaying the decrypted message with details of the values used: rsa.au3
    1 point
  10. Jos

    Hold Key and release

    Please don't, just stay out or report in case you are sure it is in violation with our rules. Please don't react like this either, it doesn't contribute to any fruitful discussion... but while we are on the subject: You haven't told us which program needs this many repeats for the letter a yet, so what is it you are doing here? Jos
    1 point
  11. For those who are interestd in go a little bit deeper, I think Khan academy has done a topic (with videos) about it, that is where I learned about how RSA works and how it was independently rediscovered. A little bit of math logic and prime numbers you can have a good way to encrypt data without a single shared key. Asymmetrical encryption they call it I think ... I found the topic: Journey into cryptography, it covers RSA in the modern cryptography section: https://www.khanacademy.org/computing/computer-science/cryptography#modern-crypt
    1 point
  12. @Nine was just trying to legitimize the purpose and intent of your script. Key spamming such as your example is more frequently than not associated with game bots. So no, it's not trash; and the fact you remain vague and got defensive doesn't bode well. So how 'bout we ask a different way....what are you trying to automate? Feel free to report, it may draw the attention this thread is shaping up to warrant either way.
    1 point
  13. water

    OutlookEX UDF

    Unfortunately there is no way to include the OutlookEx documentation into the AutoIt CHM documentation. You can integrate the OutlookEx UDF into SciTE by using the SciTEConfig tool (press Ctrl+1), select tab "Other tools", "Run User Calltip Manager" and then process the OutlookEX UDF. For a full help file you need to open the UDF and check the source or open OutlookEx.htm (comes with the OutlookEx zip-file).
    1 point
  14. As promised: This suits my needs at the moment, but I plan to add some other things to it as well, but it's at least usable now. The slider at the bottom sets the level the microphone must detect in order to detect it as a "clap". By default, I have the setting set to nearly deafening... I have twin three year old girls who enjoy screaming and running around while I'm trying to cook, so I have it set to where I need to clap very loudly to activate the next step. That's also the reason for requiring 3 sequential claps (to cut down on false positives). While they were napping, 2 worked just fine. I've included a few of our family's favorite recipes just as an example, but they're just glorified text files. If you dive into the AU3 instead of just using the exe, some basic configuration settings are near the top since I haven't gotten around to making a GUI settings window yet. I'm open to suggestions on how to improve it, as well as any constructive criticism anyone has to offer about the code itself. I'm always eager to grow! FlashCook.rar
    1 point
  15. JLogan3o13

    Hold Key and release

    To add to what Jos stated above, @Nine you would do well to read the following thread carefully: Pestering newcomers with questions because you think maybe they're doing something against the rules is not good enough. If the OP states something specifically against the rules, report it. If you are unsure whether it is against the rules or not, report it. And don't, as some around here do, report it and then help in the thread or report it and then continue to harangue the poster; report and move on. We have had sanction forum members in the past for wanting to play detective and grill others over their intentions - no one on the Moderation team wants to go back to having to do that.
    0 points
×
×
  • Create New...