paschalism

WinStep.ahk

May 14th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;WinStep.ahk
  2. ; Step through groups of windows using hotkeys
  3. ;Skrommel @ 2005
  4.  
  5. #SingleInstance,Force
  6. SetTitleMatchMode,2
  7.  
  8. applicationname=WinStep
  9.  
  10. Gosub,READINI
  11. Gosub,TRAYMENU
  12.  
  13. Loop
  14. {
  15.   Sleep,100
  16.   GetKeyState,shift,LShift,P
  17.   GetKeyState,ctrl,LCtrl,P
  18.   GetKeyState,alt,LAlt,P
  19.   GetKeyState,win,LWin,P
  20.   shifts=%shift%%ctrl%%alt%%win%
  21.   keys=
  22.   Loop,10
  23.   {
  24.     key:=A_Index-1
  25.     GetKeyState,state,%key%,P
  26.     keys=%keys%%state%
  27.   }
  28.   StringGetPos,key,keys,D
  29.   state=%shifts%%key%
  30.   StringLen,length,state
  31.   If length=5
  32.   If shifts=%add%
  33.   {
  34.     WinGet,%add%%key%,ID,A
  35.     window:=%add%%key%
  36.     WinGetTitle,title,ahk_id %window%
  37.     SoundPlay,%addsound%
  38.     GroupAdd,group%key%,ahk_id %window%
  39.     TOOLTIP("Added to Group" key ": " title)
  40.   }
  41.   Else
  42.   If shifts=%show%
  43.   {
  44.     SoundPlay,%showsound%
  45.     GroupActivate,group%key%
  46.     TOOLTIP("Activating Group" key)
  47.   }
  48. }  
  49.  
  50.  
  51. TOOLTIP(tooltip,timeout=3000)
  52. {
  53.   ToolTip,%tooltip%
  54.   Sleep,1000
  55.   SetTimer,TOOLTIPOFF,%timeout%
  56.   Return
  57. }
  58.  
  59.  
  60. TOOLTIPOFF:
  61. SetTimer,TOOLTIPOFF,Off
  62. ToolTip
  63. Return
  64.  
  65.  
  66. TRAYMENU:
  67. Menu,Tray,DeleteAll
  68. Menu,Tray,NoStandard
  69. Menu,Tray,Add,%applicationname%,ABOUT
  70. Menu,Tray,Add,
  71. Menu,Tray,Add,&Settings...,SETTINGS
  72. Menu,Tray,Add,&About...,ABOUT
  73. Menu,Tray,Add,E&xit,Exit
  74. Menu,Tray,Default,%applicationname%
  75. Menu,Tray,Tip,%applicationname%
  76. Return
  77.  
  78.  
  79. SETTINGS:
  80. Gosub,READINI
  81. RunWait,%applicationname%.ini
  82. Gosub,READINI
  83. Return
  84.  
  85.  
  86. EXIT:
  87. ExitApp
  88.  
  89.  
  90. READINI:
  91. IfNotExist,%applicationname%.ini
  92. {
  93. ini=`;[Settings]
  94. ini=%ini%`n`;addsound=C:\Windows\Media\notify.wav  `;Sound to play when adding a window to a group
  95. ini=%ini%`n`;showsound=C:\Windows\Media\ding.wav   `;Sound to play when showing a window
  96. ini=%ini%`n`;addshift=0                            `;0=No 1=Yes  Use shift in show Hotkey?
  97. ini=%ini%`n`;addctrl=1                             `;                ctrl
  98. ini=%ini%`n`;addalt=0                              `;                alt
  99. ini=%ini%`n`;addwin=0                              `;                win
  100. ini=%ini%`n`;showshift=0                           `;0=No 1=Yes  Use shift in show Hotkey?
  101. ini=%ini%`n`;showctrl=0                            `;                ctrl
  102. ini=%ini%`n`;showalt=1                             `;                alt
  103. ini=%ini%`n`;showwin=0                             `;                win
  104. ini=%ini%`n
  105. ini=%ini%`n[Settings]
  106. ini=%ini%`naddsound=C:\Windows\Media\notify.wav
  107. ini=%ini%`nshowsound=C:\Windows\Media\ding.wav
  108. ini=%ini%`naddshift=0
  109. ini=%ini%`naddctrl=1
  110. ini=%ini%`naddalt=0
  111. ini=%ini%`naddwin=0
  112. ini=%ini%`nshowshift=0
  113. ini=%ini%`nshowctrl=0
  114. ini=%ini%`nshowalt=1
  115. ini=%ini%`nshowwin=0
  116. FileAppend,%ini%,%applicationname%.ini
  117. ini=
  118. }
  119. IniRead,addsound,%applicationname%.ini,Settings,addsound
  120. IniRead,showsound,%applicationname%.ini,Settings,C:\Windows\Media\tada.wav
  121.  
  122. IniRead,addshift,%applicationname%.ini,Settings,addshift
  123. IniRead,addctrl,%applicationname%.ini,Settings,addctrl
  124. IniRead,addalt,%applicationname%.ini,Settings,addalt
  125. IniRead,addwin,%applicationname%.ini,Settings,addwin
  126. IniRead,showshift,%applicationname%.ini,Settings,showshift
  127. IniRead,showctrl,%applicationname%.ini,Settings,showctrl
  128. IniRead,showalt,%applicationname%.ini,Settings,showalt
  129. IniRead,showwin,%applicationname%.ini,Settings,showwin
  130.  
  131. If addshift=1
  132.   addshift=D
  133. Else
  134.   addshift=U
  135. If addctrl=1
  136.   addctrl=D
  137. Else
  138.   addctrl=U
  139. If addalt=1
  140.   addalt=D
  141. Else
  142.   addalt=U
  143. If addwin=1
  144.   addwin=D
  145. Else
  146.   addwin=U
  147.  
  148. If showshift=1
  149.   showshift=D
  150. Else
  151.   showshift=U
  152. If showctrl=1
  153.   showctrl=D
  154. Else
  155.   showctrl=U
  156. If showalt=1
  157.   showalt=D
  158. Else
  159.   showalt=U
  160. If showwin=1
  161.   showwin=D
  162. Else
  163.   showwin=U
  164.  
  165. add=%addshift%%addctrl%%addalt%%addwin%
  166. show=%showshift%%showctrl%%showalt%%showwin%
  167. Return
  168.  
  169.  
  170. ABOUT:
  171. Gui,99:Destroy
  172. Gui,99:Margin,20,20
  173. Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
  174. Gui,99:Font,Bold
  175. Gui,99:Add,Text,x+10 yp+10,%applicationname% v1.0
  176. Gui,99:Font
  177. Gui,99:Add,Text,y+10,- Step through groups of windows using hotkeys
  178. Gui,99:Add,Text,y+0,Ctrl-0: add a window to a Group0
  179. Gui,99:Add,Text,y+0,Ctrl-1: add a window to a Group1
  180. Gui,99:Add,Text,y+0,  ... :   ...
  181. Gui,99:Add,Text,y+0,Alt-0 : show the next window of Group0
  182. Gui,99:Add,Text,y+0,Alt-1 : show the next window of Group1
  183. Gui,99:Add,Text,y+0,  ... :   ...
  184. Gui,99:Add,Text,y+10,- To change hotkeys and sounds, choose Settings in the tray menu
  185.  
  186. Gui,99:Add,Picture,xm y+20 Icon5,%applicationname%.exe
  187. Gui,99:Font,Bold
  188. Gui,99:Add,Text,x+10 yp+10,1 Hour Software by Skrommel
  189. Gui,99:Font
  190. Gui,99:Add,Text,y+10,For more tools, information and donations, please visit
  191. Gui,99:Font,CBlue Underline
  192. Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
  193. Gui,99:Font
  194.  
  195. Gui,99:Add,Picture,xm y+20 Icon7,%applicationname%.exe
  196. Gui,99:Font,Bold
  197. Gui,99:Add,Text,x+10 yp+10,DonationCoder
  198. Gui,99:Font
  199. Gui,99:Add,Text,y+10,Please support the contributors at
  200. Gui,99:Font,CBlue Underline
  201. Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
  202. Gui,99:Font
  203.  
  204. Gui,99:Add,Picture,xm y+20 Icon6,%applicationname%.exe
  205. Gui,99:Font,Bold
  206. Gui,99:Add,Text,x+10 yp+10,AutoHotkey
  207. Gui,99:Font
  208. Gui,99:Add,Text,y+10,This tool was made using the powerful
  209. Gui,99:Font,CBlue Underline
  210. Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
  211. Gui,99:Font
  212.  
  213. Gui,99:Show,,%applicationname% About
  214. hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
  215. OnMessage(0x200,"WM_MOUSEMOVE")
  216. Return
  217.  
  218. 1HOURSOFTWARE:
  219.  Run,http://www.1hoursoftware.com,,UseErrorLevel
  220. Return
  221.  
  222. DONATIONCODER:
  223.  Run,http://www.donationcoder.com,,UseErrorLevel
  224. Return
  225.  
  226. AUTOHOTKEY:
  227.  Run,http://www.autohotkey.com,,UseErrorLevel
  228. Return
  229.  
  230. 99GuiClose:
  231.  Gui,99:Destroy
  232.   OnMessage(0x200,"")
  233.   DllCall("DestroyCursor","Uint",hCur)
  234. Return
  235.  
  236. WM_MOUSEMOVE(wParam,lParam)
  237. {
  238.   Global hCurs
  239.   MouseGetPos,,,,ctrl
  240.   If ctrl in Static14,Static18,Static22
  241.     DllCall("SetCursor","UInt",hCurs)
  242.   Return
  243. }
  244. Return
Advertisement
Add Comment
Please, Sign In to add comment