Zedna Posted May 15, 2007 Share Posted May 15, 2007 (edited) I know there are another "Net Send" scripts but I used some new techniques not used elsewhereso I share it to other users here.It uses:NET VIEW - to list active computers (in DropDown)NET SEND - to send messageOn recipient's computer must be running Messenger service.It don't work on Win 9x/MeIn window title is shown name of computer and also description of computer in brackets if defined.Application can be minimized to tray icon and restored by doubleclick.I'm sorry for labels in Czech language. I'm too lazy to translate it to English.If there will be big interest I can translate it to English.EDIT: Now all translated to English EDIT: New version with InitMessangerService() and MessangerIsRunning() check and statusbar showing whether Messenger service is running, when it's not running then try to start itadded also screenshot expandcollapse popup#Compiler_Icon=net_send.ico #NoTrayIcon #include "Constants.au3" #include "GUIConstants.au3" If @OSType = "WIN32_WINDOWS" Then Exit Global Const $WM_COMMAND = 0x0111 Global Const $CBN_DROPDOWN = 7 Global $pc_desc = RegRead('HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters','srvcomment') Global $sender = @ComputerName If $pc_desc <> '' Then $sender &= ' (' & $pc_desc & ')' Opt("TrayMenuMode",1) Opt("TrayOnEventMode",1) TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TrayEvent") TraySetState(2) ; hide #Region ### START Koda GUI section ### Form= $gui = GUICreate("Net Send - " & $sender, 373, 186) GUICtrlCreateLabel("R&ecipient:", 10, 14, 51, 20) $cbx_computers = GUICtrlCreateCombo("", 68, 12, 280, 120) GUICtrlSetFont($cbx_computers, 9, 400, "", "Courier New") GUICtrlCreateLabel("&Message: ", 10, 56, 51, 17) $ed_message = GUICtrlCreateEdit("", 68, 54, 280, 64, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) ; $WS_VSCROLL $btn_send = GUICtrlCreateButton("&Send", 150, 130, 80, 25, 0) $status = GUICtrlCreateLabel("", 0, 168, 372, 17, -1, $WS_EX_CLIENTEDGE) GUICtrlSetState($cbx_computers, $GUI_FOCUS) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") InitMessangerService() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_EVENT_MINIMIZE TrayShow(1) ; show Case $msg = $btn_send $CPUID = GUICtrlRead($cbx_computers) $msg = GUICtrlRead($ed_message) SendNetMessage($CPUID, $msg) EndSelect WEnd Exit Func TrayEvent() TrayShow(0) ; hide EndFunc Func TrayShow($show) ; 0/1 hide/show If $show Then GuiSetState(@SW_HIDE) TraySetState(1) ; show TraySetToolTip ("Net Send") Else GuiSetState(@SW_Show) TraySetState(2) ; hide EndIf EndFunc Func LoadComputers() $computers = '' $computer_list = '' $foo = Run(@ComSpec & ' /c net view', @ScriptDir, @SW_HIDE, $STDOUT_CHILD) While 1 $computers &= StdoutRead($foo) If @error Then ExitLoop WEnd If $computers <> '' Then $computers = DllCall('user32.dll','Int','OemToChar','str',$computers ,'str','') ; translate from OEM to ANSI $computers = StringSplit($computers[2], @CRLF, 1) For $i = 1 To $computers[0] $line = $computers[$i] $line = StringStripWS($line,2) ; strip trailing white space $pos = StringInStr($line, "\\") If $pos <> 1 Then ContinueLoop $line = StringTrimLeft($line, 2) $computer_list &= $line & "|" Next $computer_list = StringTrimRight($computer_list, 1) EndIf GUICtrlSetData($cbx_computers, '|All|' & $computer_list) EndFunc Func SendNetMessage($recipient, $message) If $recipient = '' Then MsgBox(48,'Warning', 'Recipient is empty!') Return EndIf If $message = '' Then MsgBox(48,'Warning', 'Message is empty!') Return EndIf GUISetCursor(15,1,$gui) $message &= @CRLF & @CRLF & 'Message from: ' & $sender $message = StringReplace($message,@CRLF,Chr(182)) If $recipient = 'All' Then $recipient = '*' Else ; remove description of computer (we want only computer name) $blankpos = StringInStr($recipient, " ") ; note: when typed by hand may be or not any space If $blankpos > 0 Then $recipient = StringLeft($recipient, $blankpos - 1) EndIf ;~ $result = RunWait(@ComSpec & " /c net send " & $CPUID & " " & $msg, "", @SW_HIDE) $foo = Run(@ComSpec & " /c net send " & $recipient & " " & $message, "", @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) $result = '' While 1 $result &= StdoutRead($foo) If @error Then ExitLoop WEnd $err = '' While 1 $err &= StderrRead($foo) If @error Then ExitLoop WEnd $result &= $err $result = DllCall('user32.dll','Int','OemToChar','str',$result ,'str','') ; translate from OEM to ANSI GUISetCursor(2,0,$gui) If $err = '' Then $icon_id = 64 Else $icon_id = 48 EndIf MsgBox($icon_id+262144,'Information', $result[2]) EndFunc Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = _HiWord($wParam) Local $nID = _LoWord($wParam) Local $hCtrl = $lParam Switch $nID Case $cbx_computers Switch $nNotifyCode Case $CBN_DROPDOWN LoadComputers() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _HiWord($x) Return BitShift($x, 16) EndFunc Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc Func InitMessangerService() GUICtrlSetData($status, 'Checking status of Messenger service ...') ; run automatically $type = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Messenger','Start') If $type <> 2 Then RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Messenger','Start','REG_DWORD',2) If MessangerIsRunning() Then $status_text = 'Messenger service is running' Else GUICtrlSetData($status, 'Messenger service is not running - starting service ...') RunWait(@ComSpec & " /c " & 'Net start Messenger', "", @SW_HIDE) If MessangerIsRunning() Then $status_text = 'Messenger service is running' Else $status_text = 'Messenger service is not running' EndIf EndIf GUICtrlSetData($status, $status_text) EndFunc Func MessangerIsRunning() $disp_name = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Messenger','DisplayName') $foo = Run(@ComSpec & ' /c net start', @ScriptDir, @SW_HIDE, $STDOUT_CHILD) $services = '' While 1 $services &= StdoutRead($foo) If @error Then ExitLoop WEnd $services = DllCall('user32.dll','Int','OemToChar','str',$services ,'str','') ; translate from OEM to ANSI $services = StringSplit($services[2], @CRLF, 1) For $i = 1 To $services[0] $line = StringStripWS($services[$i],3) ; strip leading/trailing white space If $line = $disp_name Then Return 1 Next Return 0 EndFuncHere is also script for check whether Messenger service is running:#include "Constants.au3" MsgBox(0,'Messanger',MessangerIsRunning()) Func MessangerIsRunning() $disp_name = RegRead('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Messenger','DisplayName') $foo = Run(@ComSpec & ' /c net start', @ScriptDir, @SW_HIDE, $STDOUT_CHILD) $services = '' While 1 $services &= StdoutRead($foo) If @error Then ExitLoop WEnd $services = DllCall('user32.dll','Int','OemToChar','str',$services ,'str','') ; translate from OEM to ANSI $services = StringSplit($services[2], @CRLF, 1) For $i = 1 To $services[0] $line = StringStripWS($services[$i],3) ; strip leading/trailing white space If $line = $disp_name Then Return 1 Next Return 0 EndFuncStart Messenger service:Run(@ComSpec & " /c " & 'Net start Messenger', "", @SW_HIDE)Stop Messenger service:Run(@ComSpec & " /c " & 'Net stop Messenger', "", @SW_HIDE) EDIT: fixed corrupted topic after forum upgradenet_send.ico Edited July 20, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
November Posted May 15, 2007 Share Posted May 15, 2007 I would ... but i cant... i dont know Czech! It send messages like net send? i cant try because corporate firewall blocks it! Well going to see the code... looks really usefull! great job cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Zedna Posted May 15, 2007 Author Share Posted May 15, 2007 (edited) I would ... but i cant... i dont know Czech!Now translation to English is done It send messages like net send?Yes. It uses:NET VIEW - to list active computers (in DropDown)NET SEND - to send message Edited May 15, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
November Posted May 16, 2007 Share Posted May 16, 2007 Now translation to English is done Yes. It uses:NET VIEW - to list active computers (in DropDown)NET SEND - to send messageGreat job... its really usefull for computer browse!Keep the great work Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
Cyber Posted May 16, 2007 Share Posted May 16, 2007 FANTASTIC! VERY WONDERFULL! Console Browse: Navigate on the WEB in a textual consoleMultiPing!: Show computer on the lan and/or show the local/remote task, ALL animated!KillaWin: Event executingCryptPage: Crypt your webpage and show only with key Link to comment Share on other sites More sharing options...
Zedna Posted May 16, 2007 Author Share Posted May 16, 2007 november Posted Today, 03:35 PM Great job... its really usefull for computer browse!Keep the great workFANTASTIC! VERY WONDERFULL!Thanks for positive feedback There is new version - check first post. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
lordicast Posted December 1, 2007 Share Posted December 1, 2007 i get ==> Can not redeclare a constant.: Global $WM_COMMAND = 0x0111 Global ^ ERROR [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
corey822 Posted December 1, 2007 Share Posted December 1, 2007 i get ==> Can not redeclare a constant.: Global $WM_COMMAND = 0x0111 Global ^ ERRORme 2 C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake Link to comment Share on other sites More sharing options...
Developers Jos Posted December 1, 2007 Developers Share Posted December 1, 2007 Just comment the line out and try again.. shouldn't be to hard ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
corey822 Posted December 1, 2007 Share Posted December 1, 2007 Just comment the line out and try again.. shouldn't be to hard ...yes lol had to comment out 2 line for it to work now all i need is a lan to test on C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake Link to comment Share on other sites More sharing options...
Michel Claveau Posted December 1, 2007 Share Posted December 1, 2007 (edited) Hi! Little problem: NET SEND no longer exist in Vista... Good luck, for found other thing. (edit: on Vista, you must use then command MSG ; try MSG /?) Edited December 1, 2007 by Michel Claveau Link to comment Share on other sites More sharing options...
lordicast Posted December 2, 2007 Share Posted December 2, 2007 now it just hangs when drop down is used.. i have to end process to stop. [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
Zedna Posted December 2, 2007 Author Share Posted December 2, 2007 now it just hangs when drop down is used..i have to end process to stop.When dropdown is opened script runs NET VIEW to get list of computers.If NET VIEW is slow you must wait to dropdown finish its opening.You can change script to make NET VIEW once at start of script (and not at opening dropdown)but then you will be waiting at start and you will not have fresh computer list if you have running script for long time.In my office network NET VIEW is very quick in most cases but sometimes it's very slow so I must wait too. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
CoePSX Posted December 3, 2007 Share Posted December 3, 2007 Here's a method to send messages without using Run, and you can even change the sender name that appears on the message (good for formatting the name of even kidding)http://www.autoitscript.com/forum/index.php?showtopic=30735 [quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"]╔══════════════════════════════╗║░░██░░░░░░░░██░░███░░░████░░░█║║░█░░█░░██░░█░░█░█░░█░█░░░░█░█░║║░█░░░░█░░█░████░███░░░██░░░█░░║║░█░░█░█░░█░█░░░░█░░░░░░░█░█░█░║║░░██░░░██░░░██░░█░░░░███░█░░░█║╚══════════════════════════════╝[/font] Link to comment Share on other sites More sharing options...
Zedna Posted December 3, 2007 Author Share Posted December 3, 2007 Here's a method to send messages without using Run, and you can even change the sender name that appears on the message (good for formatting the name of even kidding)http://www.autoitscript.com/forum/index.php?showtopic=30735Thanks for info.It looks like advanced system deep technique :-) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ahstax Posted February 17, 2012 Share Posted February 17, 2012 Hello, I'm completely new with AutoIt... so please excuse my perhaps very much to dump questions... I copied the code to the editor. Using "Tools", "Go (F5)" resulted to following error (I guess...) $ed_message = GUICtrlCreateEdit("", 68, 54, 280, 64, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) $ed_message = GUICtrlCreateEdit("", 68, 54, 280, 64, BitOR(^ ERROR What has to be done to handle it? And... is there a newer version available using msg.exe? 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