Kardus Posted October 13, 2005 Share Posted October 13, 2005 This app is an edited version of slugsend, I changed it up to use in my school's network to message 3 of my peers (and for them to message me). A few of my other classmates saw it and now they all want to use it Instead of sending the message by checking the names off, I'd like to put in a text box so you can just type in the person's username in, and the message would be sent. If possible, it would be an added bonus if someone could help me add a feature to send the message to more than one user (sperated by commas in the textbox). I tried doing this but I'm having some problems, if anyone can help it'd be appreciated. I basically want to put a textbox in the area where the checkboxes/captions are (and get it working). Heres my code: expandcollapse popup; Proof-of-Concept for a net-send-based messenger program ; CyberSlug: Original code 3 July 2004 ; Revised for new GUI syntax 10 December 2004 ; Gui Recode to 3.1.1 15 August 2005 ; Update with own code by evod510 2005 #include <GuiConstants.au3> RunWait("net start messenger","",@SW_HIDE);Make sure messenger service is running Opt("WinWaitDelay", 10) ;speeds things up a little $MyGui = GuiCreate("Burlinator Messenger", 450,275,(@DesktopHeight-392)/2, (@DesktopHeight-359)/2 , 0x04CF0000) ;Controls might have word-wrap and/or read-only styles... maybe also styles to always show scroll bar... $txt_output = GuiCtrlCreateEdit("", 10, 10, 433, 170, 0x50231904, 0x00000200) ;$txt_input = GuiCtrlCreateEdit("Message goes here.", 10, 230, 370, 70, 0x50231104) $txt_input = GuiCtrlCreateEdit("Message goes here.", 10, 230, 430, 40, 0x50231104) GuiCtrlSetState($txt_input, $GUI_FOCUS);default control with focus $button_send = GUICtrlCreateButton("Send", 10, 190, 50, 30) $checkbox_topmost = GuiCtrlCreateCheckbox("Always On Top", 130, 190, 150, 30, $BS_PUSHLIKE);looks like button....;checkbox will be pushed in by default $button_sendclear = GUICtrlCreateButton("Clear", 70, 190, 50, 30) ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST NAME START;;;;;;;;;;;;;;;;;;;; $checkCN1 = GUICtrlCreateCheckbox ("Ninja", 290, 186, 50, 20) $checkCN2 = GUICtrlCreateCheckbox ("Sam Fisher", 290, 206, 75, 20) $checkCN3 = GUICtrlCreateCheckbox ("Rambo", 370, 186, 50, 20) $checkCN4 = GUICtrlCreateCheckbox ("Petesa Boy", 370, 206, 75, 20) ;$MainCheck = GUICtrlCreateCheckbox("Select/Unselect", 390, 130, 120, 20) ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST NAME END;;;;;;;;;;;;;;;;;;;;; GuiSetState(@SW_SHOW) GUICtrlSendMsg($txt_input, 0xB1, 0, 99999);I want the sample text message to be highlighted upon start ;MAIN MESSAGE LOOP While 1 sleep(5);sleep to prevent maxing out the CPU ; I want to trap the Enter key (but only when this GUI is active) so that it causes ; the message in the textbox to be send If WinActive($MyGui) Then HotKeySet("{Enter}", "EnterSends");register hotkey when our GUI messenger window is active Else HotKeySet("{Enter}");un-register hotkey otherwise EndIf ; Constantly poll to see if a Net Send Popup has appeared. If so, grab its contents and close it. If WinExists("Messenger Service", "Message from") Then Local $i, $t = "" $text = StringSplit( StringReplace(WinGetText("Messenger Service","Message from"),@CRLF,@LF) , @LF) WinClose("Messenger Service", "Message from") $sender = StringMid($text[2], 14, StringInStr($text[2]," to ")-14 ) $t = "" For $i = 4 to $text[0] $t = $t & $text[$i] & @CRLF Next $t = StringStripWS($t, 2);strip trailing whitespace ; Display contents from the Popup in the form '<TIME> SENDER: Message' GUICtrlSetData($txt_output, GUICtrlRead($txt_output) & "<" & @Hour & ":" & @Min & ":" & @Sec & "> " & $sender & ": " & $t & @CRLF) ;ControlFocus($MyGui, "", $txt_input);return focus back to the input field ControlFocus($MyGui, "", $txt_input) If WinActive ( "NetSend") Then TrayTip("clears any tray tip","",0) Else TrayTip("", "NetSend", 5) Sleep(1) EndIf EndIf $msg = GuiGetMsg() ; Get any GUI messag events Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_send EnterSends() Case $msg = $button_sendclear Enterclear() Case $msg = $checkbox_topmost If GUICtrlRead($checkbox_topmost) = 1 Then WinSetOnTop($MyGui, "", 1);checked for 'always on-top' window Else WinSetOnTop($MyGui, "", 0);unchecked for normal window EndIf EndSelect WEnd Exit Func EnterSends() ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST START;;;;;;;; $state1 = GUICtrlRead($checkCN1) $state2 = GUICtrlRead($checkCN2) $state3 = GUICtrlRead($checkCN3) $state4 = GUICtrlRead($checkCN4) ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST END;;;;;;;;; ControlFocus($MyGui, "", "Edit2") If StringStripWS(GUICtrlRead($txt_input), 3) = "" Then Return Local $message = """" & GUICtrlRead($txt_input) & """" ;wrap message in quotes Local $message2 = @ComputerName & " : " & GUICtrlRead($txt_input) ;wrap message in quotes ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST NAME 2 START;;;;;;;; if $state1 = 1 Then $arg1 = "brewjerm" Run('net send' & $arg1 & ' "' & $message & '"', '', @SW_HIDE) Else $arg1 = "" EndIf If $state2 = 1 Then $arg2 = "tyrrstev" Run('net send' & $arg2 & ' "' & $message & '"', '', @SW_HIDE) Else $arg2 = "" EndIf If $state3 = 1 Then $arg3 = "randchri" Run('net send' & $arg3 & ' "' & $message & '"', '', @SW_HIDE) Else $arg3 = "" EndIf If $state4 = 1 Then $arg4 = "sgangian" Run('net send' & $arg4 & ' "' & $message & '"', '', @SW_HIDE) Else $arg4 = "" EndIf ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST NAME 2 END;;;;;;;;; GuiCtrlSetData($txt_output, GUICtrlRead($txt_output) & "<" & @Hour & ":" & @Min & ":" & @Sec & "> " & $message2 & @CRLF) GuiCtrlSetData($txt_input, '') ;clear contents of textbox EndFunc Func Enterclear() GuiCtrlSetData($txt_output, '') ;clear contents of textbox Message Typed and Received, you dont anybody else to read your message!! EndFunc If anyone is wondering the arguements are the usernames (first 4 letters of surname followed by the first 4 letters of firstname). Link to comment Share on other sites More sharing options...
Rahul Rohela Posted October 15, 2005 Share Posted October 15, 2005 Try This......... ; Proof-of-Concept for a net-send-based messenger program ; CyberSlug: Original code 3 July 2004 ; Revised for new GUI syntax 10 December 2004 ; Gui Recode to 3.1.1 15 August 2005 ; Update with own code by evod510 2005 #include <GuiConstants.au3> RunWait("net start messenger","",@SW_HIDE);Make sure messenger service is running Opt("WinWaitDelay", 10) ;speeds things up a little $MyGui = GuiCreate("Burlinator Messenger", 450,275,(@DesktopHeight-392)/2, (@DesktopHeight-359)/2 , 0x04CF0000) ;Controls might have word-wrap and/or read-only styles... maybe also styles to always show scroll bar... $txt_output = GuiCtrlCreateEdit("", 10, 10, 433, 170, 0x50231904, 0x00000200) ;$txt_input = GuiCtrlCreateEdit("Message goes here.", 10, 230, 370, 70, 0x50231104) $txt_input = GuiCtrlCreateEdit("Message goes here.", 10, 230, 430, 40, 0x50231104) GuiCtrlSetState($txt_input, $GUI_FOCUS);default control with focus $button_send = GUICtrlCreateButton("Send", 10, 190, 50, 30) $checkbox_topmost = GuiCtrlCreateCheckbox("Always On Top", 130, 190, 150, 30, $BS_PUSHLIKE);looks like button....;checkbox will be pushed in by default $button_sendclear = GUICtrlCreateButton("Clear", 70, 190, 50, 30) ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST NAME START;;;;;;;;;;;;;;;;;;;; $checkCN1 = GUICtrlCreateInput ("Ninja", 290, 186, 75, 20) $checkCN2 = GUICtrlCreateInput ("Sam Fisher", 290, 206, 75, 20) $checkCN3 = GUICtrlCreateInput ("Rambo", 370, 186, 75, 20) $checkCN4 = GUICtrlCreateInput ("Petesa Boy", 370, 206, 75, 20) ;$MainCheck = GUICtrlCreateCheckbox("Select/Unselect", 390, 130, 120, 20) ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST NAME END;;;;;;;;;;;;;;;;;;;;; GuiSetState(@SW_SHOW) GUICtrlSendMsg($txt_input, 0xB1, 0, 99999);I want the sample text message to be highlighted upon start ;MAIN MESSAGE LOOP While 1 sleep(5);sleep to prevent maxing out the CPU ; I want to trap the Enter key (but only when this GUI is active) so that it causes ; the message in the textbox to be send If WinActive($MyGui) Then HotKeySet("{Enter}", "EnterSends");register hotkey when our GUI messenger window is active Else HotKeySet("{Enter}");un-register hotkey otherwise EndIf ; Constantly poll to see if a Net Send Popup has appeared. If so, grab its contents and close it. If WinExists("Messenger Service", "Message from") Then Local $i, $t = "" $text = StringSplit( StringReplace(WinGetText("Messenger Service","Message from"),@CRLF,@LF) , @LF) WinClose("Messenger Service", "Message from") $sender = StringMid($text[2], 14, StringInStr($text[2]," to ")-14 ) $t = "" For $i = 4 to $text[0] $t = $t & $text[$i] & @CRLF Next $t = StringStripWS($t, 2);strip trailing whitespace ; Display contents from the Popup in the form '<TIME> SENDER: Message' GUICtrlSetData($txt_output, GUICtrlRead($txt_output) & "<" & @Hour & ":" & @Min & ":" & @Sec & "> " & $sender & ": " & $t & @CRLF) ;ControlFocus($MyGui, "", $txt_input);return focus back to the input field ControlFocus($MyGui, "", $txt_input) If WinActive ( "NetSend") Then TrayTip("clears any tray tip","",0) Else TrayTip("", "NetSend", 5) Sleep(1) EndIf EndIf $msg = GuiGetMsg() ; Get any GUI messag events Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_send EnterSends() Case $msg = $button_sendclear Enterclear() Case $msg = $checkbox_topmost If GUICtrlRead($checkbox_topmost) = 1 Then WinSetOnTop($MyGui, "", 1);checked for 'always on-top' window Else WinSetOnTop($MyGui, "", 0);unchecked for normal window EndIf EndSelect WEnd Exit Func EnterSends() ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST START;;;;;;;; $state1 = GUICtrlRead($checkCN1) $state2 = GUICtrlRead($checkCN2) $state3 = GUICtrlRead($checkCN3) $state4 = GUICtrlRead($checkCN4) ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST END;;;;;;;;; ControlFocus($MyGui, "", "Edit2") If StringStripWS(GUICtrlRead($txt_input), 3) = "" Then Return Local $message = """" & GUICtrlRead($txt_input) & """" ;wrap message in quotes Local $message2 = @ComputerName & " : " & GUICtrlRead($txt_input) ;wrap message in quotes ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST NAME 2 START;;;;;;;; if $state1 = 1 Then $arg1 = "brewjerm" Run('net send' & $arg1 & ' "' & $message & '"', '', @SW_HIDE) Else $arg1 = "" EndIf If $state2 = 1 Then $arg2 = "tyrrstev" Run('net send' & $arg2 & ' "' & $message & '"', '', @SW_HIDE) Else $arg2 = "" EndIf If $state3 = 1 Then $arg3 = "randchri" Run('net send' & $arg3 & ' "' & $message & '"', '', @SW_HIDE) Else $arg3 = "" EndIf If $state4 = 1 Then $arg4 = "sgangian" Run('net send' & $arg4 & ' "' & $message & '"', '', @SW_HIDE) Else $arg4 = "" EndIf ;;;;;;;;;;;;;;;;;;;;;;CHECHBOX USERLIST NAME 2 END;;;;;;;;; GuiCtrlSetData($txt_output, GUICtrlRead($txt_output) & "<" & @Hour & ":" & @Min & ":" & @Sec & "> " & $message2 & @CRLF) GuiCtrlSetData($txt_input, '') ;clear contents of textbox EndFunc Func Enterclear() GuiCtrlSetData($txt_output, '') ;clear contents of textbox Message Typed and Received, you dont anybody else to read your message!! EndFunc Link to comment Share on other sites More sharing options...
Valuater Posted October 15, 2005 Share Posted October 15, 2005 i made one for our office that lists the computer names on the local network expandcollapse popupDim $un = @UserName Dim $QT_web = "www.XPCleanMenu.HostRocket.com" $ver = "1.0" ;delete last listing Filedelete(@TempDir & "\b.tmp") ; make sure net send is running RunWait("net start messenger","",@SW_HIDE) ;gets the computer list and a few other things RunWait(@ComSpec & ' /c net view > ' & @TempDir & '\a.tmp',"", @SW_HIDE) Sleep(300) ;open the file for working $file = FileOpen(@TempDir & "\a.tmp", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "QT - Error", "Unable to open file.") Exit EndIf ;Creates new file in which the result will be written FileOpen(@TempDir & "\b.tmp", 1) ; Read in lines of text until the EOF is reached in file a.tmp While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ;find the string "\\" $result = StringInStr($line,"\\") if $result = 1 Then ;find next blank $blankpos = StringInStr($line," ") ;Find length of line $len = StringLen($line) ;calculate from what position to Trim string to the right $len = $len - $blankpos ;Trim all characters after the computer name $line = StringTrimRight($line, $len) ;Trim the // $line = StringTrimLeft($line,2) ;Write line to file, adding "|" FileWrite(@TempDir & "\b.tmp", $line & "|") EndIf Wend FileClose($file) FileDelete(@TempDir & "\a.tmp") $file2 = FileReadline(@TempDir & "\b.tmp", 1) ;install pics $Time_Logo = @TempDir & "\Time-logo.jpg" FileInstall("C:\XPClean-web\Settings\XPClean-pics\Time.jpg", $Time_Logo) $Time_icon = @TempDir & "\Time-Icon.ico" FileInstall("C:\XPClean-web\Settings\XPClean-pics\Time-Icon.ico", $Time_icon) $Sound_clk = @TempDir & "\Sound_clk.wav" FileInstall("C:\XPClean-web\Settings\XPClean-pics\Sounds\Clickerx.wav", $Sound_clk) $Sound_grp = @TempDir & "\Sound_grp.wav" FileInstall("C:\XPClean-web\Settings\XPClean-pics\Sounds\Group_open.wav", $Sound_grp) $Sound_bar = @TempDir & "\Sound_bar.wav" FileInstall("C:\XPClean-web\Settings\XPClean-pics\Sounds\xpinfbar.wav", $Sound_bar) $Sound_lnk = @TempDir & "\Sound_lnk.wav" FileInstall("C:\XPClean-web\Settings\XPClean-pics\Sounds\Notify.wav", $Sound_lnk) ;GUI Start #include "GUIConstants.au3" ;#include <Process.au3> ;Set GUI Opt("GUICoordMode", 1) ;Opt("GUINotifyMode", 1) $Dummy_win = GUICreate('') $Tmesg_win = GuiCreate("*QTime Station* - PC Messenger ver " & $ver, 482, 335, -1, -1,-1,$WS_EX_ACCEPTFILES,$Dummy_win);, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetFont(9, 400, -1, "MS Sans Serif") GUISetIcon($Time_icon) $Icon_1 = GUICtrlCreatePic($Time_Logo, 393, 10, 75, 70) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "QTasc") $Group_1A = GuiCtrlCreateGroup( "Message from: ", 20, 10, 350, 50) GUICtrlCreateLabel( $un, 40, 30, 150, 20) ;Create 1 combo box, give focus and populate with contents of b.tmp $Group_1A = GuiCtrlCreateGroup("Message to: ",20, 70, 350, 50) $combo_1 = GUICtrlCreateCombo("", 130, 87, 120, 20) GUICtrlSetState(-1,$GUI_FOCUS) GUICtrlSetData(-1,$file2) $label_1 = GUICtrlCreateLabel( "C&hoose the PC", 40, 90, 150, 20) $Group_4 = GuiCtrlCreateGroup("Last Message Sent", 20, 270, 350, 50) $MSent = GUICtrlCreateLabel("No Recent Messages", 40, 288, 320, 28) ;Create buttons $button_1 = GUICtrlCreateButton("S&end", 390, 190, 80, 30) GUICtrlSetState(-1,$GUI_DEFBUTTON) $button_2 = GUICtrlCreateButton("Set-Up", 390, 275, 80, 20) $button_3 = GUICtrlCreateButton("C&ancel", 390, 300, 80, 20) ;create text input $Group_3 = GuiCtrlCreateGroup("Message Text", 20, 140, 350, 120) GUICtrlCreateLabel("Please Type in Your Test Message in the Box Below", 40, 165, 310, 20) GUICtrlCreateLabel("The Message includes the Time, Date, PC and Sender Name", 40, 185, 320, 20) $text = GUICtrlCreateInput("Message", 40, 215, 310, 20) ;Show the GUI GuiSetState (@SW_SHOW) SoundPlay ($Sound_lnk,1) ;sets tray icon opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. opt("TrayOnEventMode", 1) ;TraySetClick (16); right click $show_tray = TrayCreateItem ("Show *QTime Station*") TrayItemSetOnEvent (-1, "Set_Show") TrayCreateItem ("") $upgrade_tray = TrayCreateItem ("Check New Releases") TrayItemSetOnEvent (-1, "Set_Update") TrayCreateItem ("") $setup_tray = TrayCreateItem ("Net-Send Setup") TrayItemSetOnEvent (-1, "Set_Setup") TrayCreateItem ("") $about_tray = TrayCreateItem ("About QTasc") TrayItemSetOnEvent (-1, "Set_QT") TrayCreateItem ("") $exit_tray = TrayCreateItem ("Exit *QTime Station*") TrayItemSetOnEvent (-1, "Set_Exit") TraySetState () $msg = 0 While 1; $msg <> -3 $msg = GuiGetMsg() Select case $msg = $button_3 Or $msg = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $Tmesg_win) SoundPlay ($Sound_grp,1) case $msg = $button_2 ;SoundPlay ($Sound_clk,1) Call("Set_Setup") case $msg = $button_1 SoundPlay ($Sound_clk,1) $CPUID = GuictrlRead($combo_1) If $CPUID = "" Then MsgBox(64,"Send Error 1"," Please choose a PC to *Send* to... ") ContinueLoop EndIf $msg1 = GuictrlRead($text) If $msg1 = "" Or $msg1 = "Message" Then MsgBox(64,"Send Error 2"," Please Type a *Text Message* First... " ) ContinueLoop EndIf $runvar =RunWait(@comspec & " /c net send " & $CPUID & $un & " says: " & $msg1,"",@sw_hide) ;MsgBox(0,"",$runvar) If $runvar > 0 Then MsgBox(64,"Send Error 3"," Your Message *Could Not Be Sent* " & @CRLF & @CRLF & " Please press the *Set-Up* Button " & @CRLF & @CRLF & "and press *Set-Up* on " & $CPUID & " " ) ContinueLoop EndIf GUICtrlSetData ( $MSent, $msg1) EndSelect WEnd Exit ;---------------------------- FUNCTIONS ---------------------- Func Set_Update() SoundPlay ($Sound_clk,1) Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $QT_web) WinWaitActive("") EndFunc Func Set_Show() SoundPlay ($Sound_grp,1) GUISetState(@SW_SHOW, $Tmesg_win) EndFunc Func Set_QT() SoundPlay ($Sound_grp,1) $iMsgBoxAnswer = MsgBox(32, "*QTime Station* , by QTasc", "WHO IS, QT APPRAISAL SERVICE CO ?" & @CRLF & "" & @CRLF & "We are a Real Estate Appraisal Company based in Riverside, California. " & @CRLF & "" & @CRLF & "Thank you." & @CRLF & "" & @CRLF & "", 60) Select Case $iMsgBoxAnswer = -1;Timeout EndSelect SoundPlay ($Sound_grp,1) EndFunc Func Set_Exit() SoundPlay ($Sound_lnk,1) Exit EndFunc ;==>Set_Exit Func Set_Setup() SoundPlay ($Sound_clk,1) GUISetState(@SW_HIDE, $Tmesg_win) Run("mmc Services.msc -k netsvcs", @SystemDir) WinWaitActive("Services") Sleep(300) Send("{TAB}") Sleep(300) Send("Messenger") Sleep(300) Send("{ENTER}") Sleep(300) Send("!e") Sleep(300) Send("A") Sleep(300) Send("!A") Sleep(300) Send("!S") Sleep(2000) MsgBox(64,"Finished Set-up"," If all settings are satisfactory... " & @CRLF & " Please press *OK* ") While 3 If Not WinExists("Messenger Properties") Then ExitLoop Sleep(100) WEnd Sleep(100) WinClose("Services") EndFunc ;==>Set_Exit 8) Link to comment Share on other sites More sharing options...
Rahul Rohela Posted October 15, 2005 Share Posted October 15, 2005 HI $show_tray = TrayCreateItem ("Show *QTime Station*") Is giving error "Unknown function name"... Any idea??? Link to comment Share on other sites More sharing options...
LxP Posted October 15, 2005 Share Posted October 15, 2005 Sounds like you need to install the beta and ensure that you run your scripts with it (and not the release version, which will happen by default). Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now