Here is source with changed functions with code of sbav1 (no more putty needed)
Code: Select all
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author: moras86
Function: Samsung TV - PC Remote
#ce ----------------------------------------------------------------------------
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 0)
Global $IPaddr, $keycode
$IPaddr = IniRead(@ScriptDir & "\rctest.ini", "connect", "ip", "NotFound")
If $IPaddr = "NotFound" Then
MsgBox(4112, "Error", "Cant find IP address in .ini file")
Exit
Endif
HotKeySet("{END}", "koniec")
Opt("GUIOnEventMode",1)
GUICreate("Remote LAN Control :: Samsung", 350, 525)
GuiSetOnEvent($GUI_EVENT_CLOSE, "koniec")
$btn_power = GUICtrlCreateButton("Power OFF", 10, 10, 60, 25)
GUICtrlSetOnEvent($btn_Power, "key_power")
$btn_tv = GUICtrlCreateButton("TV", 10, 35, 60, 25)
GUICtrlSetOnEvent($btn_tv, "key_tv")
$btn_1 = GUICtrlCreateButton("1", 10, 60, 60, 25)
GUICtrlSetOnEvent($btn_1, "key_1")
$btn_2 = GUICtrlCreateButton("2", 70, 60, 60, 25)
GUICtrlSetOnEvent($btn_2, "key_2")
$btn_3 = GUICtrlCreateButton("3", 130, 60, 60, 25)
GUICtrlSetOnEvent($btn_3, "key_3")
$btn_4 = GUICtrlCreateButton("4", 10, 85, 60, 25)
GUICtrlSetOnEvent($btn_4, "key_4")
$btn_5 = GUICtrlCreateButton("5", 70, 85, 60, 25)
GUICtrlSetOnEvent($btn_5, "key_5")
$btn_6 = GUICtrlCreateButton("6", 130, 85, 60, 25)
GUICtrlSetOnEvent($btn_6, "key_6")
$btn_7 = GUICtrlCreateButton("7", 10, 110, 60, 25)
GUICtrlSetOnEvent($btn_7, "key_7")
$btn_8 = GUICtrlCreateButton("8", 70, 110, 60, 25)
GUICtrlSetOnEvent($btn_8, "key_8")
$btn_9 = GUICtrlCreateButton("9", 130, 110, 60, 25)
GUICtrlSetOnEvent($btn_9, "key_9")
$btn_favch = GUICtrlCreateButton("FAV.CH", 10, 135, 60, 25)
GUICtrlSetOnEvent($btn_favch, "key_favch")
$btn_0 = GUICtrlCreateButton("0", 70, 135, 60, 25)
GUICtrlSetOnEvent($btn_0, "key_0")
$btn_prech = GUICtrlCreateButton("PRE-CH", 130, 135, 60, 25)
GUICtrlSetOnEvent($btn_prech, "key_prech")
$btn_volup = GUICtrlCreateButton("VOL +", 10, 165, 60, 25)
GUICtrlSetOnEvent($btn_volup, "key_volup")
$btn_mute = GUICtrlCreateButton("MUTE", 70, 165, 60, 25)
GUICtrlSetOnEvent($btn_mute, "key_mute")
$btn_chup = GUICtrlCreateButton("CH +", 130, 165, 60, 25)
GUICtrlSetOnEvent($btn_chup, "key_chup")
$btn_voldn = GUICtrlCreateButton("VOL -", 10, 190, 60, 25)
GUICtrlSetOnEvent($btn_voldn, "key_voldn")
$btn_source = GUICtrlCreateButton("SOURCE", 70, 190, 60, 25)
GUICtrlSetOnEvent($btn_source, "key_source")
$btn_chdn = GUICtrlCreateButton("CH -", 130, 190, 60, 25)
GUICtrlSetOnEvent($btn_chdn, "key_chdn")
$btn_info = GUICtrlCreateButton("INFO", 10, 220, 60, 25)
GUICtrlSetOnEvent($btn_info, "key_info")
$btn_menu = GUICtrlCreateButton("MENU", 70, 220, 60, 35)
GUICtrlSetOnEvent($btn_menu, "key_menu")
$btn_guide = GUICtrlCreateButton("GUIDE", 130, 220, 60, 25)
GUICtrlSetOnEvent($btn_guide, "key_guide")
$btn_tools = GUICtrlCreateButton("TOOLS", 10, 245, 60, 25)
GUICtrlSetOnEvent($btn_tools, "key_tools")
$btn_return = GUICtrlCreateButton("RETURN", 130, 245, 60, 25)
GUICtrlSetOnEvent($btn_return, "key_return")
$btn_enter = GUICtrlCreateButton("ENTER", 75, 290, 50, 50)
GUICtrlSetOnEvent($btn_enter, "key_enter")
$btn_up = GUICtrlCreateButton("^", 70, 265, 60, 20)
GUICtrlSetOnEvent($btn_up, "key_up")
$btn_left = GUICtrlCreateButton("<", 50, 285, 20, 60)
GUICtrlSetOnEvent($btn_left, "key_left")
$btn_right = GUICtrlCreateButton(">", 130, 285, 20, 60)
GUICtrlSetOnEvent($btn_right, "key_right")
$btn_down = GUICtrlCreateButton("v", 70, 345, 60, 20)
GUICtrlSetOnEvent($btn_down, "key_down")
$btn_internet = GUICtrlCreateButton("INTERNET", 10, 355, 60, 25)
GUICtrlSetOnEvent($btn_internet, "key_internet")
$btn_exit = GUICtrlCreateButton("EXIT", 130, 355, 60, 25)
GUICtrlSetOnEvent($btn_exit, "key_exit")
$btn_red = GUICtrlCreateButton("R", 10, 385, 45, 25)
GUICtrlSetOnEvent($btn_red, "key_red")
$btn_green = GUICtrlCreateButton("G", 55, 385, 45, 25)
GUICtrlSetOnEvent($btn_green, "key_green")
$btn_yellow = GUICtrlCreateButton("Y", 100, 385, 45, 25)
GUICtrlSetOnEvent($btn_yellow, "key_yellow")
$btn_blue = GUICtrlCreateButton("B", 145, 385, 45, 25)
GUICtrlSetOnEvent($btn_blue, "key_blue")
$btn_ttx = GUICtrlCreateButton("TTX/MIX", 10, 415, 60, 25)
GUICtrlSetOnEvent($btn_ttx, "key_ttx")
$btn_media = GUICtrlCreateButton("MEDIA.P", 70, 415, 60, 25)
GUICtrlSetOnEvent($btn_media, "key_media")
$btn_content = GUICtrlCreateButton("CONTENT", 130, 415, 60, 25)
GUICtrlSetOnEvent($btn_content, "key_content")
$btn_chlist = GUICtrlCreateButton("CH LIST", 10, 440, 60, 25)
GUICtrlSetOnEvent($btn_chlist, "key_chlist")
$btn_ad = GUICtrlCreateButton("AD", 70, 440, 60, 25)
GUICtrlSetOnEvent($btn_ad, "key_ad")
$btn_subt = GUICtrlCreateButton("SUBT.", 130, 440, 60, 25)
GUICtrlSetOnEvent($btn_subt, "key_subt")
$btn_fb= GUICtrlCreateButton("<<", 10, 465, 60, 25)
GUICtrlSetOnEvent($btn_fb, "key_fb")
$btn_pause = GUICtrlCreateButton("| |", 70, 465, 60, 25)
GUICtrlSetOnEvent($btn_pause, "key_pause")
$btn_ff = GUICtrlCreateButton(">>", 130, 465, 60, 25)
GUICtrlSetOnEvent($btn_ff, "key_ff")
$btn_rec = GUICtrlCreateButton("REC ( )", 10, 490, 60, 25)
GUICtrlSetOnEvent($btn_rec, "key_rec")
$btn_play = GUICtrlCreateButton("PLAY >", 70, 490, 60, 25)
GUICtrlSetOnEvent($btn_play, "key_play")
$btn_stop = GUICtrlCreateButton("STOP [ ]", 130, 490, 60, 25)
GUICtrlSetOnEvent($btn_stop, "key_stop")
GuiCtrlCreateGroup("Extra keys", 198, 10, 145, 125)
$btn_dvb = GUICtrlCreateButton("DVB signal", 205, 25, 65, 25)
GUICtrlSetOnEvent($btn_dvb, "key_dvb")
$btn_sleep = GUICtrlCreateButton("Sleep", 270, 25, 65, 25)
GUICtrlSetOnEvent($btn_sleep, "key_sleep")
$btn_pip = GUICtrlCreateButton("PIP", 205, 50, 65, 25)
GUICtrlSetOnEvent($btn_pip, "key_pip")
$btn_psize = GUICtrlCreateButton("Picture size", 270, 50, 65, 25)
GUICtrlSetOnEvent($btn_psize, "key_psize")
$btn_smode = GUICtrlCreateButton("Sound mode", 205, 75, 65, 25)
GUICtrlSetOnEvent($btn_smode, "key_smode")
$btn_srs = GUICtrlCreateButton("SRS on/off", 270, 75, 65, 25)
GUICtrlSetOnEvent($btn_srs, "key_srs")
$btn_energy = GUICtrlCreateButton("Energy save", 205, 100, 65, 25)
GUICtrlSetOnEvent($btn_energy, "key_energy")
GUICtrlCreateGroup ("",-99,-99,1,1)
GuiCtrlCreateGroup("Picture mode", 198, 140, 145, 125)
$btn_pmode = GUICtrlCreateButton("Swich mode", 205, 155, 65, 25)
GUICtrlSetOnEvent($btn_pmode, "key_pmode")
$btn_p_user1 = GUICtrlCreateButton("User 1", 270, 155, 65, 25)
GUICtrlSetOnEvent($btn_p_user1, "key_p_user1")
$btn_p_dynamic = GUICtrlCreateButton("Dynamic", 205, 180, 65, 25)
GUICtrlSetOnEvent($btn_p_dynamic, "key_p_dynamic")
$btn_p_user2 = GUICtrlCreateButton("User 2", 270, 180, 65, 25)
GUICtrlSetOnEvent($btn_p_user2, "key_p_user2")
$btn_p_standard = GUICtrlCreateButton("Standard", 205, 205, 65, 25)
GUICtrlSetOnEvent($btn_p_standard, "key_p_standard")
$btn_p_user3 = GUICtrlCreateButton("User 3", 270, 205, 65, 25)
GUICtrlSetOnEvent($btn_p_user3, "key_p_user3")
$btn_p_movie = GUICtrlCreateButton("Movie", 205, 230, 65, 25)
GUICtrlSetOnEvent($btn_p_movie, "key_p_movie")
$btn_p_movie2 = GUICtrlCreateButton("Movie 2", 270, 230, 65, 25)
GUICtrlSetOnEvent($btn_p_movie2, "key_p_movie2")
GUICtrlCreateGroup ("",-99,-99,1,1)
GuiCtrlCreateGroup("Aspect ratio", 198, 270, 145, 50)
$btn_aspect43 = GUICtrlCreateButton("4:3", 205, 285, 65, 25)
GUICtrlSetOnEvent($btn_aspect43, "key_aspect43")
$btn_aspect169 = GUICtrlCreateButton("16:9", 270, 285, 65, 25)
GUICtrlSetOnEvent($btn_aspect169, "key_aspect169")
GUICtrlCreateGroup ("",-99,-99,1,1)
GuiCtrlCreateGroup("Direct source", 198, 325, 145, 125)
$btn_s_scart1 = GUICtrlCreateButton("Scart 1", 205, 340, 65, 25)
GUICtrlSetOnEvent($btn_s_scart1, "key_s_scart1")
$btn_s_hdmi1 = GUICtrlCreateButton("HDMI 1", 270, 340, 65, 25)
GUICtrlSetOnEvent($btn_s_hdmi1, "key_s_hdmi1")
$btn_s_scart2 = GUICtrlCreateButton("Scart 2", 205, 365, 65, 25)
GUICtrlSetOnEvent($btn_s_scart2, "key_s_scart2")
$btn_s_hdmi2 = GUICtrlCreateButton("HDMI 2", 270, 365, 65, 25)
GUICtrlSetOnEvent($btn_s_hdmi2, "key_s_hdmi2")
$btn_s_component = GUICtrlCreateButton("Component", 205, 390, 65, 25)
GUICtrlSetOnEvent($btn_s_component, "key_s_component")
$btn_s_vga = GUICtrlCreateButton("VGA (PC)", 270, 390, 65, 25)
GUICtrlSetOnEvent($btn_s_vga, "key_s_vga")
$btn_s_av = GUICtrlCreateButton("Composite", 205, 415, 65, 25)
GUICtrlSetOnEvent($btn_s_av, "key_s_av")
$btn_s_hdmi4 = GUICtrlCreateButton("HDMI 4", 270, 415, 65, 25)
GUICtrlSetOnEvent($btn_s_hdmi4, "key_s_hdmi4")
GUICtrlCreateGroup ("",-99,-99,1,1)
GuiCtrlCreateLabel("Remote LAN Control", 220, 468)
GuiCtrlSetColor(-1,0xaaa)
GuiCtrlCreateLabel("version: 0.01 beta", 220, 480)
GuiCtrlSetColor(-1,0xaaa)
GuiCtrlCreateLabel("by moras86", 264, 495)
GuiSetIcon("icon.ico", 0)
GUISetState()
While 1
Sleep(100)
WEnd
Func key_power()
$keycode = "2"
SendKeycode($keycode)
EndFunc
Func key_tv()
$keycode = "27"
SendKeycode($keycode)
EndFunc
Func key_1()
$keycode = "4"
SendKeycode($keycode)
EndFunc
Func key_2()
$keycode = "5"
SendKeycode($keycode)
EndFunc
Func key_3()
$keycode = "6"
SendKeycode($keycode)
EndFunc
Func key_4()
$keycode = "8"
SendKeycode($keycode)
EndFunc
Func key_5()
$keycode = "9"
SendKeycode($keycode)
EndFunc
Func key_6()
$keycode = "10"
SendKeycode($keycode)
EndFunc
Func key_7()
$keycode = "11"
SendKeycode($keycode)
EndFunc
Func key_8()
$keycode = "13"
SendKeycode($keycode)
EndFunc
Func key_9()
$keycode = "14"
SendKeycode($keycode)
EndFunc
Func key_0()
$keycode = "17"
SendKeycode($keycode)
EndFunc
Func key_favch()
$keycode = "68"
SendKeycode($keycode)
EndFunc
Func key_prech()
$keycode = "19"
SendKeycode($keycode)
EndFunc
Func key_volup()
$keycode = "7"
SendKeycode($keycode)
EndFunc
Func key_voldn()
$keycode = "11"
SendKeycode($keycode)
EndFunc
Func key_chup()
$keycode = "18"
SendKeycode($keycode)
EndFunc
Func key_chdn()
$keycode = "16"
SendKeycode($keycode)
EndFunc
Func key_mute()
$keycode = "15"
SendKeycode($keycode)
EndFunc
Func key_source()
$keycode = "1"
SendKeycode($keycode)
EndFunc
Func key_info()
$keycode = "31"
SendKeycode($keycode)
EndFunc
Func key_tools()
$keycode = "75"
SendKeycode($keycode)
EndFunc
Func key_guide()
$keycode = "79"
SendKeycode($keycode)
EndFunc
Func key_return()
$keycode = "88"
SendKeycode($keycode)
EndFunc
Func key_menu()
$keycode = "26"
SendKeycode($keycode)
EndFunc
Func key_enter()
$keycode = "104"
SendKeycode($keycode)
EndFunc
Func key_up()
$keycode = "96"
SendKeycode($keycode)
EndFunc
Func key_down()
$keycode = "97"
SendKeycode($keycode)
EndFunc
Func key_left()
$keycode = "101"
SendKeycode($keycode)
EndFunc
Func key_right()
$keycode = "98"
SendKeycode($keycode)
EndFunc
Func key_internet()
$keycode = "147"
SendKeycode($keycode)
EndFunc
Func key_exit()
$keycode = "45"
SendKeycode($keycode)
EndFunc
Func key_red()
$keycode = "108"
SendKeycode($keycode)
EndFunc
Func key_green()
$keycode = "20"
SendKeycode($keycode)
EndFunc
Func key_yellow()
$keycode = "21"
SendKeycode($keycode)
EndFunc
Func key_blue()
$keycode = "22"
SendKeycode($keycode)
EndFunc
Func key_ttx()
$keycode = "44"
SendKeycode($keycode)
EndFunc
Func key_media()
$keycode = "140"
SendKeycode($keycode)
EndFunc
Func key_content()
$keycode = "121"
SendKeycode($keycode)
EndFunc
Func key_chlist()
$keycode = "107"
SendKeycode($keycode)
EndFunc
Func key_ad()
$keycode = "0"
SendKeycode($keycode)
EndFunc
Func key_subt()
$keycode = "37"
SendKeycode($keycode)
EndFunc
Func key_fb()
$keycode = "69"
SendKeycode($keycode)
EndFunc
Func key_pause()
$keycode = "74"
SendKeycode($keycode)
EndFunc
Func key_ff()
$keycode = "72"
SendKeycode($keycode)
EndFunc
Func key_rec()
$keycode = "73"
SendKeycode($keycode)
EndFunc
Func key_play()
$keycode = "71"
SendKeycode($keycode)
EndFunc
Func key_stop()
$keycode = "70"
SendKeycode($keycode)
EndFunc
Func key_dvb()
$keycode = "45"
SendKeycode($keycode)
sleep("700")
$keycode = "26"
SendKeycode($keycode)
sleep("700")
$keycode = "96"
SendKeycode($keycode)
sleep("700")
$keycode = "104"
SendKeycode($keycode)
sleep("700")
$keycode = "97"
SendKeycode($keycode)
sleep("700")
$keycode = "104"
SendKeycode($keycode)
sleep("700")
$keycode = "96"
SendKeycode($keycode)
sleep("700")
$keycode = "104"
SendKeycode($keycode)
sleep("700")
EndFunc
Func key_sleep()
$keycode = "1"
SendKeycode($keycode)
EndFunc
Func key_pip()
$keycode = "32"
SendKeycode($keycode)
EndFunc
Func key_psize()
$keycode = "62"
SendKeycode($keycode)
EndFunc
Func key_smode()
$keycode = "43"
SendKeycode($keycode)
EndFunc
Func key_energy()
$keycode = "119"
SendKeycode($keycode)
EndFunc
Func key_srs()
$keycode = "110"
SendKeycode($keycode)
EndFunc
Func key_pmode()
$keycode = "40"
SendKeycode($keycode)
EndFunc
Func key_p_dynamic()
$keycode = "189"
SendKeycode($keycode)
EndFunc
Func key_p_standard()
$keycode = "223"
SendKeycode($keycode)
EndFunc
Func key_p_movie()
$keycode = "222"
SendKeycode($keycode)
EndFunc
Func key_p_user1()
$keycode = "220"
SendKeycode($keycode)
EndFunc
Func key_p_user2()
$keycode = "219"
SendKeycode($keycode)
EndFunc
Func key_p_user3()
$keycode = "218"
SendKeycode($keycode)
EndFunc
Func key_p_movie2()
$keycode = "221"
SendKeycode($keycode)
EndFunc
Func key_aspect43()
$keycode = "227"
SendKeycode($keycode)
EndFunc
Func key_aspect169()
$keycode = "228"
SendKeycode($keycode)
EndFunc
Func key_s_scart1()
$keycode = "132"
SendKeycode($keycode)
EndFunc
Func key_s_scart2()
$keycode = "235"
SendKeycode($keycode)
EndFunc
Func key_s_component()
$keycode = "134"
SendKeycode($keycode)
EndFunc
Func key_s_av()
$keycode = "236"
SendKeycode($keycode)
EndFunc
Func key_s_vga()
$keycode = "105"
SendKeycode($keycode)
EndFunc
Func key_s_hdmi1()
$keycode = "233"
SendKeycode($keycode)
EndFunc
Func key_s_hdmi2()
$keycode = "190"
SendKeycode($keycode)
EndFunc
Func key_s_hdmi4()
$keycode = "197"
SendKeycode($keycode)
EndFunc
Func SendKeycode($keycode)
Local $sc
TCPStartup()
While 1
$sc = TCPConnect($IPaddr, 2345)
If @error Then
MsgBox(4112, "Error", "TCPConnect failed with WSA error: " & @error)
ExitLoop
Endif
TCPSend($sc, $keycode & @LF)
TCPCloseSocket($sc)
ExitLoop
WEnd
TCPShutdown()
EndFunc
Func koniec()
Exit
EndFunc
Function key_dvb() is cool, i left sleep 700 ms, but i think time depends from CPU load and may varry. I think it is good to add user-defined functions (vote for most wanted functions?)
added guide key.
gui for IP address input.