AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extract Informations about TaskButtons
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Thu Apr 26, 2007 2:47 am    Post subject: Extract Informations about TaskButtons Reply with quote

It'll extract infos about the taskbar buttons, as a sequel to the script:
http://www.autohotkey.com/forum/topic17314.html

DOWNLOAD TaskButton.ahk/TrayIcon.ahk.


Last edited by Sean on Tue Aug 21, 2007 6:34 am; edited 6 times in total
Back to top
View user's profile Send private message
Grumpy
Guest





PostPosted: Thu Apr 26, 2007 9:04 am    Post subject: Reply with quote

For me, it displays the list of icons in the Quick Run toolbar...
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Thu Apr 26, 2007 10:08 am    Post subject: Reply with quote

Grumpy wrote:
For me, it displays the list of icons in the Quick Run toolbar...

OK, I changed it to not rely on any assumptions.
BTW, I chose other method than FindWindowEx, as it may be easier to be adapted to other toolbars.
Back to top
View user's profile Send private message
Grumpy
Guest





PostPosted: Thu Apr 26, 2007 10:20 am    Post subject: Reply with quote

I am sorry, but I see no difference...
WinXP Pro SP2.
I run VirtuaWin (multiple window manager) if that makes a difference.
Quick Launch = ToolbarWindow323
Task List = ToolbarWindow323
Notification Area = ToolbarWindow321

OK, going out of lazy mode, I found the error: the classical If without parentheses:
Code:
      If (sClass = "MSTaskSwWClass")
     {
         nTB := A_Index
         Break
     }
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Thu Apr 26, 2007 10:33 am    Post subject: Reply with quote

Grumpy wrote:
OK, going out of lazy mode, I found the error: the classical If without parentheses:

Right, thanks. The error wasn't detected in my test as I recycled the variable nTB.
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Fri Nov 09, 2007 1:29 am    Post subject: Reply with quote

Sean, do you know if it is possible to get the idx for a task button that is under the mouse? I am trying to make a script that will let you drag and drop the position of the task button on the task bar.

E.g: You have 3 task buttons and you want to move the 3rd one on the first place (near the start menu).

The MoveButton function is perfect for this but I am not sure how to get the idx for the specific task button under the mouse. (The mouse will point on the task bar button, not on the window of the process, so MouseGetPos cannot replicate this)

Any pointers?
Thanks again for this great script.
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Fri Nov 09, 2007 1:39 am    Post subject: Reply with quote

XavierGr wrote:
Sean, do you know if it is possible to get the idx for a task button that is under the mouse?

Yes using TB_HITTEST. I think lexicos uses it in his mouse-hover script:
http://www.autohotkey.com/forum/viewtopic.php?t=22763

BTW, if TB_GETHOTITEM is enough in your test, you may use it instead as it's simpler to use.
Code:
MsgBox, % GetHotItem() . " | " . HitTest()
Return

GetHotItem()
{
   idxTB := GetTaskSwBar()
   SendMessage, 0x447, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd   ; TB_GETHOTITEM
   Return ErrorLevel << 32 >> 32
}

HitTest()
{
   idxTB:=   GetTaskSwBar()
   ControlGet, hWnd, hWnd,, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd
   WinGet, pid, PID, ahk_id %hWnd%
   hProc:=   DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pid)
   pRB  :=   DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 8, "Uint", 0x1000, "Uint", 0x4)
   DllCall("GetCursorPos", "int64P", pt)
   DllCall("ScreenToClient", "Uint", hWnd, "int64P", pt)
   DllCall("WriteProcessMemory", "Uint", hProc, "Uint", pRB, "int64P", pt, "Uint", 8, "Uint", 0)
   idx  :=   DllCall("SendMessage", "Uint", hWnd, "Uint", 0x445, "Uint", 0, "Uint", pRB)   ; TB_HITTEST
   DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
   DllCall("CloseHandle"  , "Uint", hProc)
   Return   idx
}
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Fri Nov 09, 2007 1:16 pm    Post subject: Reply with quote

Brilliant!

Now a simple script like this, can make all the Taskbar Buttons Movable:

Code:
; Make the TaskBar Buttons Movable with LButton Drag and Drop
~LButton::
    MouseGetPos, , , id
    WinGetClass, Class, ahk_id %id%
    if(Class != "Shell_TrayWnd")
        return
    StartPos := GetHotItem()
return
   
~LButton Up::
    MouseGetPos, , , id
    WinGetClass, Class, ahk_id %id%
    if(Class != "Shell_TrayWnd")
        return
    MoveButton(StartPos, GetHotItem())
return


Make sure to include TaskButton.ahk and the GetHotItem() function on your script.

P.S: If someone can think of a less intrusive way to detect if the Mouse Cursor is on the taskbar please share. (My main concern is that now every time the user clicks, code is running even if we don't move taskbar buttons.
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
majkinetor !
Guest





PostPosted: Fri Nov 09, 2007 3:47 pm    Post subject: Reply with quote

Nice. thx.
Back to top
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Fri Nov 09, 2007 6:18 pm    Post subject: Reply with quote

I tested this code on Windows 2000 and unfortunately it won't work.
It seems that GetTaskbar() doesn't return a value.

Anypointers on how to fix it?
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Sat Nov 10, 2007 1:01 am    Post subject: Reply with quote

XavierGr wrote:
I tested this code on Windows 2000 and unfortunately it won't work.
It seems that GetTaskbar() doesn't return a value.

Does the following line in TaskButton.ahk return non-empty result in W2K?
Code:
MsgBox % TaskButtons()

You have to check with the Windows Spy tool if the taskbar control is ToolbarWindow32, not SysTabControl32.
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Sat Nov 10, 2007 2:39 am    Post subject: Reply with quote

Sean wrote:

Does the following line in TaskButton.ahk return non-empty result in W2K?
Code:
MsgBox % TaskButtons()

You have to check with the Windows Spy tool if the taskbar control is ToolbarWindow32, not SysTabControl32.


Yes, TaskButtons() doesn't return anything, I will try to look more closely on this next time I will be in front of a Window2000 machine. (Probably next week)

Thanks for the help anyway.
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Fri Nov 16, 2007 6:18 pm    Post subject: Reply with quote

With ToolBarWindow32 the ErrorLevel before the Loop in TaskButtons() is set to FAIL.

Replacing ToolBarWindow32 with SysTabControl32 the ErrorLevel is set to 0. So the loop never runs and no Buttons are returned from TaskButtons().

Even if I set ErrorLevel to a number before the Loop, the function fails to return anything, DllCall DllCall("ReadProcessMemory"...) after SendMessage, 0x417 returns 1. (And in the end hwnd is 0)

But the first error is that ErrorLevel is 0 so the Loop never executes.
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1141

PostPosted: Sat Nov 17, 2007 1:03 am    Post subject: Reply with quote

XavierGr wrote:
Replacing ToolBarWindow32 with SysTabControl32 the ErrorLevel is set to 0.

So, W2K seems to use SysTabControl32 for the taskbar controls, as I suspected. Then, I'm afraid you can't use this script in W2K.
Back to top
View user's profile Send private message
XavierGr



Joined: 15 Jul 2006
Posts: 42

PostPosted: Sat Nov 17, 2007 1:34 am    Post subject: Reply with quote

Ah! Too bad, pity indeed.

Thanks for clearing that up anyway. Very Happy
_________________
One hotkey to rule them all!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group