Jump to content

button


Vaeb
 Share

Recommended Posts

hi!

I would like to change a button (button-bad) to a better looking button (button-good).

This is the script:

$back = GUICtrlCreateButton(" ", "630", "10", "57","53",$BS_BITMAP)
    GUICtrlSetImage($back, @ScriptDir & "\System\back.bmp")

the buttons:

Edited by Vaeb
Link to comment
Share on other sites

hi!

I would like to change a button (button-bad) to a better looking button (button-good).

This is the script:

$back = GUICtrlCreateButton(" ", "630", "10", "57","53",$BS_BITMAP)
    GUICtrlSetImage($back, @ScriptDir & "\System\back.bmp")

the buttons:

Can you say what the problem is that you need help with? Is it connected with the fact that you want a button to have either the button_good or button_bad image but you are not setting it to have either?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Okay:

button_good and button_bad are screenshots of my gui.

i made button_good by gimp.

so how can i make it to look like button good, by programming?

I hope you understand my weird reply. xD

Link to comment
Share on other sites

You have to place your bad and good pictures into directory of this script

AButton.au3:

#include <GuiConstants.au3>
Global $hWnd
Global $Width = 400, $Height = $Width
Global $Good = 1

$Style = $WS_THICKFRAME + $WS_POPUP
$StyleEx = $WS_EX_OVERLAPPEDWINDOW

$hWnd = GuiCreate("AJump (c) Valery Ivanov, 10 December 2007", $Width, $Height, (@DesktopWidth-$Width)/2, (@DesktopHeight-$Height)/2, $Style, $StyleEx)

$Button = GUICtrlCreateButton(" ", 10, 10, 57, 53, $BS_BITMAP)
GUICtrlSetImage($Button, @ScriptDir & "\button_good.bmp")

GuiSetState()

While 1
 $Msg = GUIGetMsg(1)
 Select 
  case $Msg[0] = $Button
     If $Good then 
       GUICtrlSetImage($Button, @ScriptDir & "\button_bad.bmp")
       $Good = 0
     else
       GUICtrlSetImage($Button, @ScriptDir & "\button_good.bmp")
       $Good = 1
    endif
  case $Msg[0] = $GUI_EVENT_CLOSE
       exit 
  endselect
WEnd

And enjoy it!

The point of world view

Link to comment
Share on other sites

no, this is not what i want.

I want the button back.bmp be transparent as you can see on SCREENSHOT button-good.

At the moment it looks like button-bad.

here is the button "back.bmp":

back.bmp

Link to comment
Share on other sites

no, this is not what i want.

I want the button back.bmp be transparent as you can see on SCREENSHOT button-good.

At the moment it looks like button-bad.

here is the button "back.bmp":

Make it a gif??
Link to comment
Share on other sites

of course i tried that.

i made a gif with transparent background.

but when i add back.gif to the script instead of back.bmp, it just creates a button without picture.

Link to comment
Share on other sites

Try use merlin.gif like pattern and this script:

#include <GuiConstants.au3>
Global $hWnd
Global $Width = 400, $Height = $Width
Global $Good = 1

$hWnd = GuiCreate('MyButton', $Width, $Height)
$Button = GUICreate("AButton", 68, 71, 10, 10,  $WS_POPUP,  BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD), $hWnd)
GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif", 0, 0, 0, 0)

GUISetState(@SW_SHOW, $Button)
GUISetState(@SW_SHOW, $hWnd)

While 1
 $Msg = GUIGetMsg(1)
  If WinActive('AButton','') then 
      MsgBox(0,'','Hi!')
      WinActivate('MyButton','')
  endif 
 Select 
  case $Msg[0] = $GUI_EVENT_CLOSE
    exit 
  endselect
WEnd

The point of world view

Link to comment
Share on other sites

Moreover, you can very easy create many Merlins.

Here they are 36 ones! Why not ?

#include <GuiConstants.au3>
Global $hWnd
Global $Width = 440, $Height = $Width
Global $Good = 1

$hWnd = GuiCreate('MyButton', $Width, $Height)

For $i = 1 to 6
For $j = 1 to 6
  $Button = GUICreate("AButton", 70, 70, 10 + 70*($i-1), 10 + 70*($j-1),  $WS_POPUP,  BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD), $hWnd)
  GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif", 0, 0, 0, 0)
    GUISetState(@SW_SHOW, $Button)
next
next

GUISetState(@SW_SHOW, $hWnd)

While 1
$Msg = GUIGetMsg(1)
  If WinActive('AButton','') then
      MsgBox(0,'','Hi!')
      WinActivate('MyButton','')
  endif
Select
  case $Msg[0] = $GUI_EVENT_CLOSE
    exit
  endselect
WEnd

The point of world view

Link to comment
Share on other sites

Why the heck can't I see the Button with this Script??

#include <GuiConstants.au3>

bla()

Func bla()
    $Gui1 = GUICreate("Standort", "701", "641")
    $Button = GUICreate("back", "630", "10", "57", "53",  $WS_POPUP,  BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD), $Gui1)
    GUICtrlCreatePic(@ScriptDir & "\System\back.gif",0,0,0,0)
    GUISetState(@SW_SHOW, $Button)
    GUISetState(@SW_SHOW, $Gui1)
    WinActivate('Standort','')
            
            
            
            
    While 1
        $Msg = GUIGetMsg()
        Switch $Msg
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
        If WinActive('back','') Then
                ;GUISetState(@SW_HIDE, $Gui1)
                ;main()
                MsgBox(0,'','Hi!')
                WinActivate('Standort','')
        EndIf
    WEnd
EndFunc
Edited by Vaeb
Link to comment
Share on other sites

The button isnt Transparent.

It just have a grey background.

I want to see the picture behind the button!

and when i move the parent window, the child window doesn't move too...

:)^_^

Link to comment
Share on other sites

i know how to make transparent images.

I have a button "back.gif".

and its background is transparent.

but the gui "$Button" (Standort) is not transparent. so i just see the background of the gui behind my transparent picture.

do you understand now?

Link to comment
Share on other sites

1. Place your back.gif into dir with this script.

2. Save it as MyTestImage.au3

3. Run MyTestImage.au3 from it's folder

#include <GuiConstants.au3>
Global $hWnd
Global $Width = 400, $Height = $Width
Global $Good = 1

$hWnd = GuiCreate('MyButton', $Width, $Height)
$Button = GUICreate("AButton", 68, 71, 10, 10,  $WS_POPUP,  BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD), $hWnd)
GUICtrlCreatePic(@ScriptDir & "\back.gif", 0, 0, 0, 0)

GUISetState(@SW_SHOW, $Button)
GUISetState(@SW_SHOW, $hWnd)

While 1
$Msg = GUIGetMsg(1)
  If WinActive('AButton','') then
      MsgBox(0,'','Hi!')
      WinActivate('MyButton','')
  endif
Select
  case $Msg[0] = $GUI_EVENT_CLOSE
    exit
  endselect
WEnd

4. Report about your result to be clear.

Don't use button control. It isn't invalid for your aim!

:)

The point of world view

Link to comment
Share on other sites

yes I tryed your script.

It works.

But the other GUI "$hWnd" needs a background picture.

when i add the background picture to your script, the script looks like that:

#include <GuiConstants.au3>
Global $hWnd
Global $Width = 400, $Height = $Width
Global $Good = 1

$hWnd = GuiCreate('MyButton', $Width, $Height)
$pic111 = GUICtrlCreatePic(@ScriptDir & "\System\Imagemap1.bmp", "5", "5", "691", "631", $WS_CLIPSIBLINGS)
$Button = GUICreate("AButton", 68, 71, 10, 10,  $WS_POPUP,  BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD), $hWnd)
GUICtrlCreatePic(@ScriptDir & "\System\back.gif", 0, 0, 0, 0)

GUISetState(@SW_SHOW, $Button)
GUISetState(@SW_SHOW, $hWnd)

While 1
$Msg = GUIGetMsg(1)
  If WinActive('AButton','') then
      MsgBox(0,'','Hi!')
      WinActivate('MyButton','')
  endif
Select
  case $Msg[0] = $GUI_EVENT_CLOSE
    exit
  endselect
WEnd

but there is a f***ing grey box around "back.gif"!

Link to comment
Share on other sites

yes I tryed your script.

It works.

But the other GUI "$hWnd" needs a background picture.

when i add the background picture to your script, the script looks like that:

#include <GuiConstants.au3>
Global $hWnd
Global $Width = 400, $Height = $Width
Global $Good = 1

$hWnd = GuiCreate('MyButton', $Width, $Height)
$pic111 = GUICtrlCreatePic(@ScriptDir & "\System\Imagemap1.bmp", "5", "5", "691", "631", $WS_CLIPSIBLINGS)
$Button = GUICreate("AButton", 68, 71, 10, 10,  $WS_POPUP,  BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD), $hWnd)
GUICtrlCreatePic(@ScriptDir & "\System\back.gif", 0, 0, 0, 0)

GUISetState(@SW_SHOW, $Button)
GUISetState(@SW_SHOW, $hWnd)

While 1
$Msg = GUIGetMsg(1)
  If WinActive('AButton','') then
      MsgBox(0,'','Hi!')
      WinActivate('MyButton','')
  endif
Select
  case $Msg[0] = $GUI_EVENT_CLOSE
    exit
  endselect
WEnd
I'm not too good in this area, but I'll have look if you can post a script which I can run and see the problem. Please supply the images you are using as well.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I've got a new problem.

When i open another window and close it, is the window 'back' active.

this means the function runs when it shouldn't.

EDIT:

@ Valery

Run your script and open another window.

you will see that the msgbox "Hi!" appears without clicking on the button.

Do any1 know how to fix this?

Or any other ways to make a button like that?

Edited by Vaeb
Link to comment
Share on other sites

I can't belive that it works at your computer.¨

Please test it:

1. start your merlin script

2. open & minimize a window (Internet Explorer, SciTe or anything else)

3. look if the msgbox appeared.

4. Please tell me if your merlin really works. TEST IT pls

This script really opens a msgbox when you minimize another window. Trust me, i testet it on other computers.

Edited by Vaeb
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...