Gui multi tab browser help!

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

Gui multi tab browser help!

16 Jan 2015, 23:47

hello, Im currently working on this script, 'Film browser'

problem is
If I press {backspace} key on Tab1 (ImDB)
it performs Browser_Back for Tab2 (Rotten Tomatoes) and vice versa

same for 'Enter' .. it doesnt work

those keys worked when I have only 1 tab

Any solution? sorry for my bad English

Code: Select all

/*
     __    __  __          __ __       __    __                 _       __                   
    / /_  / /_/ /_____  _ / // /____ _/ /_  / /________________(_)___  / /_ ____  _______
   / __ \/ __/ __/ __ \(_) // // __ '/ __ \/ //_/ ___/ ___/ __/ / __ \/ __// __ \/ __/ _ \
  / / / / /_/ /_/ /_/ / / // // /_/ / / / / ,< (__  ) /__/ / / / /_/ / /__/ /_/ / / / // / 
 /_/ /_/\__/\__/ .___(_) // / \__,_/_/ /_/_/|_/____/\___/_/ /_/ .___/\__(_)____/_/  \__ /  
              /_/     /_//_/                                 /_/                   (___/   
              
  Subject :  [How To] Implement Tabstop for ActiveX > Shell.Explorer
  Author  :  SKAN, for the technique described on topic.
  Topic   :  http://ahkscript.org/boards/viewtopic.php?f=7&t=879
  
*/

#NoEnv  
#SingleInstance Force
#Persistent
SetWorkingDir %A_ScriptDir% 

Gui, +LastFound +Resize +OwnDialogs
Gui, Default
OnMessage(11, "DisableSetRedraw")
Gui Add, Edit, w930 -E0x200 vURL, 

;Gui Add, Button, x+6 yp w44 Default, Go
Gui, Add, Tab2, x0 y30 Buttons vWhichTab, IMDB|Tomatatoes

Gui, Tab, 1
Gui Add, ActiveX, xm w900 h600 E0x10000 vWB hwndATLWinHWND, Shell.Explorer
WB.silent := true
ComObjConnect(WB, WB_events)
IOleInPlaceActiveObject_Interface := "{00000117-0000-0000-C000-000000000046}"
pipa := ComObjQuery( WB, IOleInPlaceActiveObject_Interface )
TranslateAccelerator := NumGet( NumGet( pipa+0 ) + 5*A_PtrSize )
OnMessage( 0x0100, "WM_KeyPress" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress" ) ; WM_KEYUP

Gui, Tab, 2
Gui Add, ActiveX, xm w900 h600 E0x10000 vWB2 hwndATLWinHWND2, Shell.Explorer
WB2.silent := true
ComObjConnect(WB2, WB_events)
IOleInPlaceActiveObject_Interface2 := "{00000117-0000-0000-C000-000000000046}"
pipa2 := ComObjQuery( WB2, IOleInPlaceActiveObject_Interface2 )
TranslateAccelerator2 := NumGet( NumGet( pipa2+0 ) + 5*A_PtrSize )
OnMessage( 0x0100, "WM_KeyPress2" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress2" ) ; WM_KEYUP

OnExit, GuiClose

Gui, Show,, Film Browser
   URL1 := "http://www.imdb.com/movies-in-theaters/?ref_=nv_tp_inth_1"
   URL2 := "http://www.rottentomatoes.com/mobile/"
   WB.Navigate(URL1)
   WB2.Navigate(URL2)
return

/*
ButtonGo:
  Gui Submit, NoHide
  if WhichTab = 왓챠
    WB.Navigate(URL)
  if WhichTab = 서치팡
    WB2.Navigate(URL)
Return
*/


class WB_events
{
    NavigateComplete2(wb, NewURL)
    {
        GuiControl,, URL, %NewURL%  ; Update the URL edit control.
    }

    DocumentComplete( WB, NewURL ) 
    {
        ; check all frames and elements for input focus
        ; WB.Document.Body.Focus()
    }     
}

GuiClose:
  ObjRelease( pipa )
  ObjRelease( pipa2 )
  OnExit
  ExitApp
Return  

GuiSize:
{
   ;// if there is a resize event lets resize the browser
   WinMove, %   "ahk_id " . ATLWinHWND, , 0,60, A_GuiWidth, A_GuiHeight
   WinMove, %   "ahk_id " . ATLWinHWND2, , 0,60, A_GuiWidth, A_GuiHeight
   return
}

WM_KeyPress( wParam, lParam, nMsg, hWnd ) {

Global WB, pipa, TranslateAccelerator
Static Vars := "hWnd | nMsg | wParam | lParam | A_EventInfo | A_GuiX | A_GuiY" 

  WinGetClass, ClassName, ahk_id %hWnd%

  If ( ClassName = "Shell DocObject View" && wParam = 0x09 ) {
    WinGet, hIES, ControlListHwnd, ahk_id %hWnd% ; Find child of 'Shell DocObject View'
    ControlFocus,, ahk_id %hIES%
    Return 0
  }

  If ( ClassName = "Internet Explorer_Server" ) {

    VarSetCapacity( MSG, 48, 0 )                   ; MSG STructure    http://goo.gl/4bHD9Z
    Loop, Parse, Vars, |, %A_Space%
      NumPut( %A_LoopField%, MSG, ( A_Index-1 ) * A_PtrSize )

    Loop 2  ; IOleInPlaceActiveObject::TranslateAccelerator method    http://goo.gl/XkGZYt
      r := DllCall( TranslateAccelerator, UInt,pipa, UInt,&MSG )
    Until wParam != 9 || WB.document.activeElement != ""

    IfEqual, R, 0, Return, 0         ; S_OK: the message was translated to an accelerator.

  }
}

WM_KeyPress2( wParam, lParam, nMsg, hWnd ) {

Global WB2, pipa2, TranslateAccelerator2
Static Vars2 := "hWnd | nMsg | wParam | lParam | A_EventInfo | A_GuiX | A_GuiY" 

  WinGetClass, ClassName2, ahk_id %hWnd%

  If ( ClassName2 = "Shell DocObject View" && wParam = 0x09 ) {
    WinGet, hIES, ControlListHwnd, ahk_id %hWnd% ; Find child of 'Shell DocObject View'
    ControlFocus,, ahk_id %hIES%
    Return 0
  }

  If ( ClassName2 = "Internet Explorer_Server" ) {

    VarSetCapacity( MSG, 48, 0 )                   ; MSG STructure    http://goo.gl/4bHD9Z
    Loop, Parse, Vars2, |, %A_Space%
      NumPut( %A_LoopField%, MSG, ( A_Index-1 ) * A_PtrSize )

    Loop 2  ; IOleInPlaceActiveObject::TranslateAccelerator method    http://goo.gl/XkGZYt
      r := DllCall( TranslateAccelerator2, UInt,pipa2, UInt,&MSG )
    Until wParam != 9 || WB2.document.activeElement != ""

    IfEqual, R, 0, Return, 0         ; S_OK: the message was translated to an accelerator.

  }
}

DisableSetRedraw() {
   return 0
} :beer: 
AutoHotkey & AutoHotkey_H v1.1.22.07
enthused
Posts: 94
Joined: 27 Dec 2014, 03:28

Re: Gui multi tab browser help!

17 Jan 2015, 01:40

Soft wrote: problem is
If I press {backspace} key on Tab1 (ImDB)
it performs Browser_Back for Tab2 (Rotten Tomatoes) and vice versa
Actually, for me:

{backspace} key on Tab1 or Tab2 always work on Tab2.
It's like Tab1 doesn't get updated but Tab2 always does.
just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Gui multi tab browser help!

17 Jan 2015, 02:21

Code: Select all

OnMessage( 0x0100, "WM_KeyPress" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress" ) ; WM_KEYUP
...
OnMessage( 0x0100, "WM_KeyPress2" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress2" ) ; WM_KEYUP
Only the functions specified in the last processed OnMessage() block will be called.
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

Re: Gui multi tab browser help!

17 Jan 2015, 06:11

enthused wrote:
Soft wrote: problem is
If I press {backspace} key on Tab1 (ImDB)
it performs Browser_Back for Tab2 (Rotten Tomatoes) and vice versa
Actually, for me:

{backspace} key on Tab1 or Tab2 always work on Tab2.
It's like Tab1 doesn't get updated but Tab2 always does.
oh same for me.. did not noticed that
AutoHotkey & AutoHotkey_H v1.1.22.07
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

Re: Gui multi tab browser help!

17 Jan 2015, 06:11

just me wrote:

Code: Select all

OnMessage( 0x0100, "WM_KeyPress" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress" ) ; WM_KEYUP
...
OnMessage( 0x0100, "WM_KeyPress2" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress2" ) ; WM_KEYUP
Only the functions specified in the last processed OnMessage() block will be called.
thank you, I figured it out!
AutoHotkey & AutoHotkey_H v1.1.22.07
enthused
Posts: 94
Joined: 27 Dec 2014, 03:28

Re: Gui multi tab browser help!

17 Jan 2015, 11:17

just me wrote:

Code: Select all

OnMessage( 0x0100, "WM_KeyPress" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress" ) ; WM_KEYUP
...
OnMessage( 0x0100, "WM_KeyPress2" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress2" ) ; WM_KEYUP
Only the functions specified in the last processed OnMessage() block will be called.
so how do you clear OnMessage() block?
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

Re: Gui multi tab browser help!

17 Jan 2015, 13:13

enthused wrote:
just me wrote:

Code: Select all

OnMessage( 0x0100, "WM_KeyPress" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress" ) ; WM_KEYUP
...
OnMessage( 0x0100, "WM_KeyPress2" ) ; WM_KEYDOWN 
OnMessage( 0x0101, "WM_KeyPress2" ) ; WM_KEYUP
Only the functions specified in the last processed OnMessage() block will be called.
so how do you clear OnMessage() block?
yes, I removed 2nd OnMessage (WM_Keypress2)

and modified 'WM_Keypress' like this

WhichTab is Tab's variable name
for Tab1 WhichTab returns 1, Tab2 returns 2

Gui, Add, Tab2, x0 y30 Buttons vWhichTab AltSubmit, IMDB|RottenTomatoes ;Using WhichTab and AltSubmit

Code: Select all

WM_KeyPress( wParam, lParam, nMsg, hWnd ) {

Global WB, pipa, TranslateAccelerator, WB2, pipa2, TranslateAccelerator2, WhichTab, WB3, pipa3, TranslateAccelerator3, WB4, pipa4, TranslateAccelerator4

Gui, Submit, NoHide
Static Vars := "hWnd | nMsg | wParam | lParam | A_EventInfo | A_GuiX | A_GuiY" 

  WinGetClass, ClassName, ahk_id %hWnd%

  If ( ClassName = "Shell DocObject View" && wParam = 0x09 ) {
    WinGet, hIES, ControlListHwnd, ahk_id %hWnd% ; Find child of 'Shell DocObject View'
    ControlFocus,, ahk_id %hIES%
    Return 0
  }
  
  if WhichTab = 1
  {
  If ( ClassName = "Internet Explorer_Server" ) {

    VarSetCapacity( MSG, 48, 0 )                   ; MSG STructure    http://goo.gl/4bHD9Z
    Loop, Parse, Vars, |, %A_Space%
      NumPut( %A_LoopField%, MSG, ( A_Index-1 ) * A_PtrSize )

    Loop 2  ; IOleInPlaceActiveObject::TranslateAccelerator method    http://goo.gl/XkGZYt
      r := DllCall( TranslateAccelerator, UInt,pipa, UInt,&MSG )
    Until wParam != 9 || WB.document.activeElement != ""

    IfEqual, R, 0, Return, 0         ; S_OK: the message was translated to an accelerator.

  }
  }
  
  if WhichTab = 2
  {
  If ( ClassName = "Internet Explorer_Server" ) {

    VarSetCapacity( MSG, 48, 0 )                   ; MSG STructure    http://goo.gl/4bHD9Z
    Loop, Parse, Vars, |, %A_Space%
      NumPut( %A_LoopField%, MSG, ( A_Index-1 ) * A_PtrSize )

    Loop 2  ; IOleInPlaceActiveObject::TranslateAccelerator method    http://goo.gl/XkGZYt
      r := DllCall( TranslateAccelerator2, UInt,pipa2, UInt,&MSG )
    Until wParam != 9 || WB2.document.activeElement != ""

    IfEqual, R, 0, Return, 0         ; S_OK: the message was translated to an accelerator.

  }
  }
  
  if WhichTab = 3
  {
  If ( ClassName = "Internet Explorer_Server" ) {

    VarSetCapacity( MSG, 48, 0 )                   ; MSG STructure    http://goo.gl/4bHD9Z
    Loop, Parse, Vars, |, %A_Space%
      NumPut( %A_LoopField%, MSG, ( A_Index-1 ) * A_PtrSize )

    Loop 2  ; IOleInPlaceActiveObject::TranslateAccelerator method    http://goo.gl/XkGZYt
      r := DllCall( TranslateAccelerator3, UInt,pipa3, UInt,&MSG )
    Until wParam != 9 || WB3.document.activeElement != ""

    IfEqual, R, 0, Return, 0         ; S_OK: the message was translated to an accelerator.

  }
  }
  
  if WhichTab = 4
  {
  If ( ClassName = "Internet Explorer_Server" ) {

    VarSetCapacity( MSG, 48, 0 )                   ; MSG STructure    http://goo.gl/4bHD9Z
    Loop, Parse, Vars, |, %A_Space%
      NumPut( %A_LoopField%, MSG, ( A_Index-1 ) * A_PtrSize )

    Loop 2  ; IOleInPlaceActiveObject::TranslateAccelerator method    http://goo.gl/XkGZYt
      r := DllCall( TranslateAccelerator4, UInt,pipa4, UInt,&MSG )
    Until wParam != 9 || WB4.document.activeElement != ""

    IfEqual, R, 0, Return, 0         ; S_OK: the message was translated to an accelerator.

  }
  }
}
AutoHotkey & AutoHotkey_H v1.1.22.07
enthused
Posts: 94
Joined: 27 Dec 2014, 03:28

Re: Gui multi tab browser help!

17 Jan 2015, 14:23

@Soft very nice :D
Thank you for the update.

I was trying to send the OnMessage() to another function to process WhichTab and then send to Wm_KeyPress or Wm_KeyPress2 but wasn't working on both tabs.

Interestingly it was working on the first tab {backSpace} was clicked on like Tab1 or Tab2 but not both tabs.
And the function fired only once as I placed a MsgBox but it only showed one time on the first {backSpace} but not after that.

Code: Select all

Gui, Tab, 1
Gui Add, ActiveX, xm w900 h600 E0x10000 vWB hwndATLWinHWND, Shell.Explorer
WB.silent := true
ComObjConnect(WB, WB_events)
IOleInPlaceActiveObject_Interface := "{00000117-0000-0000-C000-000000000046}"
pipa := ComObjQuery( WB, IOleInPlaceActiveObject_Interface )
TranslateAccelerator := NumGet( NumGet( pipa+0 ) + 5*A_PtrSize )
OnMessage( 0x0100, "ProcessMessages" ) ; WM_KEYDOWN
OnMessage( 0x0101, "ProcessMessages" ) ; WM_KEYUP

Gui, Tab, 2
Gui Add, ActiveX, xm w900 h600 E0x10000 vWB2 hwndATLWinHWND2, Shell.Explorer
WB2.silent := true
ComObjConnect(WB2, WB_events)
IOleInPlaceActiveObject_Interface2 := "{00000117-0000-0000-C000-000000000046}"
pipa2 := ComObjQuery( WB2, IOleInPlaceActiveObject_Interface2 )
TranslateAccelerator2 := NumGet( NumGet( pipa2+0 ) + 5*A_PtrSize )
OnMessage( 0x0100, "ProcessMessages" ) ; WM_KEYDOWN
OnMessage( 0x0101, "ProcessMessages" ) ; WM_KEYUP

Code: Select all

ProcessMessages() {
ControlGet, WhichTab, Tab, , SysTabControl321, Film Browser
DllCall("User32.dll\MsgWaitForMultipleObjectsEx", 1, WhichTab, 1000, 0x0001, 0)
if (WhichTab == 1) 
{
	MsgBox,,%WhichTab%
	OnMessage( 0x0100, "WM_KeyPress" ) ; WM_KEYDOWN
    OnMessage( 0x0101, "WM_KeyPress" ) ; WM_KEYUP
}

else if (WhichTab == 2) 
{
	MsgBox,,%WhichTab%
	OnMessage( 0x0100, "WM_KeyPress2" ) ; WM_KEYDOWN
    OnMessage( 0x0101, "WM_KeyPress2" ) ; WM_KEYUP
	
}

}
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
Location: Seoul
Contact:

Re: Gui multi tab browser help!

17 Jan 2015, 22:54

#enthused
hmm.. Maybe because we cant use same OnMessage(WM Keypress) twice?

code u wrote seems interesting!
AutoHotkey & AutoHotkey_H v1.1.22.07
enthused
Posts: 94
Joined: 27 Dec 2014, 03:28

Re: Gui multi tab browser help!

17 Jan 2015, 23:05

@Soft
Soft wrote:hmm.. Maybe because we cant use same OnMessage(WM Keypress) twice?
Thank you for explaining.

I thought so too, but was trying to avoid modifying Wm_KeyPress as it is complicated for me :D
Thank you for showing the solution.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Marium0505 and 340 guests