Code: Select all
Gui, Add, Picture, +Border +TabStop gPickIcon vSelectedIcon Icon23, %A_WinDir%\System32\SHELL32.dll
Thanks.
JB
Code: Select all
Gui, Add, Picture, +Border +TabStop gPickIcon vSelectedIcon Icon23, %A_WinDir%\System32\SHELL32.dll
Code: Select all
#Requires AutoHotkey v1.1.33.02
#If GuiControlGetFocusedVarName() = "SelectedIcon"
Enter::
Space::
; ....
return
GuiControlGetFocusedVarName() {
GuiControlGet focusedVarName, FocusV
return focusedVarName
}
Code: Select all
#Requires AutoHotkey v1.1.33
image := A_ScriptDir "\test.png"
Gui Add, Pic,, % image
Gui Add, Button, ggo Default w0 h0
Gui Show
Return
go() {
MsgBox 123
}
Code: Select all
#SingleInstance, Force
Gui1 := {}
Gui, New, +AlwaysOnTop +HwndHwnd
Gui1.Hwnd := hwnd
Gui1.Controls := {}
Gui1.Handles := []
cc := Gui1.Controls.Picture_1 := { Hwnd: "" , X: "m" , Y: "m" , W: 200 , H: 200 , Label: "PictureRoutine_1" }
Gui, Add, Picture, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " Icon46 hwndhwnd g" cc.Label , Shell32.dll
cc.Hwnd := Hwnd
Gui1.Handles[ Hwnd ] := cc
cc := Gui1.Controls.Picture_2 := { Hwnd: "" , X: "m" , Y: "+10" , W: 200 , H: 200 , Label: "PictureRoutine_2" }
Gui, Add, Picture, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " Icon47 hwndhwnd +Border g" cc.Label , Shell32.dll
cc.Hwnd := hwnd
Gui1.Handles[ hwnd ] := cc
cc := Gui1.Controls.Picture_3 := { Hwnd: "" , X: "m" , Y: "+10" , W: 200 , H: 200 , Label: "PictureRoutine_3" }
Gui, Add, Picture, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " Icon48 hwndhwnd g" cc.Label , Shell32.dll
cc.Hwnd := hwnd
Gui1.Handles[ hwnd ] := cc
Gui, Show
Gui1.ControlList := [ "Picture_1" , "Picture_2" , "Picture_3" ]
Gui1.FocusedControl := 2
return
GuiClose:
GuiContextMenu:
*ESC::ExitApp
#If ( WinActive( "ahk_Id " Gui1.Hwnd ) )
Tab::
WinSet, Style, -0x00800000 , % "ahk_id " Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
( ++Gui1.FocusedControl > Gui1.ControlList.Length() ) ? ( Gui1.FocusedControl := 1 )
WinSet, Style, +0x00800000 , % "ahk_id " Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
GuiControl, % Gui1.Hwnd ":Focus", % Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
return
Enter::
Try{
gosub, % Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Label
}catch{
Gui, % Gui1.Hwnd ":+OwnDialogs"
MsgBox, Error
}
return
#If
PictureRoutine_1:
if( Gui1.FocusedControl != 1 ){
WinSet, Style, -0x00800000 , % "ahk_id " Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
Gui1.FocusedControl := 1
WinSet, Style, +0x00800000 , % "ahk_id " Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
GuiControl, % Gui1.Hwnd ":Focus", % Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
}
ToolTip, % "Control # " Gui1.FocusedControl
SetTimer, TipsOff, -2000
SoundBeep 555
return
PictureRoutine_2:
if( Gui1.FocusedControl != 2 ){
WinSet, Style, -0x00800000 , % "ahk_id " Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
Gui1.FocusedControl := 2
WinSet, Style, +0x00800000 , % "ahk_id " Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
GuiControl, % Gui1.Hwnd ":Focus", % Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
}
ToolTip, % "Control # " Gui1.FocusedControl
SetTimer, TipsOff, -2000
SoundBeep 666
return
PictureRoutine_3:
if( Gui1.FocusedControl != 3 ){
WinSet, Style, -0x00800000 , % "ahk_id " Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
Gui1.FocusedControl := 3
WinSet, Style, +0x00800000 , % "ahk_id " Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
GuiControl, % Gui1.Hwnd ":Focus", % Gui1.Controls[ Gui1.ControlList[ Gui1.FocusedControl ] ].Hwnd
}
ToolTip, % "Control # " Gui1.FocusedControl
SetTimer, TipsOff, -2000
SoundBeep 777
return
TipsOff:
ToolTip
return
Code: Select all
OnMessage( 0x100 , Func( "_CaptureKeys" ).Bind( Gui1) )
Yes, a custom hotkey will do the trick, but what I was wondering was whether there was "Windows native" way (of which I was unaware) to trigger a picture control action.
Yep
Or for more complicated interactions you can monitor the window message [ 0x100 ]Code: Select all
OnMessage( 0x100 , Func( "_CaptureKeys" ).Bind( Gui1) )
Code: Select all
#SingleInstance, Force
Gui1 := {}
Gui, New, +AlwaysOnTop +HwndHwnd
Gui1.Hwnd := hwnd
Gui, Show, w300 h300
OnMessage( 0x100 , Func( "_CaptureKeys" ).Bind( Gui1 ) )
return
GuiClose:
GuiContextMenu:
*ESC::ExitApp
_CaptureKeys( Gui1 , input ){
hwnd := WinActive( "A" )
if( hwnd != Gui1.Hwnd )
return 1
if( Input = 9 )
ToolTip, % "You Pressed the TAB key"
else
ToolTip, % "You Pressed: " chr( Input ) "`nInput: " Input
SetTimer, TipsOff, -2000
}
TipsOff:
ToolTip
return
Code: Select all
#SingleInstance, Force
Gui1 := {}
Gui, New, +AlwaysOnTop +HwndHwnd
Gui1.Hwnd := hwnd
Gui, Margin, % Gui1.Margin := 10 , 10
Gui1.Controls := {}
cc := Gui1.Controls.Picture_1 := { hwnd: "" , X: Gui1.Margin , Y: Gui1.Margin , W: 200 , H: 200 , Label: "PicRoutine" }
Gui, Add, Pic, % "x" cc.X " y" cc.Y " w" cc.W " h" cc.H " Icon46 +hwndhwnd g" cc.Label , Shell32.dll
cc.Hwnd := hwnd
Gui, Show,
OnMessage( 0x100 , Func( "_CaptureKeys" ).Bind( Gui1 ) )
return
GuiClose:
GuiContextMenu:
*ESC::ExitApp
PicRoutine:
Gui, % Gui1.Hwnd ":+OwnDialogs"
MsgBox, You pressed the pic control
return
_CaptureKeys( Gui1 , input ){
hwnd := WinActive( "A" )
if( hwnd != Gui1.Hwnd )
return 1
if( Input = 13 )
gosub, % Gui1.Controls.Picture_1.Label
}
Code: Select all
Gui, Add, Picture, x5 y5 +Border gPickIcon vSelectedIcon Icon23, %A_WinDir%\System32\SHELL32.dll
Gui, Add, Button, x5 y5 w0 h0 gPickIcon,
Users browsing this forum: adam86shadow, balawi28, Bing [Bot], Chunjee, JKJadan and 268 guests