Sign in to follow this  
Followers 0
AlphaWolf

Help (programs)

11 posts in this topic

Hi,

could anyone help me with a piece of code im trying to learn,im trying to make a program to launch other programs,very simple,but when i use the run command for a button,it comes up with a random number (4 digits). I would like it say something like You have just launched "Program" , very simple,just a dropmenu or a button.

Please help me,i really wonna get into coding,im only 14,so want to start early.

Thanks

Joe


Share this post


Link to post
Share on other sites



Hi,

could anyone help me with a piece of code im trying to learn,im trying to make a program to launch other programs,very simple,but when i use the run command for a button,it comes up with a random number (4 digits). I would like it say something like You have just launched "Program" , very simple,just a dropmenu or a button.

Please help me,i really wonna get into coding,im only 14,so want to start early.

Thanks

Joe

Joe, it's difficult to help anyone without the actual code they are using.

What I am going to assume is you are using a variable with run:

$var = Run(...)

In this case, $var will actually be the PID (process identification) of the process you just executed.

If you are trying to get the name of the process just ran, look at the example in the help file under _ProcessGetName().


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Hi,

could anyone help me with a piece of code im trying to learn,im trying to make a program to launch other programs,very simple,but when i use the run command for a button,it comes up with a random number (4 digits). I would like it say something like You have just launched "Program" , very simple,just a dropmenu or a button.

Please help me,i really wonna get into coding,im only 14,so want to start early.

Thanks

Joe

Those 4 digits are probably because of the return value of that function is the PID of the program process that you are starting with Run().

Share this post


Link to post
Share on other sites

I am using:

GuiCtrlCreateButton("Run (program)", Positioning)

in a very plain background

please try and help muttley

Thanks

Joe

Note: i am very new to this


Share this post


Link to post
Share on other sites

Sorry:

Full Script:

#include <GuiConstantsEx.au3>

; GUI

GuiCreate("Sample GUI", 400, 400)

GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; MENU

GuiCtrlCreateMenu("Context Menu")

GuiCtrlCreateMenu("Menu&Two")

GuiCtrlCreateMenu("MenuTh&ree")

GuiCtrlCreateMenu("Menu&Four")

; CONTEXT MENU

$contextMenu = GuiCtrlCreateContextMenu()

GuiCtrlCreateMenuItem("Context Menu", $contextMenu)

GuiCtrlCreateMenuItem("", $contextMenu) ;separator

GuiCtrlCreateMenuItem("&Properties", $contextMenu)

; BUTTON

GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)

; GUI MESSAGE LOOP

GuiSetState()

While GuiGetMsg() <> $GUI_EVENT_CLOSE

WEnd


Share this post


Link to post
Share on other sites

Sorry:

Full Script:

#include <GuiConstantsEx.au3>

; GUI

GuiCreate("Sample GUI", 400, 400)

GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

; MENU

GuiCtrlCreateMenu("Context Menu")

GuiCtrlCreateMenu("Menu&Two")

GuiCtrlCreateMenu("MenuTh&ree")

GuiCtrlCreateMenu("Menu&Four")

; CONTEXT MENU

$contextMenu = GuiCtrlCreateContextMenu()

GuiCtrlCreateMenuItem("Context Menu", $contextMenu)

GuiCtrlCreateMenuItem("", $contextMenu) ;separator

GuiCtrlCreateMenuItem("&Properties", $contextMenu)

; BUTTON

GuiCtrlCreateButton("Sample Button", 10, 330, 100, 30)

; GUI MESSAGE LOOP

GuiSetState()

While GuiGetMsg() <> $GUI_EVENT_CLOSE

WEnd

@Joe...

That doesn't do anything at all, where are you getting the display of 4 numbers? What exactly do you need help with? I believe I gave you the answer to your original question.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Sorry,i sent you the wrong bit,i cant find the but that worked,but i know it used :

GuiCtrlCreateButton("Paint", Run (mspaint)10, 330, 100, 30)

, but i know that doesnt work,it was something along that line, but i didnt use PID or $var, or atleast i dont think it did muttley

sorry,you'll have to be patient,im new to coding,but really want to be a coder or something later in my life :)


Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Sorry,i sent you the wrong bit,i cant find the but that worked,but i know it used :

GuiCtrlCreateButton("Paint", Run (mspaint)10, 330, 100, 30)

, but i know that doesnt work,it was something along that line, but i didnt use PID or $var, or atleast i dont think it did muttley

sorry,you'll have to be patient,im new to coding,but really want to be a coder or something later in my life :)

Run returns the PID as I said, you are using Run.

So simply assign a variable to Run: $i_PID = Run(etc..):

After you execute the above, then use _ProcessGetName() (repeating myself here).

Now go try that, if it fails, then post all the code you are using, along with the failing attempts.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thanks for that, but i think we might be getting confused,im try to get the button to execute the program, if im just stupid or something,or anoying you,just say so,or dont reply,before i wanted the button to execute say mspaint,and a box came up with 4 random numbers,but i dont know whats going on now.

Sorry for any bother

Joe


Share this post


Link to post
Share on other sites

Thanks for that, but i think we might be getting confused,im try to get the button to execute the program, if im just stupid or something,or anoying you,just say so,or dont reply,before i wanted the button to execute say mspaint,and a box came up with 4 random numbers,but i dont know whats going on now.

Sorry for any bother

Joe

Ahh, you are actually Running Paint as you are launching that way.
Global $h_gui, $h_mspaint, $i_paint_pid
$h_gui = GUICreate("Example")
$h_mspaint = GUICtrlCreateButton("Run mspaint", 10, 10, 100, 25)
GUISetState()
While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $h_mspaint
            If ControlGetText($h_gui, "", $h_mspaint) = "Run mspaint" Then
                $i_paint_pid = Run(@SystemDir & "\mspaint.exe")
                GUICtrlSetData($h_mspaint, "Close mspaint")
            Else
                ProcessClose($i_paint_pid)
                GUICtrlSetData($h_mspaint, "Run mspaint")
            EndIf
    EndSwitch
WEnd
I thought you just posted it wrong.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

thanks

i have to go,my sick uncle is better,so im off to go be with him,thanks so much for the help!

ill recomment you guys,and maybe donate muttley


Share this post


Link to post
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
Sign in to follow this  
Followers 0