AutoHotkey Community

It is currently May 27th, 2012, 11:06 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: January 4th, 2012, 4:28 pm 
Online

Joined: October 13th, 2009, 11:56 am
Posts: 103
I used the code from the help file to get a list of existing windows:
Code:
WinGet, id, list,,, Program Manager
Loop, %id%
{
    this_id := id%A_Index%
    WinActivate, ahk_id %this_id%
    WinGetClass, this_class, ahk_id %this_id%
    WinGetTitle, this_title, ahk_id %this_id%
    MsgBox, 4, , Visiting All Windows`n%a_index% of %id%`nahk_id %this_id%`nahk_class %this_class%`n%this_title%`n`nContinue?
    IfMsgBox, NO, break
}


But it lists windows in the most recently viewed order instead of direct order (the order in which they lay on taskbar).
How to get that list sorted the way I need?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 11:00 am 
Online

Joined: October 13th, 2009, 11:56 am
Posts: 103
Anyone? please, help me :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 3:35 pm 
It has been posted on the forum. I always forget the script but I know for one script the code is posted on google code, you can activate windows by pressing winkey+1-0 which is default under win7 but not xp so it see the correct order. something like activate by number or so. See http://code.google.com/hosting/search?q ... Autohotkey and you'll find it eventually, it has a black & white icon if I remember correctly.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 3:51 pm 
There is also one(or more??) script to get info from taskbar buttons,it migth be helpful.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 7:22 pm 
It is a script by Sean:

http://www.autohotkey.com/forum/post-109547.html#109547

taskbutton.ahk

Code:
#NoTrayIcon
DetectHiddenWindows, On

MsgBox % TaskButtons()
Return

TaskButtons(sExeName = "")
{
   WinGet,   pidTaskbar, PID, ahk_class Shell_TrayWnd
   hProc:=   DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
   pProc:=   DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
   idxTB:=   GetTaskSwBar()
      SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_BUTTONCOUNT
   Loop,   %ErrorLevel%
   {
      SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_GETBUTTON
      VarSetCapacity(btn,32,0)
      DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &btn, "Uint", 32, "Uint", 0)
         iBitmap   := NumGet(btn, 0)
         idn   := NumGet(btn, 4)
         Statyle := NumGet(btn, 8)
      If   dwData   := NumGet(btn,12)
         iString   := NumGet(btn,16)
      Else   dwData   := NumGet(btn,16,"int64"), iString:=NumGet(btn,24,"int64")
      DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "int64P", hWnd:=0, "Uint", NumGet(btn,12) ? 4:8, "Uint", 0)
      If Not   hWnd
         Continue
      WinGet, pid, PID,              ahk_id %hWnd%
      WinGet, sProcess, ProcessName, ahk_id %hWnd%
      WinGetClass, sClass,           ahk_id %hWnd%
      If !sExeName || (sExeName = sProcess) || (sExeName = pid)
         VarSetCapacity(sTooltip,128), VarSetCapacity(wTooltip,128*2)
      ,   DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString, "Uint", &wTooltip, "Uint", 128*2, "Uint", 0)
      ,   DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
      ,   sTaskButtons .= "idx: " . A_Index-1 . " | idn: " . idn . " | pid: " . pid . " | hWnd: " . hWnd . " | Class: " . sClass . " | Process: " . sProcess . "`n" . "   | Tooltip: " . sTooltip . "`n"
   }
   DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pProc, "Uint", 0, "Uint", 0x8000)
   DllCall("CloseHandle", "Uint", hProc)
   Return   sTaskButtons
}

HideButton(idn, bHide = True)
{
   idxTB := GetTaskSwBar()
   SendMessage, 0x404, idn, bHide, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_HIDEBUTTON
}

DeleteButton(idx)
{
   idxTB := GetTaskSwBar()
   SendMessage, 0x416, idx, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_DELETEBUTTON
}

MoveButton(idxOld, idxNew)
{
   idxTB := GetTaskSwBar()
   SendMessage, 0x452, idxOld, idxNew, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd    ; TB_MOVEBUTTON
}

GetTaskSwBar()
{
   ControlGet, hParent, hWnd,, MSTaskSwWClass1 , ahk_class Shell_TrayWnd
   ControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%
   Loop
   {
      ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
      If  Not   hWnd
         Break
      Else If   hWnd = %hChild%
      {
         idxTB := A_Index
         Break
      }
   }
   Return   idxTB
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 11:48 pm 
Online

Joined: October 13th, 2009, 11:56 am
Posts: 103
Anonymous wrote:
It has been posted on the forum. I always forget the script but I know for one script the code is posted on google code, you can activate windows by pressing winkey+1-0 which is default under win7 but not xp so it see the correct order. something like activate by number or so. See http://code.google.com/hosting/search?q ... Autohotkey and you'll find it eventually, it has a black & white icon if I remember correctly.

http://code.google.com/p/activatebynum/ this one?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 11:51 pm 
Online

Joined: October 13th, 2009, 11:56 am
Posts: 103
Anonymous wrote:
There is also one(or more??) script to get info from taskbar buttons,it migth be helpful.

without a link to that script it's not helpful much...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 11:52 pm 
Online

Joined: October 13th, 2009, 11:56 am
Posts: 103
guest 2 wrote:
It is a script by Sean:

http://www.autohotkey.com/forum/post-109547.html#109547

taskbutton.ahk

It does nothing for me: it just pops up with a blank message box.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 11:52 pm 
Use the search


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2012, 4:06 am 
Online

Joined: October 13th, 2009, 11:56 am
Posts: 103
Search gave no results.
However, one kind person on a local Russian forum of AHK wrote this code:
Code:
#NoTrayIcon
VarSetCapacity(IID, 16)
NumPut(0x11CF3C3D618736E0, IID, 0, "Int64")
NumPut(0x719B3800AA000C81, IID, 8, "Int64")
DllCall("kernel32\LoadLibrary", "Str", "Oleacc")
ControlGet, hWnd, Hwnd,, MSTaskListWClass1, ahk_class Shell_TrayWnd
taskList:=COM_AccessibleObjectFromWindow(hWnd)
Hotkey, Space, RedrawList
Gui, +AlwaysOnTop +ToolWindow
Gui, Add, ListView, r14 w450, Index|Title
RedrawList:
LV_Delete()
Loop, % taskList.accChildCount
  LV_Add("", A_Index, taskList.accName(A_Index))
Gui, Show,, % (!taskList.accChildCount ? "Nothing was found!"
: ("Found: "taskList.accChildCount " window"
. (taskList.accChildCount>1 ? "s":"  ")))"                     "
. "                        Space: refresh, F5: reload, Esc: exit"
Return
 
COM_AccessibleObjectFromWindow(Hwnd)
{
   global
   DllCall("Oleacc\AccessibleObjectFromWindow", "Ptr", Hwnd
                                              , "UInt", -4
                                              , "Ptr", &IID
                                              , "Ptr*", ppvObject)
   Return, ComObjEnwrap(ppvObject)
}
 
F5::Reload
Esc::
GuiClose:
   ExitApp

It lists windows how they lay on taskbar.
But, in that case we can activate windows only by their titles, and the problem is that different windows may have the same title, so we can't activate proper windows.

Here is another code:
Code:
;DetectHiddenWindows, On
#NoTrayIcon
Gui, +AlwaysOnTop -MinimizeBox +ToolWindow HwndGUIhWnd
Gui, Add, ListView, w450 h259, Index|Handle        |Title
ArrayID:=[]
WinGet, ListID, List,,, Running Applications
Loop, % ListID
{
   IDs:=ListID%A_Index%
   WinGetTitle, WinTitle, % "ahk_id"IDs
   If !WinTitle
   {
      Counter++
      Continue
   }
   ArrayID.Insert(IDs)
}
Gui, Show,, % (!ListID ? "Nothing was found!"
: ("Found all: "ListID " window"(ListID>1 ? "s":"  ")))
. ", with title: "ListID-Counter "                "
. "                           F5: reload, Esc: exit"
For Key, Value In ArrayID
{
   WinGetTitle, WinTitle, % "ahk_id"Value
   LV_Add("", Key, Value, WinTitle)
}
Return
 
F5::Reload
Esc::
GuiClose:
   ExitApp

It has windows' descriptors, so we can do proper calls for different windows with the same title. But the list itself is not in the direct order.

HELP!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2012, 4:10 pm 
Online

Joined: October 13th, 2009, 11:56 am
Posts: 103
Can anyone help me with getting the list of windows in the direct order with the ability to call them (not by title, but by some unique ID)?


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Edd, Exabot [Bot], Google Feedfetcher, HotkeyStick and 13 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