Как на vbs или bat или cmd изменить размер окна браузера?

Узнай цену своей работы

Формулировка задачи:

Здравствуйте. Нужен скрипт vbs для изменения уже открытого окна мазилы размером 600х800. Нашёл код 2014г. для мазилы,не работает.
Листинг программы
  1. function get_ww(window) {
  2. var frameWidth = 800;
  3. if (window.self.innerWidth)
  4. frameWidth = window.self.innerWidth;
  5. else if (window.document.documentElement && window.document.documentElement.clientWidth)
  6. frameWidth = window.document.documentElement.clientWidth;
  7. else if (window.document.body)
  8. frameWidth = window.document.body.clientWidth;
  9. return frameWidth;
  10. }
  11. function get_wh(window) {
  12. var frameHeight = 600;
  13. if (window.self.innerHeight)
  14. frameHeight = window.self.innerHeight;
  15. else if (window.document.documentElement && window.document.documentElement.clientHeight)
  16. frameHeight = window.document.documentElement.clientHeight;
  17. else if (window.document.body)
  18. frameHeight = window.document.body.clientHeight;
  19. return frameHeight;
  20. }

Решение задачи: «Как на vbs или bat или cmd изменить размер окна браузера?»

textual
Листинг программы
  1. Option Explicit
  2.  
  3. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExW" (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
  4. Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthW" (ByVal hWnd As Long) As Long
  5. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextW" (ByVal hWnd As Long, ByVal lpString As Long, ByVal cch As Long) As Long
  6. Private Declare Function MoveWindow Lib "user32" (ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
  7.  
  8. Private Sub Form_Load()
  9.     Dim hWnd        As Long
  10.     Dim cbCount     As Long
  11.     Dim wszBuffer   As String
  12.    
  13.     Do
  14.        
  15.         hWnd = FindWindowEx(0, hWnd, StrPtr("MozillaWindowClass"), 0)
  16.        
  17.         If hWnd = 0 Then Exit Sub
  18.        
  19.         cbCount = GetWindowTextLength(hWnd)
  20.        
  21.         If cbCount > 0 Then
  22.            
  23.             wszBuffer = Space$(cbCount)
  24.            
  25.             GetWindowText hWnd, StrPtr(wszBuffer), cbCount + 1
  26.            
  27.             If InStr(1, wszBuffer, "Mozilla Firefox", vbTextCompare) > 0 Then
  28.                 Exit Do
  29.             End If
  30.            
  31.         End If
  32.        
  33.         Debug.Assert DoEvents >= 0
  34.        
  35.     Loop
  36.    
  37.     MoveWindow hWnd, 100, 100, 400, 400, 1
  38.        
  39. End Sub

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

11   голосов , оценка 3.909 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы