 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
AGU Guest
|
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1557 Location: switzerland
|
Posted: Sat Jan 14, 2006 2:11 pm Post subject: |
|
|
thank you for the script corrupt
here just defined which button was clicked:
| Code: | Gui, Add, Button, h30 w140 gMyButton1 vB1 +%BS_BITMAP%
Gui, Add, Button, h30 w40 gMyButton2 vI1 +%BS_ICON%
Gui, Add, Button, h30 w60 gMyButton3 vB2 +%BS_BITMAP%
....
MyButton1:
MsgBox, Graphic button1 clicked :)
return
MyButton2:
MsgBox, Graphic button2 clicked :)
return
MyButton3:
MsgBox, Graphic button3 clicked :)
return
|
|
|
| Back to top |
|
 |
twhyman
Joined: 07 Dec 2005 Posts: 310
|
Posted: Thu Jan 19, 2006 7:26 am Post subject: |
|
|
Hi,
thanks for the script
is there a way to add text and graphic to the button?
thanks |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2446
|
Posted: Mon Jan 23, 2006 6:39 am Post subject: |
|
|
| At the moment... the easiest way would be to create a custom bitmap with the desired text. |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1557 Location: switzerland
|
Posted: Tue Apr 04, 2006 10:14 pm Post subject: |
|
|
easy example, create a record button , save with irfanview
| Code: |
;part 1 save this as record.bmp (AltGr/ print screen, save with irfanview)
#NoTrayIcon
;C=000000 ;black
;C=008000 ;green
;C=C0C0C0 ;silver
;C=00FF00 ;lime
;C=808080 ;grey
;C=808000 ;olive
;C=FFFFFF ;white
;C=FFFF00 ;yellow
;C=800000 ;maroon
;C=000080 ;navy
C=FF0000 ;red
;C=0000FF ;blue
;C=800080 ;purple
;C=008080 ;teal
;C=FF00FF ;fuchsia
;C=00FFFF ;aqua
Gui,-Border
Gui,Color,%C%
Gui,Font, S16 Cdefault bold,Lucida Console
Gui,Add,TEXT,cWHITE x10 y10 ,RECORD
Gui,Show,x0 y0 w110 h40,COLOR TEST
return
esc::exitapp
|
| Code: | ;Example, click 2 Picture-Buttons
Gui, Add, Picture, gEx1 x10 y10 w80 h30,record.bmp
Gui, Add, Picture, gEx2 x220 y10 w180 h130,C:\test2.jpg
Gui, Show, x255 y146 h200 w477,TEST
Return
Ex1:
MsgBox,Clicked record
return
Ex2:
MsgBox,Clicked Picture2
return
GuiClose:
ExitApp
|
|
|
| Back to top |
|
 |
Steven Michael Guest
|
Posted: Sat Aug 19, 2006 10:32 pm Post subject: |
|
|
Ok so this script was awesome, my only question is how/what would someone need to change to make it so you could get the images from a Icon Library file such as an ICL or a DLL???
My concern is that by the time I am finished with my niffty little script I will have roughly around 20 image-buttons (using .ico files btw) and I don't want to have them all just randomly placed in a subfolder within my script's directory. It just seems much more "professional" to have fewer needed items, and it would make the files a little more secure in terms of someone messing with the images.
If someone can help me out with this soon it would greatly be appreciated. Thanks in advance
- Steven Michael |
|
| Back to top |
|
 |
robiandi
Joined: 08 Aug 2006 Posts: 49
|
Posted: Sun Aug 20, 2006 10:48 am Post subject: |
|
|
| @garry: Your example, Tue Apr 04, 2006 10:14 pm, was very helpful for me, thank you very much. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 7187
|
Posted: Mon Aug 21, 2006 10:46 am Post subject: |
|
|
Dear robiandi,
| You wrote: | | @garry: Your example, Tue Apr 04, 2006 10:14 pm, was very helpful for me, thank you very much. |
Actually the date and time will differ for people accessing this forum from different timezones.
Please refer the snapshot:
You may right-click & copy the shortcut of that post (red arrow pointing to a tiny icon)
and paste it instead - like this:
http://www.autohotkey.com/forum/viewtopic.php?p=55555#55555
Just a suggestion.
Regards,  _________________ Suresh Kumar A N |
|
| Back to top |
|
 |
robiandi
Joined: 08 Aug 2006 Posts: 49
|
Posted: Mon Aug 21, 2006 11:38 am Post subject: |
|
|
| Dear Goyyah, many thanks for the information. |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 537 Location: Texas, USA
|
Posted: Tue Dec 05, 2006 9:27 pm Post subject: |
|
|
I know this is a very old post but the content is very important so I thought I would give it a bump so that it won't go unnoticed!
Clear throat. Cough twice...
OK, I'll break. My motivation is a bit more selfish...
I noticed that buttons created using this technique appear to be using the Window Classic style (at least for me). Here's what it looks like on my computer. The 2nd and 3rd buttons are the best examples.
Is there any way to get the program to use the default button style?
Thanks in advance for your feedback. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6723 Location: France (near Paris)
|
Posted: Tue Dec 05, 2006 11:20 pm Post subject: |
|
|
Probably not. Themed buttons are drawn using bitmaps, I suppose they don't merge well with graphic buttons. Classic buttons are drawn with brushes (or pens), they are actually just a border. So they mix well with other graphics. _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
AGU Guest
|
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 537 Location: Texas, USA
|
Posted: Wed Dec 06, 2006 4:26 am Post subject: |
|
|
Not a perfect solution but it might work out until graphical buttons are a built-in feature. Hint. Hint. I'll give it a try. Thanks.
Them be my thoughts.... |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 1557 Location: switzerland
|
Posted: Wed Jan 10, 2007 8:53 am Post subject: |
|
|
example for color buttons
save a small color part (from second script) with IrfanView to red.bmp/green.bmp
or just add a picture=
| Code: | Gui, Add, Picture, x10 y10 w220 h150,%A_ScriptDir%\haarlem.jpg
|
| Code: | ;------- COLOR BUTTONS -------------------------------------
Gui,1: +AlwaysOnTop
Gui,1:Font,S12,FixedSys
;-----------------------------------------------------------
Gui,1:Add,Picture,x0 y1 h20 w100 gCALC,red.bmp
Gui,1:Add,text,cWhite BackgroundTrans x25 y3 h20 gCALC,CALC1
Gui,1:Add,Picture,x120 y1 h20 w100 gSNDVOL,green.bmp
Gui,1:Add,text,cWhite BackgroundTrans x145 y3 h20,VOLUME
;-----------------------------------------------------------
Gui,1:Show,x1 y0 h30 w230 ,COLOR BUTTONS
return
CALC:
run,calc.exe
return
SNDVOL:
run,sndvol32
return
GuiClose:
ExitApp
|
show colors=
| Code: | ;-- part 1 --- SAVE COLOR with IRFANVIEW red.bmp -------------------
;ctrl+printscreen,Irfanview,ctrl+V,mark,cut=CTRL+Y,save as=red.bmp
#NoTrayIcon
;---------------------------------------
C1=000000 ;black
C2=008000 ;green
C3=C0C0C0 ;silver
C4=00FF00 ;lime
C5=808080 ;grey
C6=808000 ;olive
C7=FFFFFF ;white
C8=FFFF00 ;yellow
C9=800000 ;maroon
C10=000080 ;navy
C11=FF0000 ;red
C12=0000FF ;blue
C13=800080 ;purple
C14=008080 ;teal
C15=FF00FF ;fuchsia
C16=00FFFF ;aqua
;C=A2A25E
;C=3C1B17
;C=C8D0D4 ;grey2
;C=D2DBDF ;grey3
;---------------------------------------
;Gui,Font, S7 Cdefault ,Lucida Console
;Gui,Add,TEXT,cWHITE x10 y10 ,RECORD
;----------------------------------------
Gui,1:-Border
Gui,1:Color,%C1%
Gui,1:Add,TEXT,cWHITE x2 y2 ,BLACK
Gui,1:Show,x0 y0 w50 h50,
Gui,2:-Border
Gui,2:Color,%C2%
Gui,2:Add,TEXT,cWHITE x2 y2 ,GREEN
Gui,2:Show,x0 y50 w50 h50,
Gui,3:-Border
Gui,3:Color,%C3%
Gui,3:Add,TEXT,cBLACK x2 y2 ,SILVER
Gui,3:Show,x0 y100 w50 h50,
Gui,4:-Border
Gui,4:Color,%C4%
Gui,4:Add,TEXT,cWHITE x2 y2 ,LIME
Gui,4:Show,x0 y150 w50 h50,
Gui,5:-Border
Gui,5:Color,%C5%
Gui,5:Add,TEXT,cBLACK x2 y2 ,GREY
Gui,5:Show,x0 y200 w50 h50,
Gui,6:-Border
Gui,6:Color,%C6%
Gui,6:Add,TEXT,cWHITE x2 y2 ,OLIVE
Gui,6:Show,x0 y250 w50 h50,
Gui,7:-Border
Gui,7:Color,%C7%
Gui,7:Add,TEXT,cBLACK x2 y2 ,WHITE
Gui,7:Show,x0 y300 w50 h50,
Gui,8:-Border
Gui,8:Color,%C8%
Gui,8:Add,TEXT,cBLACK x2 y2 ,YELLOW
Gui,8:Show,x0 y350 w50 h50,
Gui,9:-Border
Gui,9:Color,%C9%
Gui,9:Add,TEXT,cWHITE x2 y2 ,MAROON
Gui,9:Show,x0 y400 w50 h50,
Gui,10:-Border
Gui,10:Color,%C10%
Gui,10:Add,TEXT,cWHITE x2 y2 ,NAVY
Gui,10:Show,x0 y450 w50 h50,
;---------------------------
Gui,11:-Border
Gui,11:Color,%C11%
Gui,11:Add,TEXT,cWHITE x2 y2 ,RED
Gui,11:Show,x50 y0 w50 h50,
Gui,12:-Border
Gui,12:Color,%C12%
Gui,12:Add,TEXT,cWHITE x2 y2 ,BLUE
Gui,12:Show,x50 y50 w50 h50,
Gui,13:-Border
Gui,13:Color,%C13%
Gui,13:Add,TEXT,cWHITE x2 y2 ,PURPLE
Gui,13:Show,x50 y100 w50 h50,
Gui,14:-Border
Gui,14:Color,%C14%
Gui,14:Add,TEXT,cWHITE x2 y2 ,TEAL
Gui,14:Show,x50 y150 w50 h50,
Gui,15:-Border
Gui,15:Color,%C15%
Gui,15:Add,TEXT,cWHITE x2 y2 ,FUCHSIA
Gui,15:Show,x50 y200 w50 h50,
Gui,16:-Border
Gui,16:Color,%C16%
Gui,16:Add,TEXT,cBlack x2 y2 ,AQUA
Gui,16:Show,x50 y250 w50 h50,
return
esc::exitapp
|
|
|
| Back to top |
|
 |
lingoist
Joined: 05 Oct 2004 Posts: 121 Location: Brasília, Brazil
|
Posted: Mon Mar 26, 2007 10:55 pm Post subject: |
|
|
corrupt,
I've wrote a simplier function to include an GraphicButton automaticaly.
| Code: | #SingleInstance force
;PROGRAM TITLE
ProgramTitle = Gui_Add_GraphicButton_Function
;GUI SHOW + HIDE
Gui, Show, w650 h200 +Hide, %ProgramTitle%
;SET BUTTONS
loop 15
GuiAddGraphicButton("h30 w30 xp+30 GMyButton", "D:\_kirk\img_kirk\icone_vazio.bmp", ProgramTitle)
;GUI SHOW AGAIN
Gui, Show, , %ProgramTitle%
Return
MyButton:
MsgBox, Graphic button clicked :)
return
GuiClose:
ExitApp
Return
GuiAddGraphicButton(GuiAddButtonOptions, ImgPath, WindowTitle, ImgHeight=26, ImgWidth=26) {
{ ;DETAILS
; HWND = window handle
; CtrlInstance = Button Number (same as the # in ClassNN in Window Spy)
; ImgPath = Path to the image to be displayed
; ImgType = Either BS_BITMAP (default) or BS_ICON are supported (0 or 1)
; ImgHeight = Image height (default = 32)
; ImgWidth = Image width (default = 32)
}
{ ; GLOBALS AND BUTTON
DetectHiddenWindows, On
HWND := WinExist(WindowTitle)
BS_BITMAP := 128
IMAGE_BITMAP := 0
BS_ICON := 64
IMAGE_ICON := 1
}
{ ;CHOOSE .ICO OU .BMP
If ImgPath contains .ico
{
bs_chosen = %BS_ICON%
ImgType=1
}
Else If ImgPath contains .bmp
{
bs_chosen = %BS_BITMAP%
ImgType = 0
}
Gui, Add, Button, %GuiAddButtonOptions% +%bs_chosen%
}
{ ;SEARCH LAST BUTTON
WinGet, ControlList, ControlList, %WindowTitle%
StringSplit, qt, ControlList, `n
;MsgBox %qt0%`n%ControlList%
;CtrlInstance = %qt0%
Loop, parse, ControlList, `n
{
If A_LoopField not contains Button
Continue
StringReplace, butt, A_LoopField, Button, , all
ac_buttons = %ac_buttons%|%butt%
;MsgBox %A_LoopField%
}
StringTrimLeft, ac_buttons, ac_buttons, 1
Sort, ac_buttons, D| R N
Loop, parse, ac_buttons, |
{
last_button = %A_LoopField%
Break
}
;MsgBox %last_button%
CtrlInstance = %last_button%
}
{ ;DLL CALL
; Set Constants
NULL=
LR_LOADFROMFILE := 16
BM_SETIMAGE := 247
; Find the handle to the Button based on the windle handle and button number
;msgbox %CtrlInstance%
Loop, %CtrlInstance%
{
CtrlHandle := DllCall("FindWindowExA", "Uint", HWND, "Uint", CtrlHandle, "str", "Button", "str", NULL, "Uint")
If CtrlHandle = 0
Return
}
; Load the image from the file and retrieve the image handle
ImgHwnd%CtrlInstance% := DllCall("LoadImage", "UInt", NULL, "Str", ImgPath, "UInt", ImgType, "Int", ImgWidth, "Int", ImgHeight, "UInt", LR_LOADFROMFILE, "UInt")
; Assign the image to the button
DllCall("SendMessage", "UInt", CtrlHandle, "UInt", BM_SETIMAGE, "UInt", ImgType, "UInt", ImgHwnd%CtrlInstance%)
; Return the handle to the image
retImg := ImgHwnd%CtrlInstance%
}
Return, %retImg%
}
|
The problem is that it does not work when a prior button or radio is included before this functions...
By the way, if the button inserted before the function has no text, the function will work properly.
Corrupt, do you know why it happens?
Thanks,
Lingoist |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|