никак не хочет работать....даже в блокноте ...уже все перерыл/прочитал но так и не получил результата .....ОС win7 64x (если это важно)...прошу помощи
или так
Код:
Opt("WinTitleMatchMode", 2)
global $hwnd = WinGetHandle("[CLASS:Notepad]", "")
Func _KeySendHWND($hwnd, $inkey, $event="pressed")
$user32dll = DllOpen("user32.dll")
;Hex Key for WM_KEYDOWN, WM_KEYUP from helpfile
$WM_KEYDOWN = 0x100
$WM_KEYUP = 0x101
;Get Key (hex)
$key = DllCall($user32dll, "int", "VkKeyScan", "int", Asc(StringLower($inkey)))
$keyhex = $key[0]
;Create virtual Key:
$ret = DllCall($user32dll, "int", "MapVirtualKey", "int", $keyhex, "int", 0)
;create lparam info
$lparam = BitShift($ret[0], -16)
$lparam = BitOr($lparam, 1)
Select
Case $event = "pressed"
DllCall($user32dll, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $keyhex, "int", $lparam)
Sleep(15)
DllCall($user32dll, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $keyhex, "int", BitOR($lparam, 0xC0000000))
Case $event = "down"
DllCall($user32dll, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYDOWN, "int", $keyhex, "int", $lparam)
Case $event = "up"
DllCall($user32dll, "int", "PostMessage", "hwnd", $hwnd, "int", $WM_KEYUP, "int", $keyhex, "int", BitOR($lparam, 0xC0000000))
EndSelect
DllClose($user32dll)
EndFunc
While 1
;should move 1 second forward
$hwnd = WinGetHandle("[CLASS:Notepad]", "")
if @error Then
msgbox (4096, "Error...", "No AkelPad")
Else
call("_KeySendHWND",$hwnd, "w", "down")
sleep (1000)
call("_KeySendHWND",$hwnd, "w", "up")
EndIf
WEnd
Call ("_Main")
или так
Код:
Global $ProcessName = "кассы.txt — Блокнот"
Global $ProcessID = WinGetProcess($ProcessName,"")
Global $hWnd = WinGetHandle("кассы.txt — Блокнот", "")
Global $hCtrl = ControlGetHandle($hWnd, '', '')
;MsgBox(4096, "Test", $hWnd, "")
Global $WM_KEYDOWN = 0x0100 ;;declared in WindowConstants.au3
Global $WM_KEYUP = 0x0101 ;;declared in WindowConstants.au3
while 1
;ControlSend($hWnd, "", "","{Tab}")
_SendMinimizedVK($hWnd,"TAB")
sleep (500)
_SendMinimizedVK($hWnd,"1")
;ControlSend($hWnd, "", "","{1}")
sleep (500)
;Send("{Tab}")
wend
Func _SendMinimizedVK($winhandle,$vkstring)
Local $var = _GetHexByKey_Switch($vkstring)
if Not ($var = -1) Then
DllCall("user32.dll", "int", "SendMessage", _
"hwnd", $winhandle, _
"int", $WM_KEYDOWN, _
"int", _GetHexByKey_Switch($vkstring), _
"long", 0)
DllCall("user32.dll", "int", "PostMessage", _ ;SendMessage only works ingame, not in lobby
"hwnd", $winhandle, _
"int", $WM_KEYUP, _
"int", _GetHexByKey_Switch($vkstring), _
"long", 0)
;~ ConsoleWrite(1 & @CRLF) ;debug Success
Return 1
EndIf
;~ ConsoleWrite(0 & @CRLF) ;debug Failed
Return 0
EndFunc
Func _GetHexByKey_Switch($sKey)
Switch $sKey
Case "LeftMouse"
Return 0x01
Case "RightMouse"
Return 0x02
Case "MiddleMouse"
Return 0x04
Case "X1Mouse"
Return 0x05
Case "X2Mouse"
Return 0x06
Case "BACKSPACE"
Return 0x08
Case "TAB"
Return 0x09
Case "CLEAR"
Return 0x0C
Case "ENTER"
Return 0x0D
Case "SHIFT"
Return 0x10
Case "CTRL"
Return 0x11
Case "ALT"
Return 0x12
Case "PAUSE"
Return 0x13
Case "CAPSLOCK"
Return 0x14
Case "ESC"
Return 0x1B
Case " "
Return 0x20
Case "SPACE"
Return 0x20
Case "PAGE UP"
Return 0x21
Case "PAGE DOWN"
Return 0x22
Case "END"
Return 0x23
Case "HOME"
Return 0x24
Case "LEFT"
Return 0x25
Case "UP"
Return 0x26
Case "RIGHT"
Return 0x27
Case "DOWN"
Return 0x28
Case "SELECT"
Return 0x29
Case "PRINT"
Return 0x2A
Case "EXECUTE"
Return 0x2B
Case "PRINT SCREEN"
Return 0x2C
Case "INS"
Return 0x2D
Case "DEL"
Return 0x2E
Case "0"
Return 0x30
Case "1"
Return 0x31
Case "2"
Return 0x32
Case "3"
Return 0x33
Case "4"
Return 0x34
Case "5"
Return 0x35
Case "6"
Return 0x36
Case "7"
Return 0x37
Case "8"
Return 0x38
Case "9"
Return 0x39
Case "A"
Return 0x41
Case "B"
Return 0x42
Case "C"
Return 0x43
Case "D"
Return 0x44
Case "E"
Return 0x45
Case "F"
Return 0x46
Case "G"
Return 0x47
Case "H"
Return 0x48
Case "I"
Return 0x49
Case "J"
Return 0x4A
Case "K"
Return 0x4B
Case "L"
Return 0x4C
Case "M"
Return 0x4D
Case "N"
Return 0x4E
Case "O"
Return 0x4F
Case "P"
Return 0x50
Case "Q"
Return 0x51
Case "R"
Return 0x52
Case "S"
Return 0x53
Case "T"
Return 0x54
Case "U"
Return 0x55
Case "V"
Return 0x56
Case "W"
Return 0x57
Case "X"
Return 0x58
Case "Y"
Return 0x59
Case "Z"
Return 0x5A
Case "LWin"
Return 0x5B
Case "RWin"
Return 0x5C
Case "NUMPAD0"
Return 0x60
Case "NUMPAD1"
Return 0x61
Case "NUMPAD2"
Return 0x62
Case "NUMPAD3"
Return 0x63
Case "NUMPAD4"
Return 0x64
Case "NUMPAD5"
Return 0x65
Case "NUMPAD6"
Return 0x66
Case "NUMPAD7"
Return 0x67
Case "NUMPAD8"
Return 0x68
Case "NUMPAD9"
Return 0x69
Case "Multiply"
Return 0x6A
Case "Add"
Return 0x6B
Case "Separator"
Return 0x6C
Case "Subtract"
Return 0x6D
Case "Decimal"
Return 0x6E
Case "Divide"
Return 0x6F
Case "F1"
Return 0x70
Case "F2"
Return 0x71
Case "F3"
Return 0x72
Case "F4"
Return 0x73
Case "F5"
Return 0x74
Case "F6"
Return 0x75
Case "F7"
Return 0x76
Case "F8"
Return 0x77
Case "F9"
Return 0x78
Case "F10"
Return 0x79
Case "F11"
Return 0x7A
Case "F12"
Return 0x7B
Case "F13"
Return 0x7C
Case "F16"
Return 0x7F
Case "F17"
Return 0x80
Case "F18"
Return 0x81
Case "F19"
Return 0x82
Case "F20"
Return 0x83
Case "F21"
Return 0x84
Case "F22"
Return 0x85
Case "F23"
Return 0x86
Case "F24"
Return 0x87
Case "NUM LOCK"
Return 0x90
Case "SCROLL LOCK"
Return 0x91
Case "LSHIFT"
Return 0xA0
Case "RSHIFT"
Return 0xA1
Case "LCTRL"
Return 0xA2
Case "RCTRL"
Return 0xA3
Case "LMENU"
Return 0xA4
Case "RMENU"
Return 0xA5
Case "="
Return 0x92
Case ";"
Return 0xBA
Case ":"
Return 0xBA
Case "+"
Return 0xBB
Case ","
Return 0xBC
Case "-"
Return 0xBD
Case "."
Return 0xBE
Case "/"
Return 0xBF
Case "?"
Return 0xBF
Case "`"
Return 0xC0
Case "~"
Return 0xC0
Case "["
Return 0xDB
Case "{"
Return 0xDB
Case "\"
Return 0xDC
Case "|"
Return 0xDC
Case "]"
Return 0xDD
Case "}"
Return 0xDD
Case "'"
Return 0xDE
Case '"'
Return 0xDE
Case "<"
Return 0xE2
Case ">"
Return 0xE2
EndSwitch
Return -1
EndFunc ;==>_GetHexByKey_Switch