Что нового

Удалённое управление: отпрака нажатий клавишь

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Хочу сделать программу на подобии RAdmin`a, возникла проблема, если я на сервере нажимаю допустим клавишу F(большую) то клиент должен отправить в активное приложение большую букву F, тоже самое и с маленькими, плюс ко всему этому клиент должен узнать какой язык сейчас включен на компьютере где стоит клиент, как это сделать грамотно, без лишней писанины?

Чтоб узнать язык, я пологаю для этого есть функция
Код:
_WinAPI_GetKeyboardLayout(WinGetHandle('[ACTIVE]'))


Но как поместить весь Английский и Русский алфавит в скрипт + спец.символы и Ctrl, Alt, Shift и т.д.
Если можно хотя бы маленький пример, спасибо.

Я думал в сервере написать так:
Код:
HotKeySet("{A}", "SendAS")	
HotKeySet("+{A}", "SendAB")		
	
Func SendAS()
    If GetLang() = 0x0409 Then TCPSend($Socket, "a")
	If GetLang() = 0x0419 Then TCPSend($Socket, "ф")
EndFunc

Func SendAB()
    If GetLang() = 0x0409 Then TCPSend($Socket, "A")
	If GetLang() = 0x0419 Then TCPSend($Socket, "Ф")
EndFunc	
	
Func GetLang()
	Local $Lang = _WinAPI_GetKeyboardLayout(WinGetHandle('[ACTIVE]'))
	Return $Lang
EndFunc

А в клиенте так:
Код:
$bData = TCPRecv($iSocket, 8341, 1)
Send("{" & $bData & "}")

Но я подумал что замучаюсь это всё писать....
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Решил сделать виртуальную клавиатуру, чтоб по команде с сервера, клавиатура запускалась из под клиента, как только сделать чтоб окно виртуальной клавиатуры было поверх всех но никогда не было активным, иначе оно само в себя будет отправлять буквы, символы и цифры.

Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $LockState = 0
Global $Apportion = "RU"

$hVKeyWindow = GUICreate("Virtual Keyboard", 564, 177, -1, -1, $WS_BORDER)
GUISetBkColor(0xB0B0B0)
WinSetOnTop($hVKeyWindow, "", 1)
$Button00 = GUICtrlCreateButton("Exit", 510, 0, 50, 25)
$ButtonRU = GUICtrlCreateButton("RU", 460, 0, 25, 25)
$ButtonEN = GUICtrlCreateButton("EN", 485, 0, 25, 25)
$Button01 = GUICtrlCreateButton("Esc", 0, 0, 25, 25)
$Button02 = GUICtrlCreateButton("F1", 25, 0, 25, 25)
$Button03 = GUICtrlCreateButton("F2", 50, 0, 25, 25)
$Button04 = GUICtrlCreateButton("F3", 75, 0, 25, 25)
$Button05 = GUICtrlCreateButton("F4", 100, 0, 25, 25)
$Button06 = GUICtrlCreateButton("F5", 150, 0, 25, 25)
$Button07 = GUICtrlCreateButton("F6", 175, 0, 25, 25)
$Button08 = GUICtrlCreateButton("F7", 200, 0, 25, 25)
$Button09 = GUICtrlCreateButton("F8", 225, 0, 25, 25)
$Button10 = GUICtrlCreateButton("F9", 275, 0, 25, 25)
$Button11 = GUICtrlCreateButton("F10", 300, 0, 25, 25)
$Button12 = GUICtrlCreateButton("F11", 325, 0, 25, 25)
$Button13 = GUICtrlCreateButton("F12", 350, 0, 25, 25)
$Button14 = GUICtrlCreateButton("ё", 0, 25, 25, 25)
$Button15 = GUICtrlCreateButton("1", 25, 25, 25, 25)
$Button16 = GUICtrlCreateButton("2", 50, 25, 25, 25)
$Button17 = GUICtrlCreateButton("3", 75, 25, 25, 25)
$Button18 = GUICtrlCreateButton("4", 100, 25, 25, 25)
$Button19 = GUICtrlCreateButton("5", 125, 25, 25, 25)
$Button20 = GUICtrlCreateButton("6", 150, 25, 25, 25)
$Button21 = GUICtrlCreateButton("7", 175, 25, 25, 25)
$Button22 = GUICtrlCreateButton("8", 200, 25, 25, 25)
$Button23 = GUICtrlCreateButton("9", 225, 25, 25, 25)
$Button24 = GUICtrlCreateButton("0", 250, 25, 25, 25)
$Button25 = GUICtrlCreateButton("-", 275, 25, 25, 25)
$Button26 = GUICtrlCreateButton("=", 300, 25, 25, 25)
$Button27 = GUICtrlCreateButton("Bksp", 325, 25, 50, 25)
$Button28 = GUICtrlCreateButton("Tab", 0, 50, 40, 25)
$Button29 = GUICtrlCreateButton("й", 40, 50, 25, 25)
$Button30 = GUICtrlCreateButton("ц", 65, 50, 25, 25)
$Button31 = GUICtrlCreateButton("у", 90, 50, 25, 25)
$Button32 = GUICtrlCreateButton("к", 115, 50, 25, 25)
$Button33 = GUICtrlCreateButton("е", 140, 50, 25, 25)
$Button34 = GUICtrlCreateButton("н", 165, 50, 25, 25)
$Button35 = GUICtrlCreateButton("г", 190, 50, 25, 25)
$Button36 = GUICtrlCreateButton("ш", 215, 50, 25, 25)
$Button37 = GUICtrlCreateButton("щ", 240, 50, 25, 25)
$Button38 = GUICtrlCreateButton("з", 265, 50, 25, 25)
$Button39 = GUICtrlCreateButton("х", 290, 50, 25, 25)
$Button40 = GUICtrlCreateButton("ъ", 315, 50, 25, 25)
$Button41 = GUICtrlCreateButton("\", 340, 50, 35, 25)
$Button42 = GUICtrlCreateButton("Lock", 0, 75, 40, 25)
$Button43 = GUICtrlCreateButton("ф", 40, 75, 25, 25)
$Button44 = GUICtrlCreateButton("ы", 65, 75, 25, 25)
$Button45 = GUICtrlCreateButton("в", 90, 75, 25, 25)
$Button46 = GUICtrlCreateButton("а", 115, 75, 25, 25)
$Button47 = GUICtrlCreateButton("п", 140, 75, 25, 25)
$Button48 = GUICtrlCreateButton("р", 165, 75, 25, 25)
$Button49 = GUICtrlCreateButton("о", 190, 75, 25, 25)
$Button50 = GUICtrlCreateButton("л", 215, 75, 25, 25)
$Button51 = GUICtrlCreateButton("д", 240, 75, 25, 25)
$Button52 = GUICtrlCreateButton("ж", 265, 75, 25, 25)
$Button53 = GUICtrlCreateButton("э", 290, 75, 25, 25)
$Button54 = GUICtrlCreateButton("Enter", 315, 75, 60, 25)
$Button55 = GUICtrlCreateButton("Shift", 0, 100, 50, 25)
$Button56 = GUICtrlCreateButton("/", 50, 100, 25, 25)
$Button57 = GUICtrlCreateButton("я", 75, 100, 25, 25)
$Button58 = GUICtrlCreateButton("ч", 100, 100, 25, 25)
$Button59 = GUICtrlCreateButton("с", 125, 100, 25, 25)
$Button60 = GUICtrlCreateButton("м", 150, 100, 25, 25)
$Button61 = GUICtrlCreateButton("и", 175, 100, 25, 25)
$Button62 = GUICtrlCreateButton("т", 200, 100, 25, 25)
$Button63 = GUICtrlCreateButton("ь", 225, 100, 25, 25)
$Button64 = GUICtrlCreateButton("б", 250, 100, 25, 25)
$Button65 = GUICtrlCreateButton("ю", 275, 100, 25, 25)
$Button66 = GUICtrlCreateButton(".", 300, 100, 25, 25)
$Button67 = GUICtrlCreateButton("Shift", 325, 100, 50, 25)
$Button68 = GUICtrlCreateButton("Ctrl", 0, 125, 50, 25)
$Button69 = GUICtrlCreateButton("Win", 50, 125, 30, 25)
$Button70 = GUICtrlCreateButton("Alt", 80, 125, 25, 25)
$Button71 = GUICtrlCreateButton("", 105, 125, 115, 25)
$Button72 = GUICtrlCreateButton("Alt", 220, 125, 25, 25)
$Button73 = GUICtrlCreateButton("Win", 245, 125, 30, 25)
$Button74 = GUICtrlCreateButton("Print", 275, 125, 50, 25)
$Button75 = GUICtrlCreateButton("Ctrl", 325, 125, 50, 25)
$Button76 = GUICtrlCreateButton("Psc", 380, 0, 25, 25)
$Button77 = GUICtrlCreateButton("Slk", 405, 0, 25, 25)
$Button78 = GUICtrlCreateButton("Brk", 430, 0, 25, 25)
$Button79 = GUICtrlCreateButton("Ins", 380, 25, 25, 25)
$Button80 = GUICtrlCreateButton("Hm", 405, 25, 25, 25)
$Button81 = GUICtrlCreateButton("Pup", 430, 25, 25, 25)
$Button82 = GUICtrlCreateButton("Del", 380, 50, 25, 25)
$Button83 = GUICtrlCreateButton("End", 405, 50, 25, 25)
$Button84 = GUICtrlCreateButton("Pdn", 430, 50, 25, 25)
$Button85 = GUICtrlCreateButton("^", 405, 100, 25, 25)
$Button86 = GUICtrlCreateButton("<", 380, 125, 25, 25)
$Button87 = GUICtrlCreateButton("Dw", 405, 125, 25, 25)
$Button88 = GUICtrlCreateButton(">", 430, 125, 25, 25)
$Button89 = GUICtrlCreateButton("nlk", 460, 25, 25, 25)
$Button90 = GUICtrlCreateButton("/", 485, 25, 25, 25)
$Button91 = GUICtrlCreateButton("*", 510, 25, 25, 25)
$Button92 = GUICtrlCreateButton("-", 535, 25, 25, 25)
$Button93 = GUICtrlCreateButton("7", 460, 50, 25, 25)
$Button94 = GUICtrlCreateButton("8", 485, 50, 25, 25)
$Button95 = GUICtrlCreateButton("9", 510, 50, 25, 25)
$Button96 = GUICtrlCreateButton("+", 535, 50, 25, 50)
$Button97 = GUICtrlCreateButton("4", 460, 75, 25, 25)
$Button98 = GUICtrlCreateButton("5", 485, 75, 25, 25)
$Button99 = GUICtrlCreateButton("6", 510, 75, 25, 25)
$Button100 = GUICtrlCreateButton("1", 460, 100, 25, 25)
$Button101 = GUICtrlCreateButton("2", 485, 100, 25, 25)
$Button102 = GUICtrlCreateButton("3", 510, 100, 25, 25)
$Button103 = GUICtrlCreateButton("Ent", 535, 100, 25, 50)
$Button104 = GUICtrlCreateButton("0", 460, 125, 50, 25)
$Button105 = GUICtrlCreateButton(".", 510, 125, 25, 25)
GUISetState()

While 1
	Switch GUIGetMsg()
		Case $Button00
			Exit
		Case $ButtonRU
			$Apportion = "RU"
			LANG_KEYBOARD()
		Case $ButtonEN
			$Apportion = "EN"
			LANG_KEYBOARD()
		Case $Button42
			If $LockState = 0 Then
				$LockState = 1
				LOCK_KEYBOARD()
			ElseIf $LockState = 1 Then
				$LockState = 0
				LANG_KEYBOARD()
			EndIf
	EndSwitch
WEnd

Func LANG_KEYBOARD()
	If $Apportion = "RU" Then
		GUICtrlSetData($Button14, "ё")
		GUICtrlSetData($Button15, "1")
		GUICtrlSetData($Button16, '2')
		GUICtrlSetData($Button17, "3")
		GUICtrlSetData($Button18, "4")
		GUICtrlSetData($Button19, "5")
		GUICtrlSetData($Button20, "6")
		GUICtrlSetData($Button21, "7")
		GUICtrlSetData($Button22, "8")
		GUICtrlSetData($Button23, "9")
		GUICtrlSetData($Button24, "0")
		GUICtrlSetData($Button25, "-")
		GUICtrlSetData($Button26, "=")		
		GUICtrlSetData($Button29, "й")
		GUICtrlSetData($Button30, "ц")
		GUICtrlSetData($Button31, "у")
		GUICtrlSetData($Button32, "к")
		GUICtrlSetData($Button33, "е")
		GUICtrlSetData($Button34, "н")
		GUICtrlSetData($Button35, "г")
		GUICtrlSetData($Button36, "ш")
		GUICtrlSetData($Button37, "щ")
		GUICtrlSetData($Button38, "з")
		GUICtrlSetData($Button39, "х")
		GUICtrlSetData($Button40, "ъ")
		GUICtrlSetData($Button43, "ф")
		GUICtrlSetData($Button44, "ы")
		GUICtrlSetData($Button45, "в")
		GUICtrlSetData($Button46, "а")
		GUICtrlSetData($Button47, "п")
		GUICtrlSetData($Button48, "р")
		GUICtrlSetData($Button49, "о")
		GUICtrlSetData($Button50, "л")
		GUICtrlSetData($Button51, "д")
		GUICtrlSetData($Button52, "ж")
		GUICtrlSetData($Button53, "э")
		GUICtrlSetData($Button57, "я")
		GUICtrlSetData($Button58, "ч")
		GUICtrlSetData($Button59, "с")
		GUICtrlSetData($Button60, "м")
		GUICtrlSetData($Button61, "и")
		GUICtrlSetData($Button62, "т")
		GUICtrlSetData($Button63, "ь")
		GUICtrlSetData($Button64, "б")
		GUICtrlSetData($Button65, "ю")
		GUICtrlSetData($Button66, ".")
		GUICtrlSetData($Button78, "Brk")
	ElseIf $Apportion = "EN" Then
		GUICtrlSetData($Button14, "`")
		GUICtrlSetData($Button15, "1")
		GUICtrlSetData($Button16, '2')
		GUICtrlSetData($Button17, "3")
		GUICtrlSetData($Button18, "4")
		GUICtrlSetData($Button19, "5")
		GUICtrlSetData($Button20, "6")
		GUICtrlSetData($Button21, "7")
		GUICtrlSetData($Button22, "8")
		GUICtrlSetData($Button23, "9")
		GUICtrlSetData($Button24, "0")
		GUICtrlSetData($Button25, "-")
		GUICtrlSetData($Button26, "=")		
		GUICtrlSetData($Button29, "q")
		GUICtrlSetData($Button30, "w")
		GUICtrlSetData($Button31, "e")
		GUICtrlSetData($Button32, "r")
		GUICtrlSetData($Button33, "t")
		GUICtrlSetData($Button34, "y")
		GUICtrlSetData($Button35, "u")
		GUICtrlSetData($Button36, "i")
		GUICtrlSetData($Button37, "o")
		GUICtrlSetData($Button38, "p")
		GUICtrlSetData($Button39, "[")
		GUICtrlSetData($Button40, "]")
		GUICtrlSetData($Button43, "a")
		GUICtrlSetData($Button44, "s")
		GUICtrlSetData($Button45, "d")
		GUICtrlSetData($Button46, "f")
		GUICtrlSetData($Button47, "g")
		GUICtrlSetData($Button48, "h")
		GUICtrlSetData($Button49, "j")
		GUICtrlSetData($Button50, "k")
		GUICtrlSetData($Button51, "l")
		GUICtrlSetData($Button52, ";")
		GUICtrlSetData($Button53, "'")
		GUICtrlSetData($Button57, "z")
		GUICtrlSetData($Button58, "x")
		GUICtrlSetData($Button59, "c")
		GUICtrlSetData($Button60, "v")
		GUICtrlSetData($Button61, "b")
		GUICtrlSetData($Button62, "n")
		GUICtrlSetData($Button63, "m")
		GUICtrlSetData($Button64, ",")
		GUICtrlSetData($Button65, ".")
		GUICtrlSetData($Button66, "/")
		GUICtrlSetData($Button78, "Brk")
	EndIf
EndFunc   ;==>LANG_KEYBOARD

Func LOCK_KEYBOARD()
	If $Apportion = "RU" Then
		GUICtrlSetData($Button14, "Ё")
		GUICtrlSetData($Button15, "!")
		GUICtrlSetData($Button16, '"')
		GUICtrlSetData($Button17, "№")
		GUICtrlSetData($Button18, ";")
		GUICtrlSetData($Button19, "%")
		GUICtrlSetData($Button20, ":")
		GUICtrlSetData($Button21, "?")
		GUICtrlSetData($Button22, "*")
		GUICtrlSetData($Button23, "(")
		GUICtrlSetData($Button24, ")")
		GUICtrlSetData($Button25, "_")
		GUICtrlSetData($Button26, "+")
		GUICtrlSetData($Button29, "Й")
		GUICtrlSetData($Button30, "Ц")
		GUICtrlSetData($Button31, "У")
		GUICtrlSetData($Button32, "К")
		GUICtrlSetData($Button33, "Е")
		GUICtrlSetData($Button34, "Н")
		GUICtrlSetData($Button35, "Г")
		GUICtrlSetData($Button36, "Ш")
		GUICtrlSetData($Button37, "Щ")
		GUICtrlSetData($Button38, "З")
		GUICtrlSetData($Button39, "Х")
		GUICtrlSetData($Button40, "Ъ")
		GUICtrlSetData($Button41, "/")
		GUICtrlSetData($Button43, "Ф")
		GUICtrlSetData($Button44, "Ы")
		GUICtrlSetData($Button45, "В")
		GUICtrlSetData($Button46, "А")
		GUICtrlSetData($Button47, "П")
		GUICtrlSetData($Button48, "Р")
		GUICtrlSetData($Button49, "О")
		GUICtrlSetData($Button50, "Л")
		GUICtrlSetData($Button51, "Д")
		GUICtrlSetData($Button52, "Ж")
		GUICtrlSetData($Button53, "Э")
		GUICtrlSetData($Button57, "Я")
		GUICtrlSetData($Button58, "Ч")
		GUICtrlSetData($Button59, "С")
		GUICtrlSetData($Button60, "М")
		GUICtrlSetData($Button61, "И")
		GUICtrlSetData($Button62, "Т")
		GUICtrlSetData($Button63, "Ь")
		GUICtrlSetData($Button64, "Б")
		GUICtrlSetData($Button65, "Ю")
		GUICtrlSetData($Button66, ",")
		GUICtrlSetData($Button78, "Pau")
	ElseIf $Apportion = "EN" Then
		GUICtrlSetData($Button14, "~")
		GUICtrlSetData($Button15, "!")
		GUICtrlSetData($Button16, "@")
		GUICtrlSetData($Button17, "#")
		GUICtrlSetData($Button18, "$")
		GUICtrlSetData($Button19, "%")
		GUICtrlSetData($Button20, "^")
		GUICtrlSetData($Button21, "&")
		GUICtrlSetData($Button22, "*")
		GUICtrlSetData($Button23, "(")
		GUICtrlSetData($Button24, ")")
		GUICtrlSetData($Button25, "_")
		GUICtrlSetData($Button26, "+")
		GUICtrlSetData($Button29, "Q")
		GUICtrlSetData($Button30, "W")
		GUICtrlSetData($Button31, "E")
		GUICtrlSetData($Button32, "R")
		GUICtrlSetData($Button33, "T")
		GUICtrlSetData($Button34, "Y")
		GUICtrlSetData($Button35, "U")
		GUICtrlSetData($Button36, "I")
		GUICtrlSetData($Button37, "O")
		GUICtrlSetData($Button38, "P")
		GUICtrlSetData($Button39, "{")
		GUICtrlSetData($Button40, "}")
		GUICtrlSetData($Button41, "|")
		GUICtrlSetData($Button43, "A")
		GUICtrlSetData($Button44, "S")
		GUICtrlSetData($Button45, "D")
		GUICtrlSetData($Button46, "F")
		GUICtrlSetData($Button47, "G")
		GUICtrlSetData($Button48, "H")
		GUICtrlSetData($Button49, "J")
		GUICtrlSetData($Button50, "K")
		GUICtrlSetData($Button51, "L")
		GUICtrlSetData($Button52, ":")
		GUICtrlSetData($Button53, '"')
		GUICtrlSetData($Button57, "Z")
		GUICtrlSetData($Button58, "X")
		GUICtrlSetData($Button59, "C")
		GUICtrlSetData($Button60, "V")
		GUICtrlSetData($Button61, "B")
		GUICtrlSetData($Button62, "N")
		GUICtrlSetData($Button63, "M")
		GUICtrlSetData($Button64, "<")
		GUICtrlSetData($Button65, ">")
		GUICtrlSetData($Button66, "?")
		GUICtrlSetData($Button78, "Pau")
	EndIf
EndFunc   ;==>LOCK_KEYBOARD
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Скажите хотя бы как отправить символ с помощью функции Send() в любое активное окно, но ни своё, как в стандартной виртуальной клавиатуре на WinXP
 

Belfigor

Модератор
Локальный модератор
Сообщения
3,600
Репутация
940
Код:
ControlSend("[CLASS:Notepad]",  "",  "Edit1",  "This is a line of text in the notepad window")
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Ну это мы в Notepad отпраляем, а скрипт должен отправлять в любое активное окно, допустим в браузер или MicrosoftWord
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,320
Viktor1703 [?]
как отправить символ с помощью функции Send() в любое активное окно
ИМХО, Send() отправляет символы как раз в активное окно:
Код:
Dim $aArray[11][2] = [[10]]
For $i = 1 To $aArray[0][0]
	$aArray[$i][0] = Run(@WindowsDir & '\notepad.exe')
	Sleep(100)
Next
Sleep(500)
$aList = WinList('[Class:Notepad]')
If Not $aList[0][0] Then
	MsgBox(16, 'Error', 'Error')
	Exit
EndIf
For $i = 1 To $aList[0][0]
	For $j = 1 To $aArray[0][0]
		If WinGetProcess($aList[$i][1]) = $aArray[$j][0] Then
			$aArray[$j][1] = $aList[$i][1]
			WinSetTitle($aArray[$j][1], '', WinGetTitle($aArray[$j][1]) & '  ' & $j)
			ExitLoop
		EndIf
	Next
Next
For $i = 1 To $aArray[0][0]
	WinActivate($aArray[$i][1])
	If WinWaitActive($aArray[$i][1], '', 3) Then
		Send(WinGetTitle($aArray[$i][1]) & ' - Активное окно')
		Sleep(250)
	EndIf
Next
If MsgBox(36, 'Info', 'Закрываем?') = 6 Then
	For $i = 1 To $aArray[0][0]
		ProcessClose($aArray[$i][0])
	Next
EndIf
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Ну тогда в чём магия,открываю стандартную виртуальную клавиатуру в Windows XP, она постоянно находится поверх всех окон, открываю браузер и пишу в него текст набирая на вирт. клавиатуре, при этом клавиатура никуда не девается и остаётся в рабочем режиме, в чём секрет такого переключения окон?

Всё, зделал

Код:
#Include <WinAPIEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $iHandle

$hForm = GUICreate("", 300, 200)
WinSetOnTop($hForm, "", 1)
$hButton = GUICtrlCreateButton("A", 10, 10, 20, 20)
GUISetState()

While 1
	$tPoint = _WinAPI_GetMousePos()
	$hGetHandle = _WinAPI_GetAncestor(_WinAPI_WindowFromPoint($tPoint), $GA_ROOT)
	
	If $hGetHandle <> $hForm Then
		$iHandle = $hGetHandle
	EndIf

    Switch GUIGetMsg()
		Case -3
			Exit
		Case $hButton
			WinSwitch($iHandle)
			Send("A")
	EndSwitch
Wend	
    
Func WinSwitch($hWnd)
	WinActivate($hWnd)
EndFunc
 

madmasles

Модератор
Глобальный модератор
Сообщения
7,790
Репутация
2,320
Viktor1703 [?]
открываю стандартную виртуальную клавиатуру
Может, как-то так?
Код:
#include <GUIConstantsEx.au3>

Global $hWinActive

$hGui = GUICreate('Test', 230, 70)
$nButtonA = GUICtrlCreateButton('a', 20, 20, 50, 30)
$nButtonB = GUICtrlCreateButton('b', 90, 20, 50, 30)
$nButtonC = GUICtrlCreateButton('c', 160, 20, 50, 30)
GUISetState(@SW_SHOWNOACTIVATE)
AdlibRegister('_GetActive', 100)

While 1
	WinSetOnTop($hGui, '', 1)
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			Exit
		Case $nButtonA
			If $hWinActive Then
				WinActivate($hWinActive)
				WinWaitActive($hWinActive)
				Send('a')
			EndIf
		Case $nButtonB
			If $hWinActive Then
				WinActivate($hWinActive)
				WinWaitActive($hWinActive)
				ControlSend($hWinActive, '', '', 'b')
			EndIf
		Case $nButtonC
			If $hWinActive Then
				WinActivate($hWinActive)
				WinWaitActive($hWinActive)
				Send('c')
			EndIf
	EndSwitch
WEnd

Func _GetActive()
	Local $h_Win = WinGetHandle('[ACTIVE]')
	If $h_Win <> $hGui Then
		If $hWinActive <> $h_Win Then
			$hWinActive = $h_Win
		EndIf
	EndIf
EndFunc   ;==>_GetActive
 
Автор
V

Viktor1703

AutoIT Гуру
Сообщения
1,535
Репутация
413
Да, замечательно, но сразу возникла другая проблема, у меня используется скин на окне, а значит у меня 2 хэндэла, то есть скин создаёт дочернее окно, и когда я навожу на кнопку в своём окне, то получается активирую дочернее окно, вот как только узнать хэндл дочернего окна? Класс я знаю, WinGetHandle("[CLASS:SCALPHAWINDOW]") попробывал, работает, но раз через раз и очень долго


Добавлено:
Сообщение автоматически объединено:

Всё, зделал, всем спасибо!
 
Верх