Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
%Unicode=1
#Include "win32api.inc"
Global hDlg, hForeGroundWindow As Dword
%IDC_Select = 500
%IDC_Open = 501
%IDC_Close = 502
%IDC_Plus = 503
%IDC_Minus = 504
%IDC_Zero = 505
%IDC_Copy = 506
%IDC_Next = 507
%IDC_Prev = 508
Function PBMain() As Long
Dialog Default Font "Arial Black", 12, 1
Dialog New Pixels, 0, "Browser Controller ",,,800,60, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Open,"Open", 10,10,75,30
Control Add Button, hDlg, %IDC_Close,"Close", 100,10,75,30
Control Add Button, hDlg, %IDC_Select,"Select", 190,10,90,30
Control Add Button, hDlg, %IDC_Copy,"Copy", 300,10,70,30
Control Add Button, hDlg, %IDC_Plus,"Plus", 390,10,70,30
Control Add Button, hDlg, %IDC_Minus,"Minus", 480,10,70,30
Control Add Button, hDlg, %IDC_Zero,"Zero", 560,10,70,30
Control Add Button, hDlg, %IDC_Prev,"Prev", 640,10,70,30
Control Add Button, hDlg, %IDC_Next,"Next", 720,10,70,30
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
SetWindowPos(hDlg, %HWND_TOPMOST, 0, 0, 0, 0, %SWP_NOMOVE Or %SWP_NOSIZE) 'on Top
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Open : OpenLink "http://www.garybeene.com"
Dialog Set Text hDlg, "Browser Controller - Dialog: " + Str$(hDlg) + " Browser: " + Str$(hForeGroundWindow)
Case %IDC_Close : PostMessage hForeGroundWindow, %WM_SysCommand, %SC_Close, 0
Case %IDC_Select : SelectAll
Case %IDC_Copy : CopySelection
Case %IDC_Plus : ZoomIn
Case %IDC_Minus : ZoomOut
Case %IDC_Zero : ZoomZero
Case %IDC_Prev : SendPrev
Case %IDC_Next : SendNext
End Select
End Select
End Function
Sub OpenLink(URL$)
Local hInstance As Dword
hInstance = ShellExecute(hDlg, "Open", (Url$), $Nul, $Nul, %SW_Normal)
hForeGroundWindow = GetForeGroundWindow
While GetForeGroundWindow = hForeGroundWindow
Sleep 10
Wend
hForeGroundWindow = GetForeGroundWindow
End Sub
Sub ZoomIn
SetFocus hForeGroundWindow
SetForeGroundWindow hForeGroundWindow
keybd_event(%VK_CONTROL, 0, 0, 0)
keybd_event(%VK_Add, 0, 0, 0)
keybd_event(%VK_Add, 0, %KEYEVENTF_KEYUP, 0)
keybd_event(%VK_CONTROL, 0, %KEYEVENTF_KEYUP, 0)
End Sub
Sub ZoomOut
SetFocus hForeGroundWindow
SetForeGroundWindow hForeGroundWindow
keybd_event(%VK_CONTROL, 0, 0, 0)
keybd_event(%VK_Subtract, 0, 0, 0)
keybd_event(%VK_Subtract, 0, %KEYEVENTF_KEYUP, 0)
keybd_event(%VK_CONTROL, 0, %KEYEVENTF_KEYUP, 0)
End Sub
Sub ZoomZero
SetFocus hForeGroundWindow
SetForeGroundWindow hForeGroundWindow
keybd_event(%VK_CONTROL, 0, 0, 0)
keybd_event(%VK_0, 0, 0, 0)
keybd_event(%VK_0, 0, %KEYEVENTF_KEYUP, 0)
keybd_event(%VK_CONTROL, 0, %KEYEVENTF_KEYUP, 0)
End Sub
Sub SelectAll
SetFocus hForeGroundWindow
SetForeGroundWindow hForeGroundWindow
keybd_event(%VK_CONTROL, 0, 0, 0)
keybd_event(%VK_A, 0, 0, 0)
keybd_event(%VK_A, 0, %KEYEVENTF_KEYUP, 0)
keybd_event(%VK_CONTROL, 0, %KEYEVENTF_KEYUP, 0)
End Sub
Sub CopySelection
SetFocus hForeGroundWindow
SetForeGroundWindow hForeGroundWindow
keybd_event(%VK_CONTROL, 0, 0, 0)
keybd_event(%VK_C, 0, 0, 0) 'remove this and keyboard fails
keybd_event(%VK_C, 0, %KEYEVENTF_KEYUP, 0) 'remove this and keyboard fails
keybd_event(%VK_CONTROL, 0, %KEYEVENTF_KEYUP, 0) 'remove this and keyboard fails
End Sub
Sub SendNext
SetFocus hForeGroundWindow
SetForeGroundWindow hForeGroundWindow
keybd_event(%VK_Menu, 0, 0, 0)
keybd_event(%VK_Right, 0, 0, 0)
keybd_event(%VK_Right, 0, %KEYEVENTF_KEYUP, 0)
keybd_event(%VK_Menu, 0, %KEYEVENTF_KEYUP, 0)
End Sub
Sub SendPrev
SetFocus hForeGroundWindow
SetForeGroundWindow hForeGroundWindow
keybd_event(%VK_Menu, 0, 0, 0)
keybd_event(%VK_Left, 0, 0, 0)
keybd_event(%VK_Left, 0, %KEYEVENTF_KEYUP, 0)
keybd_event(%VK_Menu, 0, %KEYEVENTF_KEYUP, 0)
End Sub
http://www.garybeene.com/sw/gbsnippets.htm