liquid Posted August 28, 2005 Share Posted August 28, 2005 hey all! im a newbie to all this and new in the forum to and my question is: how do i run a program when i klick on a icon in my GUI. im planning to make a cool program and game launcher as a school project. Link to comment Share on other sites More sharing options...
BigDod Posted August 28, 2005 Share Posted August 28, 2005 You could create a button and use a picture on it instead of text. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
liquid Posted August 28, 2005 Author Share Posted August 28, 2005 (edited) You could create a button and use a picture on it instead of text.<{POST_SNAPBACK}>ok i will try that! so the icon thing isnt a good idea? and how do i insert a picture inside the button? Edited August 28, 2005 by liquid Link to comment Share on other sites More sharing options...
BigDod Posted August 28, 2005 Share Posted August 28, 2005 ok i will try that! so the icon thing isnt a good idea?<{POST_SNAPBACK}>It may be a good enough idea but I do not know how to do it Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
liquid Posted August 28, 2005 Author Share Posted August 28, 2005 It may be a good enough idea but I do not know how to do it<{POST_SNAPBACK}>ok thanks anyway Link to comment Share on other sites More sharing options...
Dickb Posted August 28, 2005 Share Posted August 28, 2005 (edited) Hi, I've made an example program to help you on your way. Look in the help file how to change things to your wishes. Have fun with it. Dick EDIT: change the names of the icon and bmp file to someting on your pc. Else you get blank buttons. #include <GUIConstants.au3> $GuiMain = GUICreate("Button Test", 200, 100) $btnIcon = GUICtrlCreateButton("", 10, 25, 50, 50, $BS_ICON) GUICtrlSetImage($btnIcon, "FileType2.ico") $btnBmp = GUICtrlCreateButton("", 75, 25, 50, 50, $BS_ICON) GUICtrlSetImage($btnBmp, "Newtion.bmp") $btnPict = GUICtrlCreatePic("Newtion.bmp", 140, 25, 50, 50) GUISetState(@SW_SHOW) While(1) $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit Case $Msg = $btnIcon MsgBox(0, "Button", "Icon Clicked") Case $Msg = $btnBmp MsgBox(0, "Button", "Picture Buttonclicked") Case $Msg = $btnPict MsgBox(0, "Picture", "Picture Clicked") EndSelect WEnd Exit Edited August 28, 2005 by Dickb Link to comment Share on other sites More sharing options...
liquid Posted August 28, 2005 Author Share Posted August 28, 2005 Hi,I've made an example program to help you on your way.Look in the help file how to change things to your wishes.Have fun with it.DickEDIT: change the names of the icon and bmp file to someting on your pc. Else you get blank buttons.#include <GUIConstants.au3> $GuiMain = GUICreate("Button Test", 200, 100) $btnIcon = GUICtrlCreateButton("", 10, 25, 50, 50, $BS_ICON) GUICtrlSetImage($btnIcon, "FileType2.ico") $btnBmp = GUICtrlCreateButton("", 75, 25, 50, 50, $BS_ICON) GUICtrlSetImage($btnBmp, "Newtion.bmp") $btnPict = GUICtrlCreatePic("Newtion.bmp", 140, 25, 50, 50) GUISetState(@SW_SHOW) While(1) $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit Case $Msg = $btnIcon MsgBox(0, "Button", "Icon Clicked") Case $Msg = $btnBmp MsgBox(0, "Button", "Picture Buttonclicked") Case $Msg = $btnPict MsgBox(0, "Picture", "Picture Clicked") EndSelect WEnd Exit<{POST_SNAPBACK}>thank u verru much, but now i wonder how to bind the button to a file like an .exei hope im not to now Link to comment Share on other sites More sharing options...
Dickb Posted August 28, 2005 Share Posted August 28, 2005 thank u verru much, but now i wonder how to bind the button to a file like an .exei hope im not to now<{POST_SNAPBACK}>I made a litte change to the example.Now every button will start notepad. Is this what you want?Replace notepad with the program name you want to start.#include <GUIConstants.au3> $GuiMain = GUICreate("Button Test", 200, 100) $btnIcon = GUICtrlCreateButton("", 10, 25, 50, 50, $BS_ICON) GUICtrlSetImage($btnIcon, "FileType2.ico") $btnBmp = GUICtrlCreateButton("", 75, 25, 50, 50, $BS_ICON) GUICtrlSetImage($btnBmp, "Newtion.bmp") $btnPict = GUICtrlCreatePic("Newtion.bmp", 140, 25, 50, 50) GUISetState(@SW_SHOW) While(1) $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit Case $Msg = $btnIcon Run("Notepad.exe") Case $Msg = $btnBmp Run("Notepad.exe") Case $Msg = $btnPict Run("Notepad.exe") EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
liquid Posted August 28, 2005 Author Share Posted August 28, 2005 (edited) I made a litte change to the example.Now every button will start notepad. Is this what you want?Replace notepad with the program name you want to start.#include <GUIConstants.au3> $GuiMain = GUICreate("Button Test", 200, 100) $btnIcon = GUICtrlCreateButton("", 10, 25, 50, 50, $BS_ICON) GUICtrlSetImage($btnIcon, "FileType2.ico") $btnBmp = GUICtrlCreateButton("", 75, 25, 50, 50, $BS_ICON) GUICtrlSetImage($btnBmp, "Newtion.bmp") $btnPict = GUICtrlCreatePic("Newtion.bmp", 140, 25, 50, 50) GUISetState(@SW_SHOW) While(1) $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit Case $Msg = $btnIcon Run("Notepad.exe") Case $Msg = $btnBmp Run("Notepad.exe") Case $Msg = $btnPict Run("Notepad.exe") EndSelect WEnd Exit<{POST_SNAPBACK}>thats exactly what i want! thank you but ure script is wierd, when i start it 101 notepads show up Edited August 28, 2005 by liquid Link to comment Share on other sites More sharing options...
Dickb Posted August 28, 2005 Share Posted August 28, 2005 thats exactly what i want! thank you but ure script is wierd, when i start it 101 notepads show up<{POST_SNAPBACK}>I have tested it (copied and pasted). Only one notepad is starting.Tested with Autoit 3.1.1 and beta 3.1.1.70. Both versions are working.Check your code (or better, start with a copy and paste)Are you sure the "$Msg = GUIGetMsg()" is inside the While loop? Link to comment Share on other sites More sharing options...
BigDod Posted August 28, 2005 Share Posted August 28, 2005 I have tested it (copied and pasted). Only one notepad is starting.Tested with Autoit 3.1.1 and beta 3.1.1.70. Both versions are working.Check your code (or better, start with a copy and paste)Are you sure the "$Msg = GUIGetMsg()" is inside the While loop?<{POST_SNAPBACK}>I copied and pasted it and I get loads and loads of notepad. I closed it before it reached 101. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Dickb Posted August 28, 2005 Share Posted August 28, 2005 I copied and pasted it and I get loads and loads of notepad. I closed it before it reached 101.<{POST_SNAPBACK}>I'm sorry, but that is a mistery to me. Works fine on my computer. Link to comment Share on other sites More sharing options...
liquid Posted August 28, 2005 Author Share Posted August 28, 2005 I'm sorry, but that is a mistery to me. Works fine on my computer.<{POST_SNAPBACK}>ok this is what i want: when i click my little firefox icon firefox.exe will start, here's my script so far; ----------------------------------------------------------------------------;; AutoIt Version: 3.1.0; Author: LiquiD;; Script Function:; My own program launcher!.;; ----------------------------------------------------------------------------; Script Start - Add your code below here#include <GuiConstants.au3>SplashImageOn("APL", "add_your_image" , 300 , 200)Sleep(3000)SplashOff(); GUIGuiCreate("APL 0.1", 200, 600);the icons!GUICtrlCreateButton ("firefox", 10,20,40,40, $BS_icon)GUICtrlSetImage (-1, "C:\Program\Mozilla Firefox\firefox.exe",2);ist always open now, untill it closes..duh!!GUISetState ()While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoopWendnow what do i need to do to make this happen? Link to comment Share on other sites More sharing options...
Dickb Posted August 28, 2005 Share Posted August 28, 2005 I've changed part of your code. My filefox is in the "Program Files" directory. This should help you on your way. ;the icons! $btnFireFox = GUICtrlCreateButton("firefox", 10, 20, 40, 40, $BS_icon) GUICtrlSetImage(-1, "C:\Program Files\Mozilla Firefox\firefox.exe", 2) ;ist always open now, untill it closes..duh!! GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $btnFireFox Then Run("C:\Program Files\Mozilla Firefox\firefox.exe") WEnd Link to comment Share on other sites More sharing options...
liquid Posted August 28, 2005 Author Share Posted August 28, 2005 I've changed part of your code. My filefox is in the "Program Files" directory.This should help you on your way.;the icons! $btnFireFox = GUICtrlCreateButton("firefox", 10, 20, 40, 40, $BS_icon) GUICtrlSetImage(-1, "C:\Program Files\Mozilla Firefox\firefox.exe", 2) ;ist always open now, untill it closes..duh!! GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $btnFireFox Then Run("C:\Program Files\Mozilla Firefox\firefox.exe") WEnd<{POST_SNAPBACK}>worked like a charm, now im starting to get the hang of things. Thanks Dickb Link to comment Share on other sites More sharing options...
Dickb Posted August 28, 2005 Share Posted August 28, 2005 You're welcome Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now