AutoHotkey Community

It is currently May 25th, 2012, 8:50 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: April 26th, 2007, 2:47 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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 August 21st, 2007, 6:34 am, edited 6 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2007, 9:04 am 
For me, it displays the list of icons in the Quick Run toolbar...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2007, 10:08 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2007, 10:20 am 
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
     }


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2007, 10:33 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2007, 1:29 am 
Offline

Joined: July 15th, 2006, 1:30 am
Posts: 48
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2007, 1:39 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2007, 1:16 pm 
Offline

Joined: July 15th, 2006, 1:30 am
Posts: 48
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2007, 3:47 pm 
Nice. thx.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 9th, 2007, 6:18 pm 
Offline

Joined: July 15th, 2006, 1:30 am
Posts: 48
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 10th, 2007, 1:01 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 10th, 2007, 2:39 am 
Offline

Joined: July 15th, 2006, 1:30 am
Posts: 48
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2007, 6:18 pm 
Offline

Joined: July 15th, 2006, 1:30 am
Posts: 48
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2007, 1:03 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2007, 1:34 am 
Offline

Joined: July 15th, 2006, 1:30 am
Posts: 48
Ah! Too bad, pity indeed.

Thanks for clearing that up anyway. :D

_________________
One hotkey to rule them all!


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 42 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 4 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:
cron
Powered by phpBB® Forum Software © phpBB Group