AutoHotkey Community

It is currently May 26th, 2012, 9:35 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: August 11th, 2009, 3:29 am 
Offline

Joined: July 1st, 2009, 9:13 pm
Posts: 16
This is a working draft of a decent alternative to alt-tab. If you assign this to a hotkey, you no longer have to hold down the alt key, and it makes it more convenient to use an auto-hide taskbar without using a mouse. I developed this to use with Dragon NaturallySpeaking since their mouse support is, ahem, cumbersome.

This script sets focus to the first item on the taskbar, "unhiding" the taskbar if necessary. You can then use the arrow keys or type the name of the app to set focus to the item, then press enter to activate it.

[EDIT: this is the new version of the code, see 2 posts down for the new post.]
Code:
   ; show and activate the taskbar
   WinShow ahk_class Shell_TrayWnd
   WinActivate ahk_class Shell_TrayWnd

   Sleep 40   ; NOTE: you might have to tweak this depending on your system
   
   ; open start menu and then tab to the first task listed
   SendPlay {LWin}
   SendPlay {Escape}{Tab 2}

   ; move mouse away from the auto-hide taskbar if it's on the left or right side
   CoordMode, Mouse, Screen
   MouseGetPos, mouseX, mouseY
   WinGetPos, barX, barY, width, height, ahk_class Shell_TrayWnd

   if( barX < 20 and mouseX <= width )
      mouseX := width + 20
   if( barX > 20 and mouseX >= barX )
      mouseX := barX - 20
   MouseMove, % mouseX > width ? mouseX : width + 20, mouseY, 2

   return

I hope this is a useful starter script for folks, it's certainly been convenient for me while dealing with RSI... ~Ivo


Last edited by IvoLucien on April 30th, 2010, 7:57 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: thanks!
PostPosted: August 25th, 2009, 1:39 pm 
Offline

Joined: August 25th, 2009, 1:05 pm
Posts: 2
Location: Moscow
Simple and useful!
Great reusing of capabilities!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 12:07 am 
Offline

Joined: July 1st, 2009, 9:13 pm
Posts: 16
Thanks much.

Here's a new, generalized version. The 2nd half just moves the mouse away from the taskbar, only relevant for autohide taskbar scenarios.

Code:
   ; show and activate the taskbar
   WinShow ahk_class Shell_TrayWnd
   WinActivate ahk_class Shell_TrayWnd

   Sleep 40   ; NOTE: you might have to tweak this depending on your system
   
   ; open start menu and then tab to the first task listed
   SendPlay {LWin}
   SendPlay {Escape}{Tab 2}

   ; move mouse away from the auto-hide taskbar if it's on the left or right side
   CoordMode, Mouse, Screen
   MouseGetPos, mouseX, mouseY
   WinGetPos, barX, barY, width, height, ahk_class Shell_TrayWnd

   if( barX < 20 and mouseX <= width )
      mouseX := width + 20
   if( barX > 20 and mouseX >= barX )
      mouseX := barX - 20
   MouseMove, % mouseX > width ? mouseX : width + 20, mouseY, 2

   return

If anyone knows how to detect if the taskbar is set to auto-hide, that would add a nice little bit of polish.

Ivo


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2010, 4:07 pm 
Offline

Joined: December 15th, 2008, 12:27 pm
Posts: 13
Assuming you send these:
sysget, Mon, Monitor
sysget, SM_CYCAPTION, 4
sysget, SM_CYFULLSCREEN, 17
WinGetPos,,, tbW, tbH, ahk_class Shell_TrayWnd

I think if SM_CYCAPTION+SM_CYFULLSCREEN equals MonBottom-MonTop, the taskbar is autohidden.

if SM_CYCAPTION+SM_CYFULLSCREEN+tbH equals MonBottom-MonTop, the taskbar is not hidden.

Another way would be to compare the results of
sysget, Mon, Monitor and sysget, MonWorkArea, MonitorWorkArea


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 9th, 2010, 6:51 pm 
Offline

Joined: July 1st, 2009, 9:13 pm
Posts: 16
Thank you, that's fabulous. ^_^

I'll write this up when I have time (probably months from now given how my project is going) or will happily integrate it if anyone provides the finished code segment.

*waves cheerfully*

szekelya wrote:
Assuming you send these:
sysget, Mon, Monitor
...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2010, 2:09 pm 
I've tried this and it doesn't really do anything useful for me. What am I missing? What should it be doing as far as task switching? If I need to run it each time to accomplish something, is that easier than alt-tab?

Sorry if I've totally missed what and how this works; it could all just be my problem. Thanks for any help.


Report this post
Top
  
Reply with quote  
PostPosted: April 30th, 2010, 7:50 pm 
Offline

Joined: July 1st, 2009, 9:13 pm
Posts: 16
Sorry to leave out a required setup step. I keep an AutoHotkey script running persistently so that my various hotkeys can be used at any time. This script is intended to be assigned to a hotkey or hotstring. The ahk help has info about making scripts persistent.

This script is probably only interesting to DNS users and people who have enough windows open at once that alt-tabbing becomes impractical (I often have 20-30 apps open.) In my case, I've assigned it to a voice recognition macro by way of Dragon Naturally Speaking, which has poor task switching to start with.

For those who are interested, if you set up your taskbar on the right or left, set it to autohide, and make it very wide, you get the benefit of seeing the full title of your apps as you switch tasks using the arrow keys or by typing the name of the app to move the taskbar selection to that item.

bbunk wrote:
I've tried this and it doesn't really do anything useful for me. What am I missing? What should it be doing as far as task switching? If I need to run it each time to accomplish something, is that easier than alt-tab?


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot] and 9 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