Turing ++ > Predefs to add functionality [Windows]
Author |
Message |
Wolf_Destiny
|
Posted: Mon Sep 11, 2006 8:28 pm Post subject: Turing ++ > Predefs to add functionality [Windows] |
|
|
Before I begin, the commands included in the predef file are only tested on Windows XP Pro, I'm not saying that they won't work on other systems, but I don't know whether or not other systems will support the DOS commands used. (If you test all the commands on a different platform, please list the ones that work/don't work, and your platform so that I can try to find equivelants)
What I've done: I've created a new predef .tu file to start blending the functionality of Windows commands into an easy to use Turing Command set.
We all know that with Sys.Exec you can carry out any DOS command right? Most people also know that you can run files with their default programs by putting them into Sys.Exec...but what about when you're done with them? How do you close them? "With the mouse duh". Okay so how does TURING close them?
I've outlined how to shutdown the computer, reboot it, list running programs, and close any given program on this help thread. But isn't there an easier way?
Now there is. I hope for this to become an ever expanding - cross platform predef file, as I find and add functionality to it. I'm also planning on making an updater for it, if I update frequently.
->If you don't know how to add a predef file, don't worry I'm detailing how to do that later.
What does the file do so far?
Version 1.0.1 - First Release
Note: To stay independant of the Sys file, it includes it's own private use Execute command for accessing the command.com
code: | tasklist : boolean
%Lists all the currently running processes,
% closes quickly however, and may need to be used in an actual command prompt
%Returns true if successful, false if not |
code: | killtask (task:string) : boolean
%Immediately forces the task with Image Name (task) to close
%Returns true if successful, false if not |
code: | shutdown (timer : int, message : string) : boolean
%Counts down "timer" seconds displaying "message" until finally shutting down the computer
%Returns true if successful, false if not |
code: | reboot (timer : int, message : string) : boolean
%Counts down "timer" seconds displaying "message" until finally rebooting the computer
%Returns true if successful, false if not |
code: | stop_shutdown : boolean
%Immediately stops a shutdown/reboot currently counting down
%Returns true if successful, false if not |
Using taskkill: (Refer to the bit about finding the Image Name)
Quote: How does [killtask] work?
First off, you need to know what's called the "image name", that the program runs under. Example firefox's image name is "firefox.exe" it's simply, but neccessary. So to do this:
1. Open your program of choice (the one that Turing will close).
2. Start Menu -> Run -> Command [enter]
3. Type: "tasklist" (no quotes) and press enter.
4. Scroll around looking under the first heading (image name) until you find your program.
5. Write down the image name somewhere.
6. Then substitute the image name into this code:
code: | taskkill -F -IM <imagenamehere> |
So to close firefox immediately:
code: | taskkill -F -IM firefox.exe |
7. Put that line into a Sys.Exec Structure.
code: | if Sys.Exec ("taskkill -F -IM firefox.exe") then
put "This program just closed firefox, how d'ya like that?"
end if |
A closer look:
-F tells the command prompt to force the program to close
-IM tells the command prompt that the image name is to follow
<imagenamehere> tells the command prompt what the heck you want to close
So instead of running:
code: | if Sys.Exec ("taskkill -F -IM firefox.exe") then
put "This program just closed firefox, how d'ya like that?"
end if |
You can now use:
code: | if killtask ("firefox.exe") then
put "This program just closed firefox, how d'ya like that?"
end if |
No more syntax additions!
I hope I've explained how it works sufficiently, but if you have any questions, post and ask! I'll be happy to answer them. Also any suggestions for additions to the project are also welcomed, as I'm at a bit of a loss now...
==========Adding a new Predef File!==========
If you already know how to do this, you could at least benefit from the ability to copy and paste.
->Download to come, don't worry!<-
1. First off, download the .tu file.
2. Put it in your "Turing\Support\Predefs\" folder.
3. Open the file "Predefs.lst" in any text editer.
4. Scroll to the bottom.
5. Add these lines to the end EXACTLY AS IS:
code: | % Contains commands for adding Windows functionality to Turing /*%ADDED%*/
"%oot/support/predefs/WIN_XP.tu" /*%ADDED%*/ |
6. The /*%ADDED%*/ bit can be taken out, but if it doesn't work, this works as a label to tell you what to remove!
7. Save the file. NOT Save as, just save. (Prevents the text editer from adding it's own file type)
8. Test the new commands! They're done! They're in!
==========Download Section==========
Rapidshare Link: Click Here
Try to primarily use the rapidshare link, if the file is no longer there, PM me and I'll repost it. If it isn't working for you, feel free to use the compsci link below.
The file isn't zipped as it is so small. This way you can save it directly to the predef folder.
Description: |
|
Download |
Filename: |
WIN_XP.tu |
Filesize: |
2.69 KB |
Downloaded: |
87 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Wolf_Destiny
|
Posted: Mon Sep 11, 2006 8:36 pm Post subject: If... |
|
|
If neither of the downloads work for you, or you think this is easier, here is the source code for the file "WIN_XP.tu" (This also justifies this post being in "Source Code")
>MAKE SURE you give it the right name!!
code: | /*
* Turing ++ | Version: 1.0.1
* ->Expansion to blend functionality of Turing and Windows
* ->Untested with any version of Windows except XP-Pro
*
* By: Steven Lyon
*
* NB: DO NOT IMPORT OR INCLUDE THIS FILE INTO YOUR PROGRAM.
* IT WILL BE IMPLICITLY IMPORTED.
*/
unit
module pervasive WIN_XP
export tasklist, killtask, shutdown, reboot, stop_shutdown
%In order to beat down version dependancies
%%Sys.Exec has the non-exported mirror of Execute
external "sys_exec" function Execute (str : string) : boolean %1.0.1
%Run "tasklist" in cmd
%%Autocloses *Needs some sort of fix
function tasklist : boolean
if Execute ("tasklist") then
result true
else
result false
end if
end tasklist %1.0.1
%Kill the task with Image Name "task"
function killtask (task : string) : boolean
if Execute ("taskkill -F -IM " + task) then
result true
else
result false
end if
end killtask %1.0.1
%Shutdown in "timer" seconds displaying "message"
%%No countdown if timer = 0, no message if message = ""
function shutdown (timer : int, message : string) : boolean
if timer not= 0 then
if message = "" then
if Execute ("shutdown -s -t " + intstr (timer)) then
result true
else
result false
end if
else
if Execute ("shutdown -s -t " + intstr (timer) + " -c " + message) then
result true
else
result false
end if
end if
else
if message = "" then
if Execute ("shutdown -s") then
result true
else
result false
end if
else
if Execute ("shutdown -s -c " + message) then
result true
else
result false
end if
end if
end if
end shutdown %1.0.1
%Reboot in "timer" seconds displaying "message"
%%No countdown if timer = 0, no message if message = ""
function reboot (timer : int, message : string) : boolean
if timer not= 0 then
if message = "" then
if Execute ("shutdown -r -t " + intstr (timer)) then
result true
else
result false
end if
else
if Execute ("shutdown -r -t " + intstr (timer) + " -c " + message) then
result true
else
result false
end if
end if
else
if message = "" then
if Execute ("shutdown -r") then
result true
else
result false
end if
else
if Execute ("shutdown -r -c " + message) then
result true
else
result false
end if
end if
end if
end reboot %1.0.1
function stop_shutdown : boolean
if Execute ("shutdown -a") then
result true
else
result false
end if
end stop_shutdown %1.0.1
end WIN_XP |
Enjoy!
~Wolf_Destiny
|
|
|
|
|
|
|
|