Jump to content

My first finished (still updating) ''program''


deus
 Share

Recommended Posts

Hi there,

I've made this script to let myself and others know that im new @ scripting.

Well here it goes : My first script ! :)

CODE
#cs

My first script. Hope its good for a beginner :)

#ce

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 0)

; Not really sure what this does, but it ain't running without it ..

Script()

Func Script()

Local $Button_1, $Button_2, $Button_3, $Button_4, $Button_5, $Button_6, $msg

GUICreate ( "" , 111, 220 )

Opt("GUICoordMode", 2)

$Button_1 = GUICtrlCreateButton("Notepad", 7, 10, 100)

$Button_2 = GUICtrlCreateButton("iTunes", -1, 10, 100)

$Button_3 = GUICtrlCreateButton("Mozilla Firefox", -1, 10, 100)

$Button_4 = GUICtrlcreatebutton("Paint", -1, 10, 100)

$Button_5 = GUICtrlcreatebutton("Info", -1, 10, 100)

$Button_6 = GUICtrlcreatebutton("Exit", -1, 10, 100)

GUISetState( @SW_SHOW )

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

MsgBox (0, "Goodbye", "Goodbye", 3)

Exit

Case $msg = $Button_1

Run( "notepad.exe" )

Case $msg = $Button_2

$itunes = Run ( "C:\Program Files\iTunes\iTunes.exe", "", @SW_MAXIMIZE )

if $itunes = 0 then MsgBox(0,"Error","you do not have itunes on your PC. Cannot run.")

Case $msg = $Button_3

$firefox = Run("C:\Program Files\Mozilla Firefox\firefox.exe", "", @SW_MAXIMIZE)

if $firefox = 0 then MsgBox(0,"Error","You do not have Mozzila Firefox on your PC. Cannot run.")

Case $msg = $Button_4

Run ("C:\Windows\System32\mspaint")

Case $msg = $Button_5

Run ("notepad.exe", "", @SW_SHOWNORMAL)

$exist = ProcessExists("notepad.exe")

if $exist <> 0 then

Sleep(1000)

Send ( "This is my first script im am glad i made it. "&@CRLF&"I know this is a noob script and not so exclusive but ive enjoied making it" )

Sleep ( 5000 )

WinClose ( "Untitled - Notepad")

Send ( "!n" )

Else

MsgBox(0,"Error","You do not have notepad on your PC. Cannot Run.")

EndIf

Case $msg = $Button_6

MsgBox (0, "Goodbye", "Goodbye", 3)

Exit

EndSelect

WEnd

EndFunc

I would be gratefull if you guys reply to this.

Had a lot of fun doing this.

Greetz , Deus

Deusfirstscript.exe

Link to comment
Share on other sites

First I Thank you for the reply ! ^_^

And second, I've got no idea what ur talking :) I will work at it, if I can find solutions

Greetz , Deus

PS* : You mean like its installing a game or sort, that you click the path where you would like to install it?

That would be great ! :)

Thanks

Link to comment
Share on other sites

Well you can do that too,

But what he meant is.

Where you have say... Case $msg = $Button_3

$firefox = Run("C:\Program Files\Mozilla Firefox\firefox.exe", "", @SW_MAXIMIZE)

He means let the user (who opens this program) choose what programs he wants to be opened etc.

So say, you have 4 input boxes. And a buton called set. Then 4 buttons next to the input boxes.

The user will type in the path to what they wish to open, (say it is firefox, itunes, autoit etc).. then they click set.

Set will then disable the input boxes, (greyed out, so you cannot type back into them), then set it so when you click a button it opens the they wish.

Say a quick example. (This is not copy and paste of course. Just snippets.

Start with,

4Input Boxes.

1 Button (Set)

4 Other buttons (Path1, Path2, Path3, Path4). (Start with these disabled at the start).

Case $SetButtons
    Global $Path1 = GUICtrlRead($Input1); obviously continue these for however many buttons you wish to allow.
    Global $Path2 = GUICtrlRead($Input2)
    GUICtrlSetState($Input1, $GUI_DISABLE);this then disables input1, also do the same for others.

Case $Button1
    RunProgram($Path1); opens program in path1

I think that would work etc.

Hope this helps.

[right][/right]

Link to comment
Share on other sites

  • Developers

; Not really sure what this does, but it ain't running without it ..
Script()
Geintje hoop ik :) Edited by Jos

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

I don't get where to put them. (sorry for not knowing things)

Could you copy it so I can copy it and upload it ? (A)

Really Really ! thank you (A)

__________________________________

Ive quick edited it and the result is an error

C:\Users\Steve\Desktop\scriptie.au3 (38) : ==> Variable used without being declared.:

Run($input1)

Run(^ ERROR

Edited by deus
Link to comment
Share on other sites

  • Developers

I don't get where to put them. (sorry for not knowing things)

Could you copy it so I can copy it and upload it ? (A)

Really Really ! thank you (A)

Not sure what you are asking here.

Jos

Edited by Jos

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

Here is a simple something i whipped up for you Deus.

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>


$Form1 = GUICreate("ProgramOpener", 243, 420, 225, 133)
$Input1 = GUICtrlCreateInput("", 24, 32, 201, 21)
$Input2 = GUICtrlCreateInput("", 24, 56, 201, 21)
$Input3 = GUICtrlCreateInput("", 24, 80, 201, 21)
$Input4 = GUICtrlCreateInput("", 24, 104, 201, 21)
$Button1 = GUICtrlCreateButton("Set", 24, 128, 201, 49, 0)
$Group1 = GUICtrlCreateGroup("Options", 8, 8, 225, 177)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button2 = GUICtrlCreateButton("Path1", 8, 192, 225, 49, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button3 = GUICtrlCreateButton("Path2", 8, 248, 227, 49, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button4 = GUICtrlCreateButton("Path3", 8, 304, 225, 49, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button5 = GUICtrlCreateButton("Path4", 8, 360, 225, 49, 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $Button1
            Global $Path1 = GUICtrlRead($Input1)
            Global $Path2 = GUICtrlread($Input2)
            Global $Path3 = GUICtrlread($Input3)
            Global $Path4 = GUICtrlRead($Input4)
            GUICtrlSetState($Input1, $GUI_DISABLE)
            GUICtrlSetState($Input2, $GUI_DISABLE)
            GUICtrlSetState($Input3, $GUI_DISABLE)
            GUICtrlSetState($Input4, $GUI_DISABLE)
            GUICtrlSetState($Button2, $GUI_ENABLE)
            GUICtrlSetState($Button3, $GUI_ENABLE)
            GUICtrlSetState($Button4, $GUI_ENABLE)
            GUICtrlSetState($Button5, $GUI_ENABLE)
            
        Case $Button2
            ShellExecute($Path1)
            
        Case $Button3
            ShellExecute($Path2)
        
        Case $Button4
            ShellExecute($Path3)
            
        Case $Button5
            ShellExecute($Path4)

    EndSwitch
WEnd

Obviously you will have to expand this.

Doing error checking etc, say if Global Path2 is not set to anything, Keep the button disabled or whatever.

Hope it helps you.

[right][/right]

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...