In a WM_KEYDOWN event, setted with OnMessage, I get the parameter hwnd.
But it is not Gui.hwnd, neither GuiCtrlFromHwnd(hwnd)
It comes form an ActiveX Shell.Explorer (so from a sub-control in a way)
How could I know which Gui that hwnd comes from ?
in WM_KEYDOWN event, unknown hwnd Topic is solved
in WM_KEYDOWN event, unknown hwnd
Last edited by FredOoo on 08 Sep 2020, 16:11, edited 1 time in total.
(Alan Turing) « What would be the point of saying that A = B if it was really the same thing? »
(Albert Camus) « Misnaming things is to add to the misfortunes of the world. »
(Albert Camus) « Misnaming things is to add to the misfortunes of the world. »
Re: in WM_KEYDOWN event, unknown hwnd
Code: Select all
WM_KEYDOWN( wParam, lParam, msg, hwnd ){
print
print "WM_KEYDOWN: " wParam " " hwnd
CurrentCtrl := GuiCtrlFromHwnd(hwnd)
if CurrentCtrl {
; Before I click on the Gui.ActiveX, we pass here
print "WM_KEYDOWN from: " type(CurrentCtrl) " name: " CurrentCtrl.name
; -> from Gui.ActiveX name:WB
} else {
; ELSE: Here it's a mess. I can't make sure hwnd come from a ctrl in that Gui.
for i, name in WinGetControls(this.hwnd)
{
print "-- Control #" i " is '" name
}
wHwnd := ControlGetHwnd(hwnd)
print "WM_KEYDOWN from: " hwnd " " this.hwnd " " wHwnd ; ???
}
if wParam==116 {
this.WB.Refresh2(3) ; REFRESH_COMPLETELY = 3
}
}
(Alan Turing) « What would be the point of saying that A = B if it was really the same thing? »
(Albert Camus) « Misnaming things is to add to the misfortunes of the world. »
(Albert Camus) « Misnaming things is to add to the misfortunes of the world. »
Re: in WM_KEYDOWN event, unknown hwnd
I have found a way to do it but I am afraid it is not the best.
If anyone who has more experience with Gui has any comments, they are welcome.
If anyone who has more experience with Gui has any comments, they are welcome.
Code: Select all
WM_KEYDOWN( wParam, lParam, msg, hwnd ){
if wParam!=116 ; F5 key
return
ok := false
CurrentCtrl := GuiCtrlFromHwnd(hwnd)
if CurrentCtrl && CurrentCtrl.gui.hwnd==this.hwnd {
; BEFORE I click on the Gui.ActiveX, we pass here
print "-> WM_KEYDOWN from: " type(CurrentCtrl) " name: " CurrentCtrl.name
ok := true
} else {
for ,name in WinGetControls(this.hwnd){ ; Ctrl.names in this Gui
try ctrlHwnd := ControlGetHwnd(name)
catch
return
if hwnd==ctrlHwnd {
; HERE I know the event comes from a "Internet Explorer_Server1" ctrl, in this Gui.
print "-> WM_KEYDOWN from: " name
ok := true
break
}
}
}
if ok
this.WB.Refresh2(3) ; 3=REFRESH_COMPLETELY
}
Last edited by FredOoo on 08 Sep 2020, 17:51, edited 2 times in total.
(Alan Turing) « What would be the point of saying that A = B if it was really the same thing? »
(Albert Camus) « Misnaming things is to add to the misfortunes of the world. »
(Albert Camus) « Misnaming things is to add to the misfortunes of the world. »
Re: in WM_KEYDOWN event, unknown hwnd Topic is solved
Call GuiFromHwnd(hwnd, true).How could I know which Gui that hwnd comes from ?
Re: in WM_KEYDOWN event, unknown hwnd
Thanks @lexikos. It's much more simple now.
Code: Select all
MyGui := Gui.New()
WB := MyGui.Add("ActiveX", "w980 h640", "Shell.Explorer").Value ; The last parameter is the name of the ActiveX component.
WB.Silent := true ; Don't box on html doc errors. (but on devMode, check if any)
WB.Navigate("https://www.autohotkey.com/boards/") ; This is specific to the web browser control.
MyGui.Show()
onMessage 0x100, 'WM_KEYDOWN'
WM_KEYDOWN( wParam, lParam, msg, hwnd ){
global MyGui, WB
if wParam==116 ; F5 key
&& (from:=GuiFromHwnd(hwnd,true))
&& from.hwnd==MyGui.hwnd ; Event from anywhere in MyGui
{
WB.Refresh2(3) ; 3=REFRESH_COMPLETELY
SoundBeep
}
;(This is just an example. Don't F5 before the page is loaded.)
}
(Alan Turing) « What would be the point of saying that A = B if it was really the same thing? »
(Albert Camus) « Misnaming things is to add to the misfortunes of the world. »
(Albert Camus) « Misnaming things is to add to the misfortunes of the world. »