AutoHotkey Community

It is currently May 27th, 2012, 10:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: November 1st, 2006, 2:52 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
This is little demonstration of mechanism to pin window on the desktop and write into invisible edit field there. If you hover your mouse over the text, white rectangle will appear witch you can use to move the text around (like caption). Double click the caption to exit.

This demonstration will display top level windows on your desktop.
This is the screenshot

Code:
#SingleInstance, force
SetBatchLines, -1

   ;set the messages
   WM_MOUSEMOVE      = 0x200
   WM_ACTIVATE         = 0x06
   GW_HWNDNEXT         = 2


   OnMessage(WM_ACTIVATE, "OnActivate")
   OnMessage(WM_MOUSEMOVE, "OnMouseMove")

   ;---------  setup ------------------
   gWidth        := 420
   gHeight       := 320
   gTitleHeight  := 15
   gRefresh      := 500
   ;-----------------------------------


   Gui, -Caption +LastFound +ToolWindow
   hwnd := WinExist()

   ;add caption
   Gui, Font, ,Webdings
   Gui, Add, Text, x0 y0 w%gWidth% h%gTitleHeight% GuiMove CFFFFFF, g
   Gui, Font, ,Courier New

   ;set trans color
   Gui, Color,EEAA99 , EEAA99
   WinSet, TransColor, EEAA99

   ;add edit control
   Gui, Add, Edit, x0 y0 w%gWidth% h%gHeight% cYELLOW -0x200000 -0x4000 -E0x200, Refreshing....

   ;pin to desktop and show
   WinSet, Bottom
   Gui, Show, w%gWidth% h%gHeight% X250 Y250 NoActivate

   ;set timer to refresh text in the edit
   SetTimer Refresh, %gRefresh%
return

;--------------------------------------------------------------------------
Refresh:
   GuiControl, ,Edit1, % "TOP LEVEL WINDOWS`n_________________`n`n" GetTopLevelWindows()
return

;--------------------------------------------------------------------------

uiMove:
   if (A_GuiControlEvent = "DoubleClick")
      ExitApp
   PostMessage, 0xA1, 2,,, A
return

;--------------------------------------------------------------------------

OnMouseMove()
{
   global   

   if !titleVis
   {
      GuiControl, Move, Edit1, % "y" gTitleHeight + 5
      WinSet, Redraw
      titleVis := true

      SetTimer TitleTimer, 3000
   }
}

;--------------------------------------------------------------------------

TitleTimer:
   SetTimer TitleTimer, off
   GuiControl, Move, Edit1, y0
   titleVis := false
return

;--------------------------------------------------------------------------

OnActivate(wparam, lparam)
{
   global
   WinSet, Bottom
}

;--------------------------------------------------------------------------

OnTimer:
   SetTimer OnTimer, off

   WinSet, Style, -0xC00000, ahk_id %hwnd%
   WinSet Redraw
   PostMessage, 0x111, 28931,,, ahk_class Progman
   WinSet, Bottom
return

;--------------------------------------------------------------------------

GetTopLevelWindows()
{
   local title, res, next, i

   next := DllCall("GetWindow", "uint", hwnd, "uint", GW_HWNDFIRST)
    loop
    {
     if !DllCall("IsWindowVisible", "uint", next)
         goto jump

   
      WinGetTitle, title, ahk_id %next%
     if InStr(res, title) > 0
      goto jump
   
   

      if (title != "") && (title != "Program Manager") && (title != A_ScriptName)
     {
         res = %res%%title%`n
        i++
     }
    
jump:
     next := DllCall("GetWindow", "uint", next, "uint", GW_HWNDNEXT)
      if (next = 0)
         break

    }
   res := res "`nTotal: " i
   return res
}

_________________
Image


Last edited by majkinetor on November 2nd, 2006, 9:25 am, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2006, 4:19 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
I replaced the code with the new one that will display the list of the top level windows in the system. You can change gRefresh parameter witch is currently set at 1 sec.


I tried Laszlo function GetCpuLoad, but somehow it doesn't work in this sceneario.... it display well, but on mouse over nothing happens. After I did examine the problem I find out that call to dll function Laszlo used will somehow block mouse move monitoring ?! If I delete all lines of this function and just leave that dll call the same things happen, if I remove just this line everything is back to normal...

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2006, 5:55 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
One note:

If you have some desktop extension, like DesktopX or IconX you will have to turn them off for a moment, as they are drawn above the desktop so this script will be invisible as it is Z-ordered in between.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 29th, 2008, 2:03 pm 
Hi,

I can't get this timer/function to work. :oops:

I think part of the function is not relevant because I'm only after the TOP level visible windows IDs listed in the current stack order.

I wanna use this TOP level windows IDs list to play with the windows on the alt-tab menu (swap order etc) on an other script.

Could you please help? Thanks

Code:
#SingleInstance, force
DetectHiddenWindows, Off
SetBatchLines, -1

SetTimer, Watch, 200
Return

Watch:
ToolTip, % GetTopLevelWindows()
Return

~Esc::
SetTimer, Watch, Off
ToolTip
KeyWait, Esc
SetTimer, Watch, 200
Return

GetTopLevelWindows()
   {
   local title, res, next, i

   next := DllCall("GetWindow", "uint", hwnd, "uint", GW_HWNDFIRST)
    loop
       {
       If !DllCall("IsWindowVisible", "uint", next)
           goto jump

      
       WinGetTitle, title, ahk_id %next%
       if InStr(res, title) > 0
         goto jump
      
      If (title != "") && (title != "Program Manager") && (title != A_ScriptName)
         {
            res = %res%%next%`n
           i++
         }
        
      jump:
        next := DllCall("GetWindow", "uint", next, "uint", 2)
         if (next = 0)
            break
       }
   return res
   }




Report this post
Top
  
Reply with quote  
 Post subject: I found
PostPosted: July 29th, 2008, 3:39 pm 
Hi,

I found:

http://www.autohotkey.com/forum/topic23 ... indow+list

Thanks


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 51 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group