Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/25/2015 in all areas

  1. Just an FYI to the post in #15, the DLLClose is in the wrong place, it needs to be before the Return statement.
    2 points
  2. JRowe

    Basic speech recognition.

    I wrestled with this one for a few days, but finally got the basics figured out. You need a microphone plugged into your computer (not a USB mic or you'll have to configure the app for it.) If you don't have SAPI, you can download 5.1 here. Try the script before, it seems SAPI gets distributed with most Vista and 7 versions. This listens to what you say into the mic, runs it through the windows speech recognition engine, and outputs the results to console. Results improve the more you train the system. I'm getting decent accuracy after about an hour of training. This uses a localized speech recognition engine, meaning that it's not subject to the Vista/7 built in Speech Recognition tool. This means you can add it into your app for your own commands, and it won't capture the basic Speech commands. There are ways of specifying grammars, utilizing the training tools, and other intricacies I haven't got to yet. Thanks to ProgAndy, cyberZeroCool, seangriffin, and all the others who've done SAPI work, you guys have blazed the trails for some very fun stuff. Global $h_Context = ObjCreate("SAPI.SpInProcRecoContext") Global $h_Recognizer = $h_Context.Recognizer Global $h_Grammar = $h_Context.CreateGrammar(1) $h_Grammar.Dictationload $h_Grammar.DictationSetState(1) ;Create a token for the default audio input device and set it Global $h_Category = ObjCreate("SAPI.SpObjectTokenCategory") $h_Category.SetId("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput\TokenEnums\MMAudioIn\") Global $h_Token = ObjCreate("SAPI.SpObjectToken") $h_Token.SetId("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\AudioInput\TokenEnums\MMAudioIn\") $h_Recognizer.AudioInput = $h_Token Global $i_ObjInitialized = 0 Global $h_ObjectEvents = ObjEvent($h_Context, "SpRecEvent_") If @error Then ConsoleWrite("ObjEvent error: " & @error & @CRLF) $i_ObjInitialized = 0 Else ConsoleWrite("ObjEvent created Successfully!" & @CRLF) $i_ObjInitialized = 1 EndIf While $i_ObjInitialized Sleep(5000) ;Allow the Audio In to finalize processing on the last 5 second capture $h_Context.Pause ;Resume audio in processing $h_Context.Resume ;Reset event function allocation (what is this? I think its garbage collection or something, needs clarification) $h_ObjectEvents = ObjEvent($h_Context, "SpRecEvent_") WEnd Func SpRecEvent_Hypothesis($StreamNumber, $StreamPosition, $Result) ConsoleWrite("Hypothesis(): Hypothized text is: " & $Result.PhraseInfo.GetText & @CRLF) EndFunc ;==>SpRecEvent_Hypothesis Func SpRecEvent_Recognition($StreamNumber, $StreamPosition, $RecognitionType, $Result) ConsoleWrite($RecognitionType & "||" & $Result.PhraseInfo.GetText & @CRLF) EndFunc ;==>SpRecEvent_Recognition Func SpRecEvent_SoundStart($StreamNumber, $StreamPosition) ConsoleWrite("Sound Started" & @CRLF) EndFunc ;==>SpRecEvent_SoundStart Func SpRecEvent_SoundEnd($StreamNumber, $StreamPosition) ConsoleWrite("Sound Ended" & @CRLF) EndFunc ;==>SpRecEvent_SoundEnd The SoundEnd event doesn't appear to work. Everything else functions as intended. In order to use this, you have to parse completed phrases from the input. Don't worry about the Sleep(5000), that doesn't interfere with the operation of the recognition. That's just there to separate the sound input into manageable chunks. It's not in UDF format, but should be very easy to adapt into your projects. A hypothesis is the engine's best guess as to what is being said. A recognition is a finalized hypothesis. After a recognition, any new input will be hypothesized until discarded or recognized. You can talk for as long as you want and it will piece together what is said, until there is a full 1 second gap in the incoming audio. Here is the SAPI recognition documentation if you want to modify this for your own purposes. Have fun!
    1 point
  3. 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
  4. 1 point
  5. @Adele - you need to hook the parent process of the console window. I was using "conhost.exe" to do this with the command prompt open and it worked. Then I switched keyboards and ran it again and it picked up the change. Did you use my exact code? I have tried it on two different machines and it worked on both.
    1 point
  6. kcvinu & anyone else reading Her is a new Beta which seems to work just fine for me in both the _CFF_Choose and _CFF_Embed cases, with and without prechecks. I would be grateful if others could test it too: ChooseFileFolder_Mod.au3 Here is the test script I have been using: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include "ChooseFileFolder_Mod.au3" Local $sRet, $aRet Global $sRootFolder = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) ConsoleWrite($sRootFolder & @CRLF) ; Register handlers $sRet = _CFF_RegMsg() If Not $sRet Then MsgBox(16, "Failure!", "Handler not registered") Exit EndIf ; Pre-check the AutoIt executable file Local $aPreCheck_List[] = [@AutoItExe] ; Note that pre-checked file will be returned unless expanded and cleared _CFF_SetPreCheck($aPreCheck_List) ; Only lowest item on a checked tree will be returned $sRet = _CFF_Choose("_CFF_Choose", 300, 500, -1, -1, "", Default, 0 + 512, -1) If $sRet Then $aRet = StringSplit($sRet, "|") $sRet = "" For $i = 1 To $aRet[0] $sRet &= $aRet[$i] & @CRLF Next MsgBox($MB_SYSTEMMODAL + $MB_ICONINFORMATION, "Done", "Selected:" & @CRLF & @CRLF & $sRet) Else MsgBox($MB_SYSTEMMODAL + $MB_ICONINFORMATION, "Oops", "No Selection") EndIf $hGUI = GUICreate("_CFF_Embed", 300, 500) $hTV = _GUICtrlTreeView_Create($hGUI, 10, 10, 280, 400, BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)) $cStop = GUICtrlCreateButton("Return", 10, 450, 80, 30) GUISetState() ; Reset precheck path _CFF_SetPreCheck($aPreCheck_List) $sRet = _CFF_Embed ($hTV, "", Default, 0 + 512, $cStop) If $sRet Then $aRet = StringSplit($sRet, "|") $sRet = "" For $i = 1 To $aRet[0] $sRet &= $aRet[$i] & @CRLF Next MsgBox($MB_SYSTEMMODAL + $MB_ICONINFORMATION, "Done", "Selected:" & @CRLF & @CRLF & $sRet) Else MsgBox($MB_SYSTEMMODAL + $MB_ICONINFORMATION, "Oops", "No Selection") EndIf Thanks in advance for any comments. M23
    1 point
  7. Hey CrypticKiwi, I have rewritten your function to gain some performance, hope it helps. $Handle1 = FileOpen("ExampleFile01.txt", 0) $Example1 = FileRead($Handle1) $Handle2 = FileOpen("ExampleFile02.txt", 0) $Example2 = FileRead($Handle2) _Scramble($Example1,$Example2) Func _Scramble($CycleData,$Data) $CycleDataArray = StringSplit($CycleData,"") $DataArray = StringSplit($Data,"") $ReturnString = "" For $i = 1 To StringLen($CycleData) - 10 If $DataArray[$i] <> 0 Then $Temp = $CycleDataArray[$i] $CycleDataArray[$i] = $CycleDataArray[$i + $DataArray[$i] - 1] $CycleDataArray[$i + $DataArray[$i] - 1] = $Temp EndIf Next For $i = 1 To StringLen($CycleData) $ReturnString &= $CycleDataArray[$i] Next return $ReturnString EndFunc ;==>_Scramble
    1 point
  8. water

    Active Directory UDF

    Looks like you need to pass an array with all the needed values. Unfortunatley this site is written in German but I think you'll get the message: http://www.administrator.de/frage/powershell-vbscript-altsecurityidentities-188680.html
    1 point
  9. You can ignore this if you want, but over time your code base will become quite difficult to maintain if you're using a lot of global variables. My advice would be to prefix with $g_, so you can tell what is global and not. It also helps those who jump on board and submit PR, which I guess is what you want? There is also git related remarks left over in DLLImports e.g. <<<<<< HEAD as well as unresolved sections. I was in the process of creating a PR, but realised it's better if @minxomat resolves the conflict(s). I know you're porting over the code, but don't write AutoIt code like you're writing VB.NET, as AutoIt != VB.NET. Edit: The reason I wrote this post now, is because code with multiple team members shouldn't look like it's written by multiple team members and from what I can see, this is where it's headed. You have variables which are a mixture of pascal-case or AutoIt-like Hungarian notation, functions that are pascal case and camel-case and not very many comments. Therefore it's best at this early stage of the game to have a style guide and plan what is the best way of structuring this project. How should internal functions be named? What is the correct approach for commenting? What's the threshold for the number of lines a function can contain?
    1 point
  10. Their is an example in the help file.
    1 point
  11. I am just making an opinion that i wouldnt recommend too much .exe files during startup but i would recommend to run a batch script during startup as it does not take up much time to load you have many command line options available if you want to run a .exe file scripted in autoit then you should add your program to the local policy editor as the scripts in the policy editor will start first with windows explorer
    1 point
  12. I have been researching this a bit. This may be a problem with the console vs. other windows. I did not verify the way the user32.dll works - but this may explain it: Cite: http://stackoverflow.com/questions/29217501/getkeyboardlayout-doesnt-work-properly-in-some-cases I can detect the changes this way ... NOTE: not sure why I can't get it to work with the standard function - mine is basically the same except the way I open the DLL call (should not make a difference). Func _WinAPI_GetKeyboardLayout2($hWnd) Local $hDLL = DllOpen("user32.dll") Local $aRet = DllCall('user32.dll', 'DWORD', 'GetWindowThreadProcessId', 'hwnd', $hWnd, 'ptr', 0) $aRet = DllCall('user32.dll', 'handle', 'GetKeyboardLayout', 'DWORD', $aRet[0]) DllClose($hDLL)Return $aRet[0] EndFunc ;==>_WinAPI_GetKeyboardLayout $parentPID=run("conhost.exe") $key=_WinAPI_GetKeyboardLayout2($parentPID) MsgBox(0,"",$key)
    1 point
  13. maybe a workaround could be to be able to read the status of the checked language in the tray menu or at least the text of the associated tooltip.... it seems that the Handle of the "language selector" control is this [CLASS:CiceroUIWndFrame] but I have not idea on how to grab his status or text. once we can get the text of that control, we could activate the cmd window and check his active language by reading the status of the "language selector" control. (indeed the status of this control changes any time you select a new window, showing his associated language.) EDIT: to try this behaviour do this: 1) open 2 cmd windows 2) activate one of those cmd and change his keyb language on the "language selector" in the tray bar 3) then alternately click on both cmd windows ant see the "text" changing on the keyb language tray control EDIT 2: other weirdness if you type this 2 commands within a cmd promt: chcp or mode con cp the result is the active table code but the result is always the same even when you change the keyboard language on the "language selector" tollbar control or by the chcp or the mode con cp commands...
    1 point
  14. Yes, it returns an array. I am using the first element in the array. Is that not the selected keyboard?
    1 point
  15. Okay, this is untested - because I am not sure how you change the keyboard layout for the Command Prompt window. However, I did notice a problem with the _WinAPI_GetKeyboardLayout function. It seems to work intermittently and was having issues inside a loop. I am not sure what I did but my code above stopped working. I decided to switch functions and use the keyboard list. I assume the first entry is the current keyboard (that may or may not be true as I only have 1). Again, the part that detects the change is untested but let me know if something like this works for you ... #include <WinAPISys.au3> #include <Array.au3> Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Global $currentKeyboard=_getKeyBoard() ;ConsoleWrite(@CRLF&$currentKeyboard&@CRLF) Global $newKeyboard=$currentKeyboard ;ConsoleWrite(@CRLF&$newKeyboard&@CRLF) func _getKeyBoard() $windowTitle="Command Prompt" $windowHandle=WinActivate($windowTitle) local $keyboardList=_WinAPI_GetKeyboardLayoutList ( ) return $keyboardList[1] EndFunc while 1 sleep(1000) $currentKeyboard=_getKeyBoard() If $currentKeyboard <> $newKeyboard Then MsgBox(0,"Change Detected","New Keyboard is: "&$currentKeyboard) $newKeyboard=$currentKeyboard Else ConsoleWrite(@CRLF&$currentKeyboard&@CRLF) EndIF WEnd
    1 point
  16. use this: Opt("WinWaitDelay",10)
    1 point
  17. This script is fairly straightforward. If you ever worked with large files before then this may be of help. By large I mean files of 2 MB or so. Granted this doesn't sound so big but going through the file and parsing it to a 2D array all at once took an astronomical amount of time so I wrote my own function to handle this. I discovered that chunking a large array can boost the performance of iterating through the elements and theoretically this should maintain the performance no matter how large the array size is. I know there is room for improvement so please feel free to contribute! Note: I wasn't able to fully test this on larger files such as 200 MB in size due to AutoIt complaining about an error allocating memory while executing _FileReadToArray(). Any help is appreciated. Features: Chunking (Performance will never degrade over time; I.E. Capable of parsing 200 lines or 20,000 and no performance hit will occur) Automatically re-sizes to dynamic columns Preserves Columns while parsing FAST!!!!!! (I can parse a file that contains 24,000 lines with variable columns up to 8 columns and it will finish under a second.) Script: _ArrayTo2DArray.au3 Example usage: Local $aExport ;Initialize array _FileReadToArray("LARGE TEXT.txt", $aExport) ;Returns 1D array of file Local $aSheet = _ArrayTo2DArray($aExport) ;Converts it to 2D Example Text File: LARGE TEXT.txt This script was inspired by >this post. *Updated attachment: Minor bug fixes* *UPDATE June 6, 2013: I apologize! I just realized I made a complete mess of the algorithm. I'm working on a fix now.* *UPDATE June 6, 2013: Bug fixed! It's attached in the post now.
    1 point
  18. TinyClipToSpeech v 1.0.0.9 Read Clipboard Text Content using Sapi Voice Access to all commands by Tray menu. If you doesn't have Sapi5 installed, script ask for download it. I know there is already some Text to speech scripts, but i wanted an easy access ( clipboard content and tray menu ) and the possibility to change voice and settings while reading. Text can be displayed on desktop gradually as what is read. You can also save text to mp3 without need of read it. My preference goes to Scansoft voices, easy to found and install and with a good pronunciation qualty. As usual, some externals files are downloaded at first execution. Previous downloads : 199 Update of 2012-07-01 Source : TinyClipToSpeech v 1.0.0.9.au3 Executable : TinyClipToSpeech.exe.html (Once this html file downloaded, double click on it for start the download) Hope you like it !
    1 point
  19. Declaring Global variables in a Function is never a good idea: #include <MsgBoxConstants.au3> ; Calling Example() first will initialise the Global variable $vVariableThatIsGlobal and therefore calling SomeFunc() won't return an error. ; Now look at Example 2. Example() Func Example() ; Declaring a variable in a function can cause serious problems, hence why all Global variables should be declared at the top of a script. Global $vVariableThatIsGlobal = 'This is a variable that has ''File Scope'' aka Global.' SomeFunc() EndFunc ;==>Example Func SomeFunc() MsgBox($MB_SYSTEMMODAL, '', $vVariableThatIsGlobal) ; As the variable was initialised this will not return an error. EndFunc ;==>SomeFuncExample 2: #include <MsgBoxConstants.au3> ; Calling SomeFunc() first will bypass the Global variable $vVariableThatIsGlobal being initialised and therefore AutoIt has no idea of what data the variable ; $vVariableThatIsGlobal contains. SomeFunc() Func Example() ; Declaring a variable in a function can cause serious problems, hence why all Global variables should be declared at the top of a script. Global $vVariableThatIsGlobal = 'This is a variable that has ''File Scope'' aka Global.' SomeFunc() EndFunc ;==>Example Func SomeFunc() MsgBox($MB_SYSTEMMODAL, '', $vVariableThatIsGlobal) ; As the variable wasn't initialised this will return an error of "variable used without being declared." EndFunc ;==>SomeFunc Question: What if I want to retain variable data once returned from a Function and only use that variable in that particular Function, can't it be declared as Global then? Answer: Static variables. #include <MsgBoxConstants.au3> Example() Func Example() SomeFunc() ; This will display a message box of 1, 1. SomeFunc() ; This will display a message box of 1, 2. SomeFunc() ; This will display a message box of 1, 3. EndFunc ;==>Example Func SomeFunc() ; This initialises a Static variable in Local scope. When a variable is declared just in Local scope (within a Function,) ; it's destroyed when the Function ends/returns. This isn't the case for a Static variable. The variable can't be ; accessed from anywhere else in the script apart from the Function it was declared in. Local Static $vVariableThatIsStatic = 0 Local $vVariableThatIsLocal = 0 $vVariableThatIsLocal += 1 ; This will always be 1 as it was destroyed once returned from SomeFunc. $vVariableThatIsStatic += 1 ; This will increase by 1. MsgBox($MB_SYSTEMMODAL, $vVariableThatIsLocal, $vVariableThatIsStatic) EndFunc ;==>SomeFunc
    1 point
  20. This UDF allows users to create and control a Microsoft Speech API ListBox (SAPIListBox) within an AutoIT GUI. It requires the Microsoft Speech SDK 5.1 (a free download from Microsoft). The SAPIListBox is a simple and effective way to add voice recognition / speech recogition to your AutoIT script. I personally have found this method of speech recognition to be even more accurate than via the other tools and methods within the SAPI SDK. The SAPIListBox looks like any other traditional ListBox (ie. AutoIT's "GUIListBox"). However it is voice sensitive. When the listbox is active, it listens to your microphone, and if a spoken word matches an item within the listbox (via Microsoft's Speech API), then that item is automatically selected. My UDF also includes the ability to detect this change in the listbox, so a script can then perform a particular action once the word is spoken. I'd used the SAPIListBox with great success in a MS Access application previously. I thought I'd port it to AutoIT just for the fun of it If you find that the speech recognition capability of this UDF is not that accurate, then go to your Windows Control Panel and open the "Speech" applet. A "Speech Properties" window will be displayed. Click the "Train Profile..." button to train the Speech API to understand your own voice better. Once you have finished this, retry this UDF. You should notice an improvement in speech recognition. REQUIREMENTS: AutoIt3 3.2 or higher the Microsoft Speech SDK 5.1 (a 68 MB free download) LIST OF FUNCTIONS: EXAMPLES: You must have downloaded and installed the Microsoft SAPI 5.1 SDK (in the Requirements section above) prior to running these examples, or using the UDF. The following example demonstrates the full set of functions in the UDF. When the script is run, a GUI is displayed. The user should be able to immediately begin talking into the microphone, reciting any of the words listed in the SAPIListBox. If a word is spoken correctly, that word should get automatically selected in the listbox. The bottom half of the GUI will display changes (as the user speaks the correct words), and also allow the user to add and remove words, and adjust other listbox properties. Clicking the "Speech Properties" button will display the settings for SAPI, and allow users to train the speech engine to better recognise their own voice. SAPIListBox control Test.au3 The following example is of a voice activated application launcher. When the script is run, a GUI is displayed. The user should be able to immediately begin talking into the microphone, reciting any of the words listed in the SAPIListBox. If a word is spoken correctly, the corresponding application should start. Clicking the "Speech Properties" button will display the settings for SAPI, and allow users to train the speech engine to better recognise their own voice. Saying the word "close" should close the active window (as launched with a previous voice command). voice activate app launcher.au3 DOWNLOAD: Latest Version - v0.1 (21/05/10) SAPIListBox.au3
    1 point
×
×
  • Create New...