Jump to content

Problem with focus a GUI


jony
 Share

Recommended Posts

Hello,

I apologize for my English.

I found code on this great forum, but I do not know how to change it.

I want open a website in toolbar when is activated and click on any link from this IE activex.

Now when I click on any link from toolbar nothing happens.

Please help me.

Thanks

#include
#include
#include
#include


Opt("WinTitleMatchMode", 2)

Global $iLast_X, $iLast_Y, $fToolBar_Vis = True, $iX = 360, $iY = 5

Global $sMain_Title = "Notepad"
If Not WinExists($sMain_Title) Then
Run("Notepad.exe")
WinWait($sMain_Title)
EndIf
Global $hApplication_Wnd = WinGetHandle($sMain_Title)
Global $iApplication_PID = WinGetProcess($sMain_Title)

ConsoleWrite($hApplication_Wnd & @CRLF)

Global $hToolBar = GUICreate("ToolBarxx", 590, 530, 10, 10, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$IE = ObjCreate("Shell.Explorer.2")
$iActiveX = GUICtrlCreateObj($IE,0,0,489,389)
$IE.navigate("http://www.google.com")




GUISetState()

_Toolbar_Follow()

;Register move event
GUIRegisterMsg($WM_MOVE, "MY_WM_MOVE")

While 1

; Check Application is running
If Not ProcessExists($iApplication_PID) Then Exit

; Hide/show toolbar as required
_Toolbar_State()

Local $iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
; Quit
Exit

EndSwitch

WEnd

Func MY_WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam, $lParam
If $hWnd = $hToolBar Then
; if toolbar moved set new relative position
Local $aApplication_Pos = WinGetPos($hApplication_Wnd)
Local $aToolBarPos = WinGetPos($hToolBar)
$iX = Abs($aApplication_Pos[0] - $aToolBarPos[0])
$iY = Abs($aApplication_Pos[1] - $aToolBarPos[1])
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_MOVE

Func _Toolbar_Follow()

Local $aApplication_Pos = WinGetPos($hApplication_Wnd)
If $aApplication_Pos[0] <> $iLast_X Or $aApplication_Pos[1] <> $iLast_Y Then
$iLast_X = $aApplication_Pos[0]
$iLast_Y = $aApplication_Pos[1]
WinMove($hToolBar, '', $aApplication_Pos[0] + $iX, $aApplication_Pos[1] + $iY)
EndIf

EndFunc ;==>_Toolbar_Follow

Func _Toolbar_State()

; If Application minimised, then hide toolbar and do nothing
If BitAND(WinGetState($hApplication_Wnd), 16) = 16 Then
GUISetState(@SW_HIDE, $hToolBar)
$fToolBar_Vis = False
; If Application not minimised
Else
; Hide ToolBar when Application not active
If BitAND(WinGetState($hApplication_Wnd), 8) <> 8 And $fToolBar_Vis = True Then
GUISetState(@SW_HIDE, $hToolBar)
$fToolBar_Vis = False
ElseIf BitAND(WinGetState($hApplication_Wnd), 8) = 8 And $fToolBar_Vis = False Then
GUISetState(@SW_SHOW, $hToolBar)
WinActivate($hApplication_Wnd)
$fToolBar_Vis = True
EndIf
; If visible check toolbar position
If $fToolBar_Vis = True Then _Toolbar_Follow()
EndIf

EndFunc ;==>_Toolbar_State
Link to comment
Share on other sites

sorry for first incomplet postcode, corect is:

#include <GUIConstants.au3>

#include <WindowsConstants.au3>

#include <StaticConstants.au3>

#include <IE.au3>

only

#Include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

are needed.

Your _Toolbar_State function block user input.

Add AdlibRegister ( '_Toolbar_State', 1500 ) before the loop

and remove _Toolbar_State() from your loop.

Then you can click on link. ;)

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...