Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[SOLVED] Unhiding Opera browser from tray minor problem


  • Please log in to reply
29 replies to this topic
wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
I like Opera browser's minimize to tray function (ctrl-H), very much indeed.

The problem is that usual routine for showing a hidden window somehow skips Opera's recognition for its new restored window state - I press Win-O, Opera is shown, everything works as it should, BUT not ctrlH because Opera's minimizing module still thinks it is hidden in tray. So I have to doubleclick tray icon.

Is there some message or correct sequence that should be used by external app to tell opera it is restored?
Now I use this autohotkey command: "WinShow,Opera ahk_class OpWindow" which works because opera's main window always contains text "Opera" or " - Opera" (I use "SetTitleMatchMode,2" too look for text inside titles). And of course WinActivate.

I tried using "process,exist,opera.exe" with "winShow,ahk_pid %errorlevel%" but it works with incorrect subwindow which is auxiliary in opera and is never shown, neither should

n-l-i-d
  • Guests
  • Last active:
  • Joined: --
Maybe you could emulate a doubleclick on the tray icon with the code from this posting?: Extract Informations about TrayIcons

wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
It will help probably, but I'm unsure how to use the info provided by that utility to emulate doubleclicking...I'll have to play with that

Carlol
  • Members
  • 163 posts
  • Last active: Aug 03 2010 03:45 AM
  • Joined: 14 Aug 2006
I'm not quite sure I understand but to get Firefox out from the tray I use this:
#7::
SetTitleMatchMode,2 
DetectHiddenWindows, On
Winshow, Mozilla Firefox
Winactivate, Mozilla Firefox
Return
Maybe you can use it to get inspired. Happy Scripting :-)

wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
Unfortunately Opera uses very strange window structure and unusual tray hiding, so such a straghtfoward WinShow doesn't help me, as I wrote it in the first post, alas :-(

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
Then do the tray hiding yourself. I know there's at least one AHK script and innumerable utilities out there to do it, and they'll do it the right way.

wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
Yes, that's a good thought

urlwolf
  • Members
  • 150 posts
  • Last active: Feb 26 2012 07:56 PM
  • Joined: 16 Mar 2006
Did anyone solve this problem? I'd love to be able to talk to opera using AHK, but everything I tried didn't work.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

It will help probably, but I'm unsure how to use the info provided by that utility to emulate doubleclicking...I'll have to play with that

First run the script "Extract ..." when opera.exe is trayminimized.
Then, replace nMsg, uID, Classname in the below with appropriate ones from the MessageBox of the results. 0x203 is WM_LBUTTONDBLCLK.

I assumed that they are static, and classname is also unique. If they really are, you have to do it only once. Afterwards, you can use it as it is now.
As I don't use opera.exe myself, I can't test it here.

DetectHiddenWindows On
PostMessage, nMsg, uID, 0x203, , ahk_class Classname


wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
AAAAAAAAAAAAAAAA!!!!!!!!!!!!!!!!!

Then, replace nMsg, uID, Classname in the below with appropriate ones from the MessageBox of the results. 0x203 is WM_LBUTTONDBLCLK.


THANX! thanx! thanx! thanx! thanx! thanx!

I've included the script (slightly modded to look for OpTaskWindow) into my autoHotKey.ini and now it works like a charm

urlwolf
  • Members
  • 150 posts
  • Last active: Feb 26 2012 07:56 PM
  • Joined: 16 Mar 2006

AAAAAAAAAAAAAAAA!!!!!!!!!!!!!!!!!

Then, replace nMsg, uID, Classname in the below with appropriate ones from the MessageBox of the results. 0x203 is WM_LBUTTONDBLCLK.


THANX! thanx! thanx! thanx! thanx! thanx!

I've included the script (slightly modded to look for OpTaskWindow) into my autoHotKey.ini and now it works like a charm


I have followed the steps, but it doesn't work here.
Can you post your modified script? BTW, mine says 'opTaskBar' when mimimized.

I want a key to both send Opera to tray and get it back from there.
The first part is not difficult, but the last... uff.

wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006
I ripped it from my ahk's ini, so it might need some modding

#o::
   DetectHiddenWindows, On
   ifWinExist,ahk_class OpTaskbar
      OperaTrayRestore()
   else {
   	; execute opera or bring window to front if it is minimized
      i:=A_TitleMatchMode
      SetTitleMatchMode,2 ;inside titles

		ifWinExist OpWindow
	   {  
	      winActivate			// just my sequence of spells ;-)
         winShow
         ifWinNotActive		
            winRestore
	   }
	   else
	   {
	   	Run %programFiles%\opera\opera.exe
	   }
      SetTitleMatchMode,%i%
   }
	return




;##################################################
OperaTrayRestore()
{
   hid:=A_DetectHiddenWindows
   DetectHiddenWindows, On
   WinGet, pid, PID, ahk_class Shell_TrayWnd

   hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pid)
   pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)

   VarSetCapacity(btn, 20)
   VarSetCapacity(nfo, 24)

   SendMessage, 0x418, 0, 0, ToolbarWindow321, ahk_class Shell_TrayWnd   ; TB_BUTTONCOUNT

   Loop, %ErrorLevel%
   {
      SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow321, ahk_class Shell_TrayWnd   ; TB_GETBUTTON

      DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)

      idn    := DecodeInteger(&btn + 4)
      dwData := DecodeInteger(&btn +12)

      DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 24, "Uint", 0)

      hWnd  := DecodeInteger(&nfo + 0)
      uID   := DecodeInteger(&nfo + 4)
      nMsg  := DecodeInteger(&nfo + 8)
      hIcon := DecodeInteger(&nfo +20)

      WinGetClass, sClass, ahk_id %hWnd%
      ifEqual,sClass,OpTaskbar
      {
         PostMessage, %nMsg%, %uID%, 0x0203, , ahk_id %hWnd%
         break
      }

   }

   DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
   DllCall("CloseHandle", "Uint", hProc)

   DetectHiddenWindows, %hid%
   Return ;sTrayIcons
}


DecodeInteger(ptr)
{
   Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
}

EncodeInteger(ref, val, nSize = 1)
{
   DllCall("ntdll\RtlFillMemoryUlong", "Uint", ref, "Uint", nSize * 4, "Uint", val)
}


P.S. not opTaskBar but opTaskbar

urlwolf
  • Members
  • 150 posts
  • Last active: Feb 26 2012 07:56 PM
  • Joined: 16 Mar 2006
Other applications that dot work with standard methods when minimzed to tray, such as mediaMonkey and timeKeeper, do not work with this method either.

Guest+
  • Guests
  • Last active:
  • Joined: --
This script works for me-

If WinExist("ahk_class OpWindow")
ControlSend,OperaWindowClass19,^h,ahk_class OpWindow
Else{
DetectHiddenWindows On
PostMessage, 1035, 1, 0x203, , ahk_class OpTaskbar
}

wOxxOm
  • Members
  • 371 posts
  • Last active: Feb 20 2015 12:10 PM
  • Joined: 09 Feb 2006

This script works for me-
PostMessage, 1035, 1, 0x203, , ahk_class OpTaskbar


PERFECT!!!!!!!!!!!!!!!!!!!!!!!! Thank you for sharing this!