AutoHotkey Community

It is currently May 27th, 2012, 1:38 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: July 15th, 2005, 11:12 am 
Below is a script to allow some control of windows using the keybourd.
I have developed repetitive strain ingery from using the mouse, so I wrote this script. It does not simulate a mouse it alows you to directly do some of the things you would normaly use a mouse for. Please feel free to add to it and post improvments. But remember the idea is not to simulate the mouse, thing of tasks/goals you are trying to do. and how they can better be done with the keyboard.

I have another script (multi desktop) that also has some simala window control stuf. it is only in a seperate script because it shares code with the desktop switching.


Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The following code copyright Richard Delorenzi 2005
; You may ether:
;
; 1) Do with it only that permited by local copyright laws.
; OR
; 2) DO What is permited by GPL licence version 2 see
; http://www.gnu.org/licenses/gpl.html
; OR
; 3) you can use, copy, modify, sell, study, etc.
; but if you pass it on you must pass on the same rights as you have
; and not block them technicaly
; i.e. if you turn it in to a .exe you must provide the script as well 
;
; If excersising cluse 2 you may remove the text of clause 1 and 3 if it helps.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; run commands. allows commands to be entered Win/x Command

#x::
  input,TextIn,CI,{ENTER}{ESC}{SPACE}
  ifequal,TextIn,title
  {
    gosub,SetTitle
  }
  ifequal,TextIn,terminal
  {
    gosub,RunTerminal
  }
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Helpers for run commands

RunTerminal: ; :todo: fix broken
  olddir=%S_WorkingDir%
  run,c:\Program Files\AutoHotkey\xterm.bat.lnk
  setWorkingDir,%olddir%
return

SetTitle:
  ToolTip,type in a title,0,0
  input,TextIn,CI,{ENTER}{ESC}
  ifequal,ErrorLevel,EndKey:Enter
  {
    winsettitle,A,,%TextIn%
  }
  ToolTip
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Move active window
; Win and   arrows to move
; Win/ctrl  arrows to move faster
; Win/Shift arrows to move to edge

;slow move window

#Right::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X+10,Y
return

#Left::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X-10,Y
return

#Up::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X,Y-10
return

#Down::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X,Y+10
return

;fast move window

#^Right::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X+100,Y
return

#^Left::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X-100,Y
return

#^Up::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X,Y-100
return

#^Down::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X,Y+100
return

;move window to edge

#+Right::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,A_ScreenWidth-W,Y
return

#+Left::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,0,Y
return

#+Up::
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X,0
return

#+Down::
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X,A_ScreenHeight-H-TH
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Resize active window
; win/t make active window tall
; win/m minimize active window

#t:: ;max hight current window
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,
  WinGetPos,X,Y,W,H,A,,,
  WinMove,A,,X,0,W,A_ScreenHeight-TH
  ; if window does not honer resize exactly so is slightly smaller than
  ; asked for its bottom edge will be where expected but to edge will be lower
  ; nextline puts top enge where I want it.
  WinMove,A,,X,0 ; :langbug: above line gets y position slightly wrong   
return

#M:: ; minimize(iconify) current window
  WinMinimize,A,,,
return

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; explorer

;;key conflict
;+Right:: ;;fast next link
;  IfWinActive, ahk_class IEFrame
;  {
;    Loop,10
;    {
;      Send,{Tab}
;    }
;  }
;  else
;  {
;    Send,+{Right}
;  }
;return

;+Left:: ;;fast prev link
;  IfWinActive, ahk_class IEFrame
;  {
;    Loop,10
;    {
;      Send,+{Tab}
;    }
;  }
;  else
;  {
;    Send,+{Left}
;  }
;return

#e:: ;;start explorer
  Run,c:/Program Files/Internet Explorer/iexplore.exe file:////c:/controlled/arm/src
return


Report this post
Top
  
Reply with quote  
 Post subject: Add resizing
PostPosted: April 1st, 2009, 6:33 am 
hi,

I added resizing (ALT + Direction keys):
(cool script, thanks!)

#!Up::
WinGetPos,X,Y,W,H,A,,,
WinMove,A,,X,0,W,H-10
return
#!Down::
WinGetPos,X,Y,W,H,A,,,
WinMove,A,,X,0,W,H+10
return
#!Left::
WinGetPos,X,Y,W,H,A,,,
WinMove,A,,X,0,W-10,H
return

#!Right::
WinGetPos,X,Y,W,H,A,,,
WinMove,A,,X,0,W+10,H
return


Report this post
Top
  
Reply with quote  
 Post subject: Oops, should be this one
PostPosted: April 1st, 2009, 6:35 am 
#!Up::
WinGetPos,X,Y,W,H,A,,,
WinMove,A,,X,,W,H-10
return
#!Down::
WinGetPos,X,Y,W,H,A,,,
WinMove,A,,X,,W,H+10
return
#!Left::
WinGetPos,X,Y,W,H,A,,,
WinMove,A,,X,,W-10,H
return

#!Right::
WinGetPos,X,Y,W,H,A,,,
WinMove,A,,X,,W+10,H
return


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 20 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