AutoHotkey Community

It is currently May 27th, 2012, 4:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: February 20th, 2010, 6:31 pm 
Offline

Joined: November 23rd, 2009, 2:11 pm
Posts: 104
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2010, 11:36 pm 
Offline

Joined: March 19th, 2009, 5:08 pm
Posts: 548
Location: Texas, USA
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 6:48 pm 
Offline

Joined: November 23rd, 2009, 2:11 pm
Posts: 104
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 February 22nd, 2010, 9:42 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 7:27 pm 
Offline

Joined: March 19th, 2009, 5:08 pm
Posts: 548
Location: Texas, USA
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 ... s.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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 9:40 pm 
Offline

Joined: November 23rd, 2009, 2:11 pm
Posts: 104
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 9:50 pm 
Offline

Joined: March 19th, 2009, 5:08 pm
Posts: 548
Location: Texas, USA
Good point. I was just thrown off by:
Code:
no:
Exit
return

And figured I'd ask, since it seemed a little redundant.

_________________
Aren't you glad that I didn't put an annoying gif here?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 12:14 am 
Offline

Joined: November 23rd, 2009, 2:11 pm
Posts: 104
its fine, :wink: 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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], JSLover, Mickers, rbrtryn and 69 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group