 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
geekdude
Joined: 23 Nov 2009 Posts: 64
|
Posted: Sat Feb 20, 2010 5:31 pm Post subject: help with messenger scripts |
|
|
i have made a script that i do not want to run, as it can seriously damage my cpu if i made it wrong. i preferr to post it here because i am not very good with batch, and my freinds aren't either
i am also not too experienced with the fileappend command
do NOT try to run this code. i first need to perfect it.
| Code: | inputbox, n
inputbox, m
msgbox, % "is this right?`n" . n . "`n" . m
filedelete, messenger.bat ; clears the way for a new batch file
FileAppend,
(comments
sc config messenger start= auto; enable xp cmd message command
net start messenger ; start xp cmd message command
@echo off
echo MESSENGER ; write messenger on the cmd window
net send %n% %m% ; send message to private ip in network
net stop messenger ; stops xp messenger service
sc config messenger start= disabled; disables xp messenger service
EXIT; exits the batch window
), messenger.bat
run, messenger.bat ; runs the previously made batch file
filedelete, messenger.bat ; deletes the previously made batch file
exitapp |
EDIT:
| Code: | inputbox, n
inputbox, m
msgbox, % "is this right?`n" . n . "`n" . m
filedelete, messenger.bat ; clears the way for a new batch file
FileAppend,
(comments
sc config messenger start= auto ; enable xp cmd message command
net start messenger ; start xp cmd message command
@echo off
echo MESSENGER ; write messenger on the cmd window
net send %n% %m% ; send message to private ip in network
EXIT ; exits the cmd window
), messenger.bat
run, messenger.bat ; runs the previously made batch file
filedelete, messenger.bat ; deletes the previously made batch file
exitapp |
_________________ /\ /\ This is Kitty
(>';'<) Cut, copy, and paste kitty onto your sig.
((")(")) Help Kitty gain World Domination.
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
camerb
Joined: 19 Mar 2009 Posts: 547 Location: Texas, USA
|
Posted: Sat Feb 20, 2010 10:36 pm Post subject: |
|
|
Not exactly sure what you're trying to do with this AHK. Why don't you try running one command, then ensure that the command ran the way you intended it to, then add another command to it, and so on...
Note that calling FileDelete immediately before FileAppend sometimes will not work. It seems that sometimes AHK appends before the file is removed. You should probably put a sleep command between the two.
Out of curiosity, why will this script damage your CPU?
Also (on a pickier note), I would make your script a bit more readable by putting the information that will be written out into a variable first... like:
| Code: | varfoo=file contents
FileAppend, %varfoo%, file.txt |
Or you could also put some line breaks in there around the FileAppend command. It took me a while to understand what the AHK was doing, and I doubt you'll remember in the future when you open the file back up again. _________________ Aren't you glad that I didn't put an annoying gif here? |
|
| Back to top |
|
 |
geekdude
Joined: 23 Nov 2009 Posts: 64
|
Posted: Mon Feb 22, 2010 5:48 pm Post subject: |
|
|
i am using it with ahk because i plan to make it into an executable that i can move around that will automatically set up the xp net-send messenger service and use an easy ahk interface to send the messages. i said not to run it because i know that command promp is very powerful and i dont know how to use it very well. thank you for the advise, i will start to work on it some more right away.
it is supposed to prompt you for ip's and messages to leave, and then make a batch file to send them. if you do not understand look at this
| Code: |
appskey::
gui, add, text,, your neighbor's private ip adress
gui, add, edit, vn
gui, add, text,, message
gui, add, edit, vm
gui, add, button, default gsubmit, submit
gui, show
return
submit:
gui, submit
gui, destroy
gui, add, text,, is this right?`n%n%`n%m%
gui, add, button, default gyes, yes
gui, add, button, gno, no
gui, show
return
no:
Exit ; supposedly stops current thread, eg (appskey, and appendend labels such as this one) but does not exit the script
return
yes:
filedelete, messenger.bat ; clears the way for a new batch file just in case
sleep, 500 ; to improve stability
FileAppend,
(comments
sc config messenger start= auto ; enable xp cmd message command
net start messenger ; start xp cmd message command
net send %n% %m% ; send message to private ip in network
net stop messenger ; stops xp messenger service
sc config messenger start= disabled ; disables xp messenger service
EXIT ; exits the cmd window
), messenger.bat
run, messenger.bat ; runs the previously made batch file
filedelete, messenger.bat ; deletes the previously made batch file
exitapp |
please help me with the uncertain things, such as the exit command in a label
note: untested _________________ /\ /\ This is Kitty
(>';'<) Cut, copy, and paste kitty onto your sig.
((")(")) Help Kitty gain World Domination.
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Last edited by geekdude on Mon Feb 22, 2010 8:42 pm; edited 1 time in total |
|
| Back to top |
|
 |
camerb
Joined: 19 Mar 2009 Posts: 547 Location: Texas, USA
|
Posted: Mon Feb 22, 2010 6:27 pm Post subject: |
|
|
You've got a lot of gosub commands in there. Especially for something this simple, you could use MsgBox, rather than using GUI (at least for your confirmation box).
Under your "no" label... Exit will exit the script, so your hotkey will no longer work after that. I'm guessing you want Return. To make that work, you'll probably need to rearrange the design of your AHK... are you planning on running your compiled ahk (the exe) on each computer more than once? I'm doubting that you will want to, so this should probably just be a script, rather than a hotkey tied to the appskey.
Exit command in a label... does this help?:
http://www.autohotkey.com/docs/commands/GuiControls.htm#Text
Not sure how many questions you had, so maybe I didn't answer all of them. _________________ Aren't you glad that I didn't put an annoying gif here? |
|
| Back to top |
|
 |
geekdude
Joined: 23 Nov 2009 Posts: 64
|
Posted: Mon Feb 22, 2010 8:40 pm Post subject: |
|
|
http://www.autohotkey.com/docs/commands/Exit.htm
i know that i could use msgbox, but i havent used it in a LONG time for y/n buttons.
from the link above:
| Quote: | | Otherwise, the Exit command terminates the current thread. In other words, the stack of subroutines called directly or indirectly by a menu, timer, or hotkey subroutine will all be returned from as though a Return were immediately encountered in each. If used directly inside such a subroutine -- rather than in one of the subroutines called indirectly by it -- Exit is equivalent to Return.[/code] |
_________________ /\ /\ This is Kitty
(>';'<) Cut, copy, and paste kitty onto your sig.
((")(")) Help Kitty gain World Domination.
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
camerb
Joined: 19 Mar 2009 Posts: 547 Location: Texas, USA
|
Posted: Mon Feb 22, 2010 8:50 pm Post subject: |
|
|
Good point. I was just thrown off by:
And figured I'd ask, since it seemed a little redundant. _________________ Aren't you glad that I didn't put an annoying gif here? |
|
| Back to top |
|
 |
geekdude
Joined: 23 Nov 2009 Posts: 64
|
Posted: Mon Feb 22, 2010 11:14 pm Post subject: |
|
|
its fine, i wasnt really sure if that was the command either until i looked it up to quote _________________ /\ /\ This is Kitty
(>';'<) Cut, copy, and paste kitty onto your sig.
((")(")) Help Kitty gain World Domination.
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|