Что нового

Вкладки web-browser'a

nu3dell

Осваивающий
Сообщения
139
Репутация
24
как правильно реализовать вкладки в браузере
Код:
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>

$IE = ObjCreate("Shell.Explorer.2")
$IE2 = ObjCreate("Shell.Explorer.2")
$IE4 = ObjCreate("Shell.Explorer.2")
GUICreate("", 700, 500)
 $tab = GUICtrlCreateTab(35, 10, 180, 21)
$tab0 = GUICtrlCreateTabItem("Вкладка")
    $tab0OK = GUICtrlCreateObj($IE, 10, 30, 680, 440)
$tab1 = GUICtrlCreateTabItem("Вкладка")
 $tab1OK = GUICtrlCreateObj($IE2, 10, 30, 680, 440)

GUISetState()
$Add=GUICtrlCreateButton('+',10,10,20,20)
$serr=GUICtrlCreateButton('Поиск',520,10,40,20)
$ser=GUICtrlCreateInput('',210,11,300,18)
$IE.navigate("http://vkontakte.ru/")
$IE2.navigate("mail.ru")


While 1
    $msg = GUIGetMsg()
    Select
	Case $msg = $GUI_EVENT_CLOSE
		Exit
	Case $msg = $Add
		GUICtrlCreateTabItem("Вкладка")
 $tab1OK = GUICtrlCreateObj($IE4, 10, 30, 680, 440)
 Case $msg = $serr
 $IE4.navigate("http://www.google.com.ua/search?aq=f&gcx=w&sourceidUTF-8&q="&GUICtrlRead($ser))
ControlDisable("","",$Add )
EndSelect
WEnd
Вот что бы при нажатие "+" создавалось не зависимая страница, и также если вкладка была активно тогда поиск только на ней
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
Обновил
 

madmasles

Модератор
Глобальный модератор
Сообщения
7 790
Репутация
2 319
nu3dell,
Попробуйте так:
Код:
#include <GUIConstantsEx.au3>

Dim $aTab[3][5] = [[2],['vkontakte', 'http://vkontakte.ru/'],['mail', 'http://mail.ru/']]
$iCount = 0
GUICreate('Test', 700, 500)
$nTab = GUICtrlCreateTab(35, 10, 180, 21)
For $i = 1 To $aTab[0][0]
	$aTab[$i][2] = ObjCreate('Shell.Explorer.2')
	$aTab[$i][3] = GUICtrlCreateTabItem($aTab[$i][0])
	$aTab[$i][4] = GUICtrlCreateObj($aTab[$i][2], 10, 30, 680, 440)
	$aTab[$i][2] .navigate($aTab[$i][1])
Next
GUICtrlCreateTabItem('')
$nAdd = GUICtrlCreateButton('+', 10, 10, 20, 20)
$nSearch = GUICtrlCreateButton('Поиск', 520, 10, 40, 20)
$nInputSearch = GUICtrlCreateInput('', 210, 11, 300, 18)
GUISetState()

While 1
	$msg = GUIGetMsg()
	Switch $msg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $nAdd
			$aTab[0][0] += 1
			ReDim $aTab[$aTab[0][0] + 1][5]
			$aTab[$aTab[0][0]][0] = 'New TabItem'
			$aTab[$aTab[0][0]][1] = 'http://autoit-script.ru/'
			$aTab[$aTab[0][0]][2] = ObjCreate('Shell.Explorer.2')
			$aTab[$aTab[0][0]][3] = GUICtrlCreateTabItem($aTab[$aTab[0][0]][0])
			GUICtrlCreateTabItem('')
			$aTab[$aTab[0][0]][4] = GUICtrlCreateObj($aTab[$aTab[0][0]][2], 10, 30, 680, 440)
			$aTab[$aTab[0][0]][2] .navigate($aTab[$aTab[0][0]][1])
			GUICtrlSetState($nAdd, $GUI_DISABLE)
		Case $nSearch
			$sSearch = GUICtrlRead($nInputSearch)
			If $sSearch Then
				$iTabNow = GUICtrlRead($nTab)
				$aTab[$iTabNow + 1][2] .navigate('http://www.google.ru/search?aq=f&gcx=w&sourceidUTF-8&q=' & $sSearch)
			EndIf
	EndSwitch
WEnd
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
madmasles замечательно спасибо
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
madmasles как правильно склеить ваш код с этим?
Код:
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $GUI_Button_Back, $GUI_Button_Forward,$Command , $Enable
Global Const $CSC_NAVIGATEFORWARD = 0x00000001
Global Const $CSC_NAVIGATEBACK = 0x00000002

    Local $oIE, $GUIActiveX
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg
    
    $oIE = ObjCreate("Shell.Explorer.2")
    GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    $GUIActiveX = GUICtrlCreateObj ($oIE, 10, 40, 600, 360)
    $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)
    $GUI_Button_Exit = GUICtrlCreateButton("Exit",10, 460, 100, 30)
    $GUI_Button_More = GUICtrlCreateButton("Еще кнопка",120, 460, 100, 30)
    ControlDisable("","",$GUI_Button_Back)
    ControlDisable("","",$GUI_Button_Forward )
    GUISetState()       ;Show GUI
    
ObjEvent($oIE, "IEEvent_");, "DWebBrowserEvents") ;создаем обЪект для регистрации событий

    $oIE.navigate("http://www.google.ru/")

    while 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $GUI_Button_Home
                $oIE.navigate("http://www.autoitscript.com")
            Case $msg = $GUI_Button_Back
                    $oIE.GoBack
            Case $msg = $GUI_Button_Forward
                $oIE.GoForward
            Case $msg = $GUI_Button_Stop
                $oIE.Stop
            Case $msg = $GUI_Button_Exit
                exit
            Case $msg = $GUI_Button_More
                MsgBox(1,"","Вот еще кнопка")
        EndSelect
        
    wend
    GUIDelete()
 
; Функция обработки события _CommandStateChange в браузере
Func IEEvent_CommandStateChange($command, $enable)
    Switch $command
        Case $CSC_NAVIGATEBACK
            If $enable = True Then
                ControlEnable("","",$GUI_Button_Back)
            Else
                ControlDisable("","",$GUI_Button_Back)
            EndIf
        Case $CSC_NAVIGATEFORWARD
            If $enable = True Then
                ControlEnable("","",$GUI_Button_Forward)
            Else
                ControlDisable("","",$GUI_Button_Forward )
            EndIf
    EndSwitch
EndFunc
 

madmasles

Модератор
Глобальный модератор
Сообщения
7 790
Репутация
2 319
nu3dell [?]
как правильно склеить ваш код с этим?
Вы лучше напишите, что Вы хотите в итоге сделать, а то я не понимаю, что значит склеить.
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
madmasles что бы в этом коде
Код:
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $GUI_Button_Back, $GUI_Button_Forward,$Command , $Enable
Global Const $CSC_NAVIGATEFORWARD = 0x00000001
Global Const $CSC_NAVIGATEBACK = 0x00000002

    Local $oIE, $GUIActiveX
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg
    
    $oIE = ObjCreate("Shell.Explorer.2")
    GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    $GUIActiveX = GUICtrlCreateObj ($oIE, 10, 40, 600, 360)
    $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)
    $GUI_Button_Exit = GUICtrlCreateButton("Exit",10, 460, 100, 30)
    $GUI_Button_More = GUICtrlCreateButton("Еще кнопка",120, 460, 100, 30)
    ControlDisable("","",$GUI_Button_Back)
    ControlDisable("","",$GUI_Button_Forward )
    GUISetState()       ;Show GUI
    
ObjEvent($oIE, "IEEvent_");, "DWebBrowserEvents") ;создаем обЪект для регистрации событий

    $oIE.navigate("http://www.google.ru/")

    while 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $GUI_Button_Home
                $oIE.navigate("http://www.autoitscript.com")
            Case $msg = $GUI_Button_Back
                    $oIE.GoBack
            Case $msg = $GUI_Button_Forward
                $oIE.GoForward
            Case $msg = $GUI_Button_Stop
                $oIE.Stop
            Case $msg = $GUI_Button_Exit
                exit
            Case $msg = $GUI_Button_More
                MsgBox(1,"","Вот еще кнопка")
        EndSelect
        
    wend
    GUIDelete()
 
; Функция обработки события _CommandStateChange в браузере
Func IEEvent_CommandStateChange($command, $enable)
    Switch $command
        Case $CSC_NAVIGATEBACK
            If $enable = True Then
                ControlEnable("","",$GUI_Button_Back)
            Else
                ControlDisable("","",$GUI_Button_Back)
            EndIf
        Case $CSC_NAVIGATEFORWARD
            If $enable = True Then
                ControlEnable("","",$GUI_Button_Forward)
            Else
                ControlDisable("","",$GUI_Button_Forward )
            EndIf
    EndSwitch
EndFunc
были еще вкладки, которые вы привели в пример
 

madmasles

Модератор
Глобальный модератор
Сообщения
7 790
Репутация
2 319
nu3dell,
При использовании функций ObjEvent($oIE, 'IEEvent_'), при клике по ссылке на странице - результате поиска google, скрипт вылетает с ошибкой (у меня).
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
madmasles
Код:
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

Local $hGui, $OptionsBtn, $OptionsDummy, $OptionsContext, $OptionsCommon, $OptionsFile, $msg

Global $GUI_Button_Back, $GUI_Button_Forward,$Command , $Enable
Global Const $CSC_NAVIGATEFORWARD = 0x00000001
Global Const $CSC_NAVIGATEBACK = 0x00000002

    Local $oIE, $GUIActiveX
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg
    
    $oIE = ObjCreate("Shell.Explorer.2")
   $hGui= GUICreate("", @DesktopWidth, @DesktopHeight-68,0,0,$WS_OVERLAPPEDWINDOW)

 $OptionsBtn = GUICtrlCreateButton("", 963, 4, 28, 22, $BS_FLAT+$BS_BITMAP)
FileInstall('set.bmp', @TempDir & '\set.bmp')
GUICtrlSetImage(-1, @TempDir & '\set.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\set.bmp')

    $OptionsDummy = GUICtrlCreateDummy()
    $OptionsContext = GUICtrlCreateContextMenu($OptionsDummy)
    $OptionsCommon = GUICtrlCreateMenuItem("Brown", $OptionsContext)
    $OptionsFile = GUICtrlCreateMenuItem("Beige", $OptionsContext)
	$OptionsExit = GUICtrlCreateMenuItem("Grey", $OptionsContext)
	GuiCtrlCreateMenuitem ("", $OptionsDummy )
	$configuration = GUICtrlCreateMenuItem("Config. PC", $OptionsContext)
    $GUIActiveX = GUICtrlCreateObj ($oIE, 10, 32, @DesktopWidth-20, @DesktopHeight-115)
    $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 4, 28, 23,$BS_BITMAP)
	FileInstall('back.bmp', @TempDir & '\back.bmp')
GUICtrlSetImage(-1, @TempDir & '\back.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\back.bmp')
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 80, 4, 28,23,$BS_BITMAP)
		FileInstall('front.bmp', @TempDir & '\front.bmp')
GUICtrlSetImage(-1, @TempDir & '\front.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\front.bmp')
    $GUI_Button_Home = GUICtrlCreateButton("Home", 45, 4, 28, 23,$BS_BITMAP)
		FileInstall('update.bmp', @TempDir & '\update.bmp')
GUICtrlSetImage(-1, @TempDir & '\update.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\update.bmp')
    

	$Search=GUICtrlCreateInput("",115,5,215,23)
	GUICtrlSetFont(-1, 14, 400, 2, "")
	GUICtrlSetCursor (-1, 5)
	$GUI_Button_Search = GUICtrlCreateButton("Search",340, 4, 73, 23,$BS_BITMAP)
			FileInstall('Search.bmp', @TempDir & '\Search.bmp')
GUICtrlSetImage(-1, @TempDir & '\Search.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\Search.bmp')
	$GUI_Button_www = GUICtrlCreateButton("RUN",705, 4, 73, 23,$BS_BITMAP)
			FileInstall('run.bmp', @TempDir & '\run.bmp')
GUICtrlSetImage(-1, @TempDir & '\run.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\run.bmp')
GUICtrlCreateLabel("|", 420, 0, 10, 30)
	GUICtrlSetColor(-1, 0xcbcbcb)
GUICtrlSetFont(-1, 18, 400, 2, "")
ObjEvent($oIE, "IEEvent_")
$www=GUICtrlCreateInput("",485,5,210,23)
GUICtrlSetFont(-1, 14, 400, 2, "")
	$htt=GUICtrlCreateLabel("http://", 430, 5, 50, 24)
$htt= GUICtrlSetFont(-1, 14, 400, 0, "")
$htt=GUICtrlSetColor(-1, 0xcbcbcb)
    $oIE.navigate("http://www.google.ru/")
	$tube = GUICtrlCreateButton("", 800, 4, 28,23,$BS_BITMAP)
				FileInstall('tube.bmp', @TempDir & '\tube.bmp')
GUICtrlSetImage(-1, @TempDir & '\tube.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\tube.bmp')
GUICtrlCreateLabel("|", 945, 0, 10, 30)
GUICtrlSetColor(-1, 0xcbcbcb)
GUICtrlSetFont(-1, 18, 400, 2, "")
GUICtrlSetFont(-1, 18, 400, 2, "")
$wik = GUICtrlCreateButton("", 835, 4, 28,23,$BS_BITMAP)
				FileInstall('w.bmp', @TempDir & '\w.bmp')
GUICtrlSetImage(-1, @TempDir & '\w.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\w.bmp')
$mail = GUICtrlCreateButton("", 870, 4, 28,23,$BS_BITMAP)
				FileInstall('@.bmp', @TempDir & '\@.bmp')
GUICtrlSetImage(-1, @TempDir & '\@.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\@.bmp')
$v = GUICtrlCreateButton("", 905, 4, 28,23,$BS_BITMAP)
				FileInstall('v.bmp', @TempDir & '\v.bmp')
GUICtrlSetImage(-1, @TempDir & '\v.bmp', -1)
GUISetState()
FileDelete(@TempDir & '\v.bmp')
GUICtrlCreateLabel("|", 785, 0, 10, 30)
GUICtrlSetFont(-1, 18, 400, 2, "")
	GUICtrlSetColor(-1, 0xcbcbcb)
 ControlDisable("","",$GUI_Button_Back)
    ControlDisable("","",$GUI_Button_Forward )

    GUISetState()
	ObjEvent($oIE, "IEEvent_")
    while 1
        $msg = GUIGetMsg()
        Select
		
	Case $msg = $OptionsCommon
		
	$Gui=GUISetBkColor(0x8B4513)

		Case $msg = $OptionsFile
			$Gui=GUISetBkColor(0xF5F5DC)
			Case $msg = $OptionsExit
			$Gui=GUISetBkColor(0x9C9C9C)
		  Case $msg = $OptionsBtn
                ShowMenu($hGui, $msg, $OptionsContext)
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
			Case $msg =$mail
				$oIE.navigate("http://mail.ru")
			Case $msg =$v
				$oIE.navigate("http://vk.com")
			Case $msg = $wik
				$oIE.navigate("http://ru.wikipedia.org")
            Case $msg = $GUI_Button_Home
		Send('{F5}')
            Case $msg = $GUI_Button_Back
                    $oIE.GoBack
            Case $msg = $GUI_Button_Forward
                $oIE.GoForward
				Case $msg = $tube
$oIE.navigate("http://www.youtube.com/")
            				case $msg =  $GUI_Button_www
            $oIE.navigate("http://www."&GUICtrlRead($www))
			Case $msg = $GUI_Button_Search
				$oIE.navigate("http://www.google.com/search?aq=UTF-8&q="&GUICtrlRead($Search))
				
			Case $msg = $configuration




_Main()

Func _Main()
	Local $VOL, $SERIAL, $TOTAL, $FREE
	Local $Input_ComputerName, $Input_CurrentUserName, $Input_OperatingSystem
	Local $Input_ServicePack, $Input_VolumeLabel, $Input_SerialNumber
	Local $Input_TotalSpace, $Input_FreeSpace, $Input_IpAddress, $Input_StartupDirectory
	Local $Input_WindowsDirectory, $Input_SystemFolderDirectory, $Input_DesktopDirectory
	Local $Input_MyDocumentsDirectory, $Input_ProgramFilesDirectory, $Input_StartMenuDirectory
	Local $Input_TemporaryFileDirectory, $Input_DesktopWidth, $Input_DesktopHeight
	Local $Input_Date, $Input_Time, $msg2


	GUICreate("PC Configuration", 469, 639, (@DesktopWidth - 469) / 2, (@DesktopHeight - 639) / 2, $WS_SYSMENU)

	$VOL = DriveGetLabel("C:\")
	$SERIAL = DriveGetSerial("C:\")
	$TOTAL = DriveSpaceTotal("C:\")
	$FREE = DriveSpaceFree("C:\")

	GUICtrlCreateLabel("Computer Name", 10, 10, 150, 20)
	GUICtrlCreateLabel("Current User Name", 10, 40, 150, 20)
	GUICtrlCreateLabel("Operating System", 10, 70, 150, 20)
	GUICtrlCreateLabel("Service Pack", 10, 100, 150, 20)
	GUICtrlCreateLabel("C: Volume Label", 10, 130, 150, 20)
	GUICtrlCreateLabel("C: Serial Number", 10, 160, 150, 20)
	GUICtrlCreateLabel("C: Total Space", 10, 190, 150, 20)
	GUICtrlCreateLabel("C: Free Space", 10, 220, 150, 20)
	GUICtrlCreateLabel("IP Address", 10, 250, 150, 20)
	GUICtrlCreateLabel("Startup Directory", 10, 280, 150, 20)
	GUICtrlCreateLabel("Windows Directory", 10, 310, 150, 20)
	GUICtrlCreateLabel("System Folder Directory", 10, 340, 150, 20)
	GUICtrlCreateLabel("Desktop Directory", 10, 370, 150, 20)
	GUICtrlCreateLabel("My Documents Directory", 10, 400, 150, 20)
	GUICtrlCreateLabel("Program File Directory", 10, 430, 150, 20)
	GUICtrlCreateLabel("Start Menu Directory", 10, 460, 150, 20)
	GUICtrlCreateLabel("Desktop Width (Pixels)", 10, 520, 150, 20)
	GUICtrlCreateLabel("Temporary File Directory", 10, 490, 150, 20)
	GUICtrlCreateLabel("Desktop Height (Pixels)", 10, 550, 150, 20)
	GUICtrlCreateLabel("Date", 10, 580, 150, 20)
	GUICtrlCreateLabel("Time", 10, 610, 150, 20)
	$Input_ComputerName = GUICtrlCreateInput("" & @ComputerName, 180, 10, 280, 20)
	$Input_CurrentUserName = GUICtrlCreateInput("" & @UserName, 180, 40, 280, 20)
	$Input_OperatingSystem = GUICtrlCreateInput("" & @OSTYPE, 180, 70, 280, 20)
	$Input_ServicePack = GUICtrlCreateInput("" & @OSServicePack, 180, 100, 280, 20)
	$Input_VolumeLabel = GUICtrlCreateInput("" & $VOL, 180, 130, 280, 20)
	$Input_SerialNumber = GUICtrlCreateInput("" & $SERIAL, 180, 160, 280, 20)
	$Input_TotalSpace = GUICtrlCreateInput("" & $TOTAL, 180, 190, 280, 20)
	$Input_FreeSpace = GUICtrlCreateInput("" & $FREE, 180, 220, 280, 20)
	$Input_IpAddress = GUICtrlCreateInput("" & @IPAddress1, 180, 250, 280, 20)
	$Input_StartupDirectory = GUICtrlCreateInput("" & @StartupDir, 180, 280, 280, 20)
	$Input_WindowsDirectory = GUICtrlCreateInput("" & @WindowsDir, 180, 310, 280, 20)
	$Input_SystemFolderDirectory = GUICtrlCreateInput("" & @SystemDir, 180, 340, 280, 20)
	$Input_DesktopDirectory = GUICtrlCreateInput("" & @DesktopDir, 180, 370, 280, 20)
	$Input_MyDocumentsDirectory = GUICtrlCreateInput("" & @MyDocumentsDir, 180, 400, 280, 20)
	$Input_ProgramFilesDirectory = GUICtrlCreateInput("" & @ProgramFilesDir, 180, 430, 280, 20)
	$Input_StartMenuDirectory = GUICtrlCreateInput("" & @StartMenuDir, 180, 460, 280, 20)
	$Input_TemporaryFileDirectory = GUICtrlCreateInput("" & @TempDir, 180, 490, 280, 20)
	$Input_DesktopWidth = GUICtrlCreateInput("" & @DesktopWidth, 180, 520, 280, 20)
	$Input_DesktopHeight = GUICtrlCreateInput("" & @DesktopHeight, 180, 550, 280, 20)
	$Input_Date = GUICtrlCreateInput("(MONTH)(DAY)(YEAR) " & @MON & "-" & @MDAY & "-" & @YEAR, 180, 580, 280, 20)
	$Input_Time = GUICtrlCreateInput("(HOUR)(MIN)(SEC) " & @HOUR & ":" & @MIN & ":" & @SEC, 180, 610, 280, 20)

	GUISetState()
	
EndFunc

        EndSelect
        
    wend
    GUIDelete()
	
	Func IEEvent_CommandStateChange($command, $enable)
    Switch $command
        Case $CSC_NAVIGATEBACK
            If $enable = True Then
                ControlEnable("","",$GUI_Button_Back)
            Else
                ControlDisable("","",$GUI_Button_Back)
            EndIf
        Case $CSC_NAVIGATEFORWARD
            If $enable = True Then
                ControlEnable("","",$GUI_Button_Forward)
            Else
                ControlDisable("","",$GUI_Button_Forward )
            EndIf
		EndSwitch
		EndFunc

 
Func ShowMenu($hWnd, $CtrlID, $nContextID)
    Local $arPos, $x, $y
    Local $hMenu = GUICtrlGetHandle($nContextID)
    
    $arPos = ControlGetPos($hWnd, "", $CtrlID)
    
    $x = $arPos[0]
    $y = $arPos[1] + $arPos[3]
    
    ClientToScreen($hWnd, $x, $y)
    TrackPopupMenu($hWnd, $hMenu, $x, $y)
EndFunc 

Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
    Local $stPoint = DllStructCreate("int;int")
    
    DllStructSetData($stPoint, 1, $x)
    DllStructSetData($stPoint, 2, $y)

    DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))
    
    $x = DllStructGetData($stPoint, 1)
    $y = DllStructGetData($stPoint, 2)
   
    $stPoint = 0
EndFunc



Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc

Нашел у себя такое, тут все хорошо
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
madmasles надеюсь на помощь
 

madmasles

Модератор
Глобальный модератор
Сообщения
7 790
Репутация
2 319
nu3dell,
По аналогии с этим куском делайте:
Код:
;...
Case $nSearch
	$sSearch = GUICtrlRead($nInputSearch)
	If $sSearch Then
		$iTabNow = GUICtrlRead($nTab);определяем текущую вкладку
		$aTab[$iTabNow + 1][2] .navigate('http://www.google.ru/search?aq=f&gcx=w&sourceidUTF-8&q=' & $sSearch);делаем с ней что-нибудь
		;или
		;$aTab[$iTabNow + 1][2] .GoBack
		;$aTab[$iTabNow + 1][2] .Stop
		; и т.д. и т.п.
	EndIf
;...
 

agikon

Знающий
Сообщения
789
Репутация
16
а скажите пожалуйста вот управлять вкладками можно только в IE? или можно и в других браузерах управлят вкладками?
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
madmasles
кнопки не работают в чем ошибка?!
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Global $GUI_Button_Back, $GUI_Button_Forward,$Command , $Enable
Global Const $CSC_NAVIGATEFORWARD = 0x00000001
Global Const $CSC_NAVIGATEBACK = 0x00000002

    Local $oIE, $GUIActiveX
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg

Dim $aTab[3][5] = [[2],['vk.com', 'http://vkontakte.ru/'],['@mail.ru', 'http://mail.ru/']]
$iCount = 0
GUICreate('Test', @DesktopWidth, @DesktopHeight-70,0,0)
$nTab = GUICtrlCreateTab(35, 27, 680, 21)

For $i = 1 To $aTab[0][0]
    $aTab[$i][2] = ObjCreate('Shell.Explorer.2')
    $aTab[$i][3] = GUICtrlCreateTabItem($aTab[$i][0])
    $aTab[$i][4] = GUICtrlCreateObj($aTab[$i][2], 10, 50, @DesktopWidth-25, @DesktopHeight-120)
    $aTab[$i][2] .navigate($aTab[$i][1])
Next
GUICtrlCreateTabItem('')
 GUICtrlSetBkColor(-1, 0xd4d0c8)
$nAdd = GUICtrlCreateButton('+', 10, 27, 20, 20)
$nSearch = GUICtrlCreateButton('Поиск', 10, 3, 40, 20)
$nInputSearch = GUICtrlCreateInput('', 55, 4, @DesktopHeight-300, 18)
$GUI_Button_Back = GUICtrlCreateButton("Back", 700, 10, 100, 30)
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 800, 10, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 900, 10, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 1030, 10, 100, 30)

    ControlDisable("","",$GUI_Button_Back)
    ControlDisable("","",$GUI_Button_Forward )
GUISetState()

While 1
    $msg = GUIGetMsg()
	Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nAdd
            $aTab[0][0] += 1
            ReDim $aTab[$aTab[0][0] + 1][5]
            $aTab[$aTab[0][0]][0] = 'Вкладка'
            $aTab[$aTab[0][0]][1] = 'Google.ru'
            $aTab[$aTab[0][0]][2] = ObjCreate('Shell.Explorer.2')
            $aTab[$aTab[0][0]][3] = GUICtrlCreateTabItem($aTab[$aTab[0][0]][0])
            $aTab[$aTab[0][0]][4] = GUICtrlCreateObj($aTab[$aTab[0][0]][2], 10, 50, @DesktopWidth-25, @DesktopHeight-120)
            $aTab[$aTab[0][0]][2] .navigate($aTab[$aTab[0][0]][1])

        Case $nSearch
            $sSearch = GUICtrlRead($nInputSearch)
            If $sSearch Then
                $iTabNow = GUICtrlRead($nTab)
                $aTab[$iTabNow + 1][2] .navigate('http://www.google.com.ua/search?aq=f&gcx=w&sourceidUTF-8&q=' & $sSearch)
            EndIf
			Select
		Case $msg = $GUI_Button_Home
                $aTab[$iTabNow + 1][2] .navigate("http://www.autoitscript.com")
            Case $msg = $GUI_Button_Back
                   $aTab[$iTabNow + 1][2].GoBack
            Case $msg = $GUI_Button_Forward
                $aTab[$iTabNow + 1][2] .GoForward
            Case $msg = $GUI_Button_Stop
                $aTab[$iTabNow + 1][2] .Stop
           EndSelect
    EndSwitch
WEnd



Func IEEvent_CommandStateChange($command, $enable)
    Switch $command
        Case $CSC_NAVIGATEBACK
            If $enable = True Then
                ControlEnable("","",$GUI_Button_Back)
            Else
                ControlDisable("","",$GUI_Button_Back)
            EndIf
        Case $CSC_NAVIGATEFORWARD
            If $enable = True Then
                ControlEnable("","",$GUI_Button_Forward)
            Else
                ControlDisable("","",$GUI_Button_Forward )
            EndIf
    EndSwitch
EndFunc
 

madmasles

Модератор
Глобальный модератор
Сообщения
7 790
Репутация
2 319
nu3dell [?]
кнопки не работают
А так?
Код:
;...
While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			Exit
		Case $nAdd
			$aTab[0][0] += 1
			ReDim $aTab[$aTab[0][0] + 1][5]
			$aTab[$aTab[0][0]][0] = 'Вкладка'
			$aTab[$aTab[0][0]][1] = 'Google.ru'
			$aTab[$aTab[0][0]][2] = ObjCreate('Shell.Explorer.2')
			$aTab[$aTab[0][0]][3] = GUICtrlCreateTabItem($aTab[$aTab[0][0]][0])
			GUICtrlCreateTabItem('')
			$aTab[$aTab[0][0]][4] = GUICtrlCreateObj($aTab[$aTab[0][0]][2], 10, 50, @DesktopWidth - 25, @DesktopHeight - 120)
			$aTab[$aTab[0][0]][2] .navigate($aTab[$aTab[0][0]][1])
		Case $nSearch
			$sSearch = GUICtrlRead($nInputSearch)
			If $sSearch Then
				$iTabNow = GUICtrlRead($nTab)
				$aTab[$iTabNow + 1][2] .navigate('http://www.google.com.ua/search?aq=f&gcx=w&sourceidUTF-8&q=' & $sSearch)
			EndIf
		Case $GUI_Button_Home
			$iTabNow = GUICtrlRead($nTab)
			$aTab[$iTabNow + 1][2] .navigate("http://www.autoitscript.com")
		Case $GUI_Button_Back
			$iTabNow = GUICtrlRead($nTab)
			$aTab[$iTabNow + 1][2] .GoBack
		Case $GUI_Button_Forward
			$iTabNow = GUICtrlRead($nTab)
			$aTab[$iTabNow + 1][2] .GoForward
		Case $GUI_Button_Stop
			$iTabNow = GUICtrlRead($nTab)
			$aTab[$iTabNow + 1][2] .Stop
	EndSwitch
WEnd
;...
Я бы заменил
Код:
;...
ControlDisable("","",$GUI_Button_Back)
;...
ControlEnable("","",$GUI_Button_Back)
;...на
GUICtrlSetState($GUI_Button_Back, $GUI_DISABLE)
;...
GUICtrlSetState($GUI_Button_Back, $GUI_ENABLE)
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
madmasles получается всегда кнопки назад вперед не активны

Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Global $GUI_Button_Back, $GUI_Button_Forward,$Command , $Enable
Global Const $CSC_NAVIGATEFORWARD = 0x00000001
Global Const $CSC_NAVIGATEBACK = 0x00000002

    Local $oIE, $GUIActiveX
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg

Dim $aTab[3][5] = [[2],['vk.com', 'http://vkontakte.ru/'],['@mail.ru', 'http://mail.ru/']]
$iCount = 0
GUICreate('Test', @DesktopWidth, @DesktopHeight-70,0,0)
$nTab = GUICtrlCreateTab(35, 27, 680, 21)

For $i = 1 To $aTab[0][0]
    $aTab[$i][2] = ObjCreate('Shell.Explorer.2')
    $aTab[$i][3] = GUICtrlCreateTabItem($aTab[$i][0])
    $aTab[$i][4] = GUICtrlCreateObj($aTab[$i][2], 10, 50, @DesktopWidth-25, @DesktopHeight-120)
    $aTab[$i][2] .navigate($aTab[$i][1])
Next
GUICtrlCreateTabItem('')
 GUICtrlSetBkColor(-1, 0xd4d0c8)
$nAdd = GUICtrlCreateButton('+', 10, 27, 20, 20)
$nSearch = GUICtrlCreateButton('Поиск', 10, 3, 40, 20)
$nInputSearch = GUICtrlCreateInput('', 55, 4, @DesktopHeight-300, 18)
$GUI_Button_Back = GUICtrlCreateButton("Back", 700, 10, 100, 30)
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 800, 10, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 900, 10, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 1030, 10, 100, 30)

    ControlDisable("","",$GUI_Button_Back)
    ControlDisable("","",$GUI_Button_Forward )
GUISetState()

;...
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nAdd
            $aTab[0][0] += 1
            ReDim $aTab[$aTab[0][0] + 1][5]
            $aTab[$aTab[0][0]][0] = 'Вкладка'
            $aTab[$aTab[0][0]][1] = 'Google.ru'
            $aTab[$aTab[0][0]][2] = ObjCreate('Shell.Explorer.2')
            $aTab[$aTab[0][0]][3] = GUICtrlCreateTabItem($aTab[$aTab[0][0]][0])
            GUICtrlCreateTabItem('')
            $aTab[$aTab[0][0]][4] = GUICtrlCreateObj($aTab[$aTab[0][0]][2], 10, 50, @DesktopWidth - 25, @DesktopHeight - 120)
            $aTab[$aTab[0][0]][2] .navigate($aTab[$aTab[0][0]][1])
        Case $nSearch
            $sSearch = GUICtrlRead($nInputSearch)
            If $sSearch Then
                $iTabNow = GUICtrlRead($nTab)
                $aTab[$iTabNow + 1][2] .navigate('http://www.google.com.ua/search?aq=f&gcx=w&sourceidUTF-8&q=' & $sSearch)
            EndIf
        Case $GUI_Button_Home
            $iTabNow = GUICtrlRead($nTab)
            $aTab[$iTabNow + 1][2] .navigate("http://www.autoitscript.com")
        Case $GUI_Button_Back
            $iTabNow = GUICtrlRead($nTab)
            $aTab[$iTabNow + 1][2] .GoBack
        Case $GUI_Button_Forward
            $iTabNow = GUICtrlRead($nTab)
            $aTab[$iTabNow + 1][2] .GoForward
        Case $GUI_Button_Stop
            $iTabNow = GUICtrlRead($nTab)
            $aTab[$iTabNow + 1][2] .Stop
    EndSwitch
WEnd
;...



Func IEEvent_CommandStateChange($command, $enable)
    Switch $command
        Case $CSC_NAVIGATEBACK
            If $enable = True Then
              GUICtrlSetState($GUI_Button_Back, $GUI_DISABLE)
            Else
  GUICtrlSetState($GUI_Button_Back, $GUI_ENABLE)
            EndIf
        Case $CSC_NAVIGATEFORWARD
            If $enable = True Then
				  GUICtrlSetState($GUI_Button_Forward, $GUI_DISABLE)
          
            Else
               	  GUICtrlSetState($GUI_Button_Forward, $GUI_ENABLE)
            EndIf
    EndSwitch
EndFunc
 
Автор
nu3dell

nu3dell

Осваивающий
Сообщения
139
Репутация
24
madmasles надеюсь на помощь
 

madmasles

Модератор
Глобальный модератор
Сообщения
7 790
Репутация
2 319
nu3dell,
Я не знаю, почему эти кнопки всегда не активны.
 

XpycT

Скриптер
Сообщения
380
Репутация
132
nu3dell
Код:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $GUI_Button_Back, $GUI_Button_Forward,$Command , $Enable
Global Const $CSC_NAVIGATEFORWARD = 0x00000001
Global Const $CSC_NAVIGATEBACK = 0x00000002

    Local $oIE, $GUIActiveX
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg

Dim $aTab[3][5] = [[2],['vk.com', 'http://vkontakte.ru/'],['@mail.ru', 'http://mail.ru/']]
$iCount = 0
GUICreate('Test', @DesktopWidth, @DesktopHeight-70,0,0)
$nTab = GUICtrlCreateTab(35, 27, 680, 21)

For $i = 1 To $aTab[0][0]
    $aTab[$i][2] = ObjCreate('Shell.Explorer.2')
    $aTab[$i][3] = GUICtrlCreateTabItem($aTab[$i][0])
    $aTab[$i][4] = GUICtrlCreateObj($aTab[$i][2], 10, 50, @DesktopWidth-25, @DesktopHeight-120)

    ObjEvent($aTab[$i][2], "_IEEvent_", "DWebBrowserEvents2")

    $aTab[$i][2] .navigate($aTab[$i][1])
Next

GUICtrlCreateTabItem('')
 GUICtrlSetBkColor(-1, 0xd4d0c8)
$nAdd = GUICtrlCreateButton('+', 10, 27, 20, 20)
$nSearch = GUICtrlCreateButton('Поиск', 10, 3, 40, 20)
$nInputSearch = GUICtrlCreateInput('', 55, 4, @DesktopHeight-300, 18)
$GUI_Button_Back = GUICtrlCreateButton("Back", 700, 10, 100, 30)
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 800, 10, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 900, 10, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 1030, 10, 100, 30)

    ControlDisable("","",$GUI_Button_Back)
    ControlDisable("","",$GUI_Button_Forward )
GUISetState()

;...
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nAdd
            $aTab[0][0] += 1
            ReDim $aTab[$aTab[0][0] + 1][5]
            $aTab[$aTab[0][0]][0] = 'Вкладка'
            $aTab[$aTab[0][0]][1] = 'Google.ru'
            $aTab[$aTab[0][0]][2] = ObjCreate('Shell.Explorer.2')
            $aTab[$aTab[0][0]][3] = GUICtrlCreateTabItem($aTab[$aTab[0][0]][0])
            GUICtrlCreateTabItem('')
            $aTab[$aTab[0][0]][4] = GUICtrlCreateObj($aTab[$aTab[0][0]][2], 10, 50, @DesktopWidth - 25, @DesktopHeight - 120)
            $aTab[$aTab[0][0]][2] .navigate($aTab[$aTab[0][0]][1])
        Case $nSearch
            $sSearch = GUICtrlRead($nInputSearch)
            If $sSearch Then
                $iTabNow = GUICtrlRead($nTab)
                $aTab[$iTabNow + 1][2] .navigate('http://www.google.com.ua/search?aq=f&gcx=w&sourceidUTF-8&q=' & $sSearch)
            EndIf
        Case $GUI_Button_Home
            $iTabNow = GUICtrlRead($nTab)
            $aTab[$iTabNow + 1][2] .navigate("http://www.autoitscript.com")
        Case $GUI_Button_Back
            $iTabNow = GUICtrlRead($nTab)
            $aTab[$iTabNow + 1][2] .GoBack
        Case $GUI_Button_Forward
            $iTabNow = GUICtrlRead($nTab)
            $aTab[$iTabNow + 1][2] .GoForward
        Case $GUI_Button_Stop
            $iTabNow = GUICtrlRead($nTab)
            $aTab[$iTabNow + 1][2] .Stop
    EndSwitch
WEnd

Func _IEEvent_CommandStateChange($command, $enable)
    Switch $command
        Case $CSC_NAVIGATEBACK
            If $enable = True Then
              GUICtrlSetState($GUI_Button_Back, $GUI_ENABLE)
            Else
              GUICtrlSetState($GUI_Button_Back, $GUI_DISABLE)
            EndIf
        Case $CSC_NAVIGATEFORWARD
            If $enable = True Then
              GUICtrlSetState($GUI_Button_Forward, $GUI_ENABLE)
            Else
              GUICtrlSetState($GUI_Button_Forward, $GUI_DISABLE)
            EndIf
    EndSwitch
EndFunc
 
Верх