반응형
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- EnvSub
- SetMouseDelay
- StringGetPos
- SetControlDelay
- if(식)
- 함수
- Var:=식
- 식
- ControlGetText
- EnvDiv
- DetectHiddenWindows
- if
- SetEnv
- IfWinExist
- autohotkey
- EnvMult
- 식의 설명
- MouseClick
- 배열
- IF (식)
- EnvSet
- SetKeyDelay
- EnvAdd
- ControlSend
- Menu
- Threads
- Blocks
- API
- IfInString
- SetTitleMatchMode
Archives
- Today
- Total
ㄴrㅎnㅂrㄹrㄱi
그래픽 버튼 (Graphic Buttons) 본문
반응형
http://www.autohotkey.com/forum/viewtopic.php?t=4047
Here's a generic function that can be used to add graphic buttons to AutoHotkey GUI scripts that should offer a bit of flexibility. Enjoy
Updated to version 2.1
Here's a generic function that can be used to add graphic buttons to AutoHotkey GUI scripts that should offer a bit of flexibility. Enjoy
Updated to version 2.1
- simplified usage
- image types currently supported: .bmp, .icoz
- added the ability to change images
- added image rollover example for SampleButton1 in the demo script
- sample images will be downloaded by the script if not found in the Working directory

; ********************************
; Demo Script
; ********************************
; Download sample images if necessary
IfNotExist %A_WorkingDir%\testbmp.bmp
{
SplashTextOn, 300, 30, !, Downloading images. Please wait...
URLDownloadToFile http://www.autohotkey.net/~corr/ahk.bmp, ahk.bmp
URLDownloadToFile http://www.autohotkey.net/~corr/testbmp.bmp, testbmp.bmp
URLDownloadToFile http://www.autohotkey.net/~corr/test2.bmp, test2.bmp
SplashTextOff
}
; Create the buttons
Gui, Add, Button, h30 w140 gNbutton, Normal Button
AddGraphicButton("SampleButton1", A_WorkingDir . "\testbmp.bmp", "h30 w140 gMyButton", 30, 140)
AddGraphicButton("SampleButton2", A_WorkingDir . "\ahk.bmp", "h30 w140 gMyButton", 80, 140)
Gui, Add, Button, h30 w140 gNbutton, Another Normal Button
AddGraphicButton("SampleButton3", A_WorkingDir . "\test2.bmp", "h30 w140 gMyButton", 20, 130)
; Show the window
Gui, Show,, Bitmap Buttons
; Image rollover for SampleButton1
OnMessage(0x200, "MouseMove")
OnMessage(0x2A3, "MouseLeave")
OnMessage(0x202, "MouseLeave") ; Restore image on LBUTTONUP
Return
MouseLeave(wParam, lParam, msg, hwnd)
{
Global
If (hwnd = SampleButton1_hwnd)
AddGraphicButton("SampleButton1", A_WorkingDir . "\testbmp.bmp", "h30 w140 gMyButton", 30, 140)
Return
}
MouseMove(wParam, lParam, msg, hwnd)
{
Global
Static _LastButtonData = true
If (hwnd = SampleButton1_hwnd)
If (_LastButtonData != SampleButton1_hwnd)
AddGraphicButton("SampleButton1", A_WorkingDir . "\ahk.bmp", "h30 w140 gMyButton", 60, 120)
_LastButtonData := hwnd
Return
}
MyButton:
MsgBox, Graphic button clicked :)
return
Nbutton:
MsgBox, Normal button Clicked :)
AddGraphicButton("SampleButton3", A_WinDir . "\clouds.bmp", "h30 w140 gMyButton", 20, 130)
Return
GuiClose:
ExitApp
; *******************************************************************
; AddGraphicButton.ahk
; *******************************************************************
; Version: 2.1 Updated: May 20, 2007
; by corrupt
; Code contributions by: lingoist
; *******************************************************************
; VariableName = variable name for the button
; ImgPath = Path to the image to be displayed
; Options = AutoHotkey button options (g label, button size, etc...)
; bHeight = Image height (default = 32)
; bWidth = Image width (default = 32)
; *******************************************************************
; note: calling the function again with the same variable name will
; modify the image on the button
; *******************************************************************
AddGraphicButton(VariableName, ImgPath, Options="", bHeight=32, bWidth=32)
{
Global
Local ImgType, ImgType1, LR_LOADFROMFILE, NULL, BM_SETIMAGE
; BS_BITMAP := 128, IMAGE_BITMAP := 0, BS_ICON := 64, IMAGE_ICON := 1
LR_LOADFROMFILE := 16
BM_SETIMAGE := 247
NULL=
SplitPath, ImgPath,,, ImgType1
ImgTYpe := (ImgType1 = "bmp") ? 128 : 64
If (%VariableName%_img != "")
DllCall("DeleteObject", "UInt", %VariableName%_img)
Else
Gui, Add, Button, v%VariableName% hwnd%VariableName%_hwnd +%ImgTYpe% %Options%
ImgType := (ImgType1 = "bmp") ? 0 : 1
%VariableName%_img := DllCall("LoadImage", "UInt", NULL, "Str", ImgPath, "UInt", ImgType, "Int", bWidth, "Int", bHeight, "UInt", LR_LOADFROMFILE, "UInt")
DllCall("SendMessage", "UInt", %VariableName%_hwnd, "UInt", BM_SETIMAGE, "UInt", ImgType, "UInt", %VariableName%_img)
Return, %VariableName%_img ; Return the handle to the image
}
반응형
'AUTOHOTKEY' 카테고리의 다른 글
| UCE(Undetect Cheat Engine) 제작 소스 다운로드 링크 (0) | 2008.10.28 |
|---|---|
| AutoHotKey (0) | 2007.10.28 |
| 오토핫키 일본사이트 네이버 번역 (0) | 2007.10.23 |
| [script] FtpUploader v0.9 (0) | 2007.10.20 |
| :: SmartGUI Creator :: (0) | 2007.10.19 |
Comments