- Elkha - Blue
- 오토핫키 커뮤니티
- 오토핫키
Gui ActiveX 에 Send,{Enter} 가 안들어가네요 ㅠㅠ.
-
-
으 저는 Class 를 나눠서 작업하질않아서 햇갈리네요.
#SingleInstance,force
Gui, Color, White
Gui, Font, S18
Gui, Add, ActiveX,x0 y0 w1000 h650 vWEB HScroll ,www.naver.com
Gui, Add, Text, x0 y655 w1000 h30 cBlue Center vShowText,F1 시작
Gui, Show, w1000 h680, 타이틀
Global WEB
return
F1::
OnMessage("13", "1835009", "256", hwnd)
return
OnMessage(wParam, lParam, Msg, hwnd)
{
static fields := "hWnd,Msg,wParam,lParam,A_EventInfo,A_GuiX,A_GuiY"
global WEB
hWnd := hwnd
if (Msg == 0x100)
{
pipa := ComObjQuery(WEB.document, "{00000117-0000-0000-C000-000000000046}")
VarSetCapacity(Msgs, 48)
Loop Parse, fields, `, ;`
NumPut(%A_LoopField%, Msgs, (A_Index-1)*A_PtrSize)
TranslateAccelerator := NumGet(NumGet(1*pipa)+5*A_PtrSize)
Loop 2
r := DllCall(TranslateAccelerator, "Ptr",pipa, "Ptr",&Msgs)
until wParam != 9 || WEB.document.activeElement != ""
ObjRelease(pipa)
if r = 0
return 0
}
}
어디가 틀렸나요? hwnd 값을넘겨줘야 하는거같은데 activex hwnd 값을만들어서 넘겨줘도 반응이없네요...추가로 이렇게만들면 F1눌렀을때 다른창에는 아무런영향이없는거 맞나요? (비활성입력랑 같은셈인가요?)
저는 비활성엔터가필요합니다.
-
클래스로 안짜시면 OnMessage를 함수로 만들면 안됩니다, 저건 오브젝트로 만들때의 OnMessage 내장함수에요
함수밖에서 생성하는 변수는 모두 Global 변수에요, 잘못 이해하고 계신거 같네요! (Global WEB 필요없음)
그리고 웹을 비활성으로 컨트롤하시려면 이런거보다 DOM을 사용하는게 훨씬 쉽고 정확해요
#SingleInstance,force
OnMessage(0x0100, "WM_KeyPress"), OnMessage(0x0101, "WM_KeyPress")
Gui, Color, White
Gui, Font, S18
Gui, Add, ActiveX,x0 y0 w1000 h650 vWEB HScroll ,www.naver.com
Gui, Add, Text, x0 y655 w1000 h30 cBlue Center vShowText,F1 시작
IOleInPlaceActiveObject_Interface:="{00000117-0000-0000-C000-000000000046}"
pipa := ComObjQuery(WEB, IOleInPlaceActiveObject_Interface )
TranslateAccelerator := NumGet(NumGet(pipa+0 ) + 5*A_PtrSize )
Gui, Show, w1000 h680, 타이틀
return
F1::
ControlGet, hShell, Hwnd,, Internet Explorer_Server1, A
WM_KeyPress("13", "1835009", "256", hShell)
return
WM_KeyPress(wParam, lParam, nMsg, hWnd ) {
Global WEB, pipa, TranslateAccelerator
Static Vars := "hWnd | nMsg | wParam | lParam | A_EventInfo | A_GuiX | A_GuiY"
VarSetCapacity( MSG, 48, 0 )
Loop, Parse, Vars, |, %A_Space%
NumPut( %A_LoopField%, MSG, ( A_Index-1 ) * A_PtrSize )
Loop 2
r := DllCall( TranslateAccelerator, UInt,pipa, UInt,&MSG )
Until wParam != 9 || WEB.document.activeElement != ""
IfEqual, R, 0, Return, 0
}
블로그에도 문의해주셨는데 코드가 길어서 여기에 답변해드릴게요
검색창에 아무렇게나 치고 F1 눌러보세요
#NoEnv
#NoTrayIcon
#SingleInstance Off
#KeyHistory 0
ListLines Off
SetBatchLines, -1
Init := new Browser()
return
F1::
Init.OnMessage("13", "1835009", "256", Init.hWnd)
return
class Browser
{
static URL := "https://duckduckgo.com"
__New()
{
global
Gui, New, +Resize +hwndhMain
this.hMain := hMain
Gui, Add, ActiveX, x0 y0 w500 h500 hwndhEmbed vWB, Shell.Explorer
this.hEmbed := hEmbed
WB.silent := true, WB.Navigate(this.URL)
this.Bound := []
this.Bound.OnMessage := this.OnMessage.Bind(this)
WinEvents.Register(this.hMain, this)
for each, Msg in [0x100, 0x201, 0x202, 0x204]
OnMessage(Msg, this.Bound.OnMessage)
Gui,Show, % " w" A_ScreenWidth*0.7 " h" A_ScreenHeight*0.7 , 브라우저
}
GuiSize()
{
DllCall("MoveWindow", "Ptr", this.hEmbed, "Int", 0, "Int", 0, "Int", A_GuiWidth, "Int", A_GuiHeight, "Int", 1)
}
GuiClose()
{
for each, Msg in [0x100, 0x201, 0x202, 0x204]
OnMessage(Msg, this.Bound.OnMessage, 0)
this.Delete("Bound"), WinEvents.Unregister(this.hMain)
Gui, Destroy
ExitApp
}
OnMessage(wParam, lParam, Msg, hWnd)
{
static fields := "hWnd,Msg,wParam,lParam,A_EventInfo,A_GuiX,A_GuiY"
global WB
this.hWnd := hWnd
if (Msg == 0x100)
{
pipa := ComObjQuery(WB.document, "{00000117-0000-0000-C000-000000000046}")
VarSetCapacity(Msgs, 48)
Loop Parse, fields, `, ;`
NumPut(%A_LoopField%, Msgs, (A_Index-1)*A_PtrSize)
TranslateAccelerator := NumGet(NumGet(1*pipa)+5*A_PtrSize)
Loop 2
r := DllCall(TranslateAccelerator, "Ptr",pipa, "Ptr",&Msgs)
until wParam != 9 || WB.document.activeElement != ""
ObjRelease(pipa)
if r = 0
return 0
}
}
}
class WinEvents
{
static Table := {}
Register(hWnd, Class, Prefix="Gui")
{
Gui, +LabelWinEvents.
this.Table[hWnd] := {Class: Class, Prefix: Prefix}
}
Unregister(hWnd)
{
this.Table.Delete(hWnd)
}
Dispatch(hWnd, Type)
{
Info := this.Table[hWnd]
return Info.Class[Info.Prefix . Type].Call(Info.Class)
}
Close()
{
return WinEvents.Dispatch(this, "Close")
}
Size()
{
return WinEvents.Dispatch(this, "Size")
}
}