Jump to content
Sign in to follow this  
liquid

help with icons!

Recommended Posts

liquid

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. :whistle:

Share this post


Link to post
Share on other sites
BigDod

You could create a button and use a picture on it instead of text.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites
liquid

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 by liquid

Share this post


Link to post
Share on other sites
BigDod

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


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites
liquid

It may be a good enough idea but I do not know how to do it

<{POST_SNAPBACK}>

ok thanks anyway :whistle:

Share this post


Link to post
Share on other sites
Dickb

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 by Dickb

Share this post


Link to post
Share on other sites
liquid

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

<{POST_SNAPBACK}>

thank u verru much, but now i wonder how to bind the button to a file like an .exe

i hope im not to :whistle: now

Share this post


Link to post
Share on other sites
Dickb

thank u verru much, but now i wonder how to bind the button to a file like an .exe

i hope im not to :whistle: 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

Share this post


Link to post
Share on other sites
liquid

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 :whistle: but ure script is wierd, when i start it 101 notepads show up Edited by liquid

Share this post


Link to post
Share on other sites
Dickb

thats exactly what i want! thank you :whistle: 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?

Share this post


Link to post
Share on other sites
BigDod

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.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites
Dickb

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.

Share this post


Link to post
Share on other sites
liquid

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()

; GUI

GuiCreate("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 ExitLoop

Wend

now what do i need to do to make this happen?

Share this post


Link to post
Share on other sites
Dickb

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

Share this post


Link to post
Share on other sites
liquid

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 :whistle:

Share this post


Link to post
Share on other sites
Dickb

You're welcome

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  

×