AutoHotkey Community

It is currently May 26th, 2012, 7:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: April 11th, 2005, 2:51 pm 
Offline

Joined: February 21st, 2005, 9:07 am
Posts: 11
Is it possible to put several scripts into one file? Each script has its own hotkey.
I tried to put Volume On-Screen-Display (OSD) and Window Shading scripts downloaded from Showcase into one file, but only the first script is executable. There is no response for the second one? So, what could be the problem?
Thanks in advance!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2005, 3:00 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
#Include is probabily what you're looking for.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2005, 4:15 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
How did you put them together?

You have to be careful with the autoexec area.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2005, 4:46 pm 
Offline

Joined: February 21st, 2005, 9:07 am
Posts: 11
toralf wrote:
How did you put them together?

You have to be careful with the autoexec area.


I just copied one script after another, e.g. Volume On-Screen-Display (OSD) and Window Shading scripts. These two scripts are in one .AHK file. So I only need run once, and there is only one AutoHotKey tray icon. When I press Win+z, the Window Shading script runs; When I press Win+UP, the master volume is increased. However, at the moment only the first script in the file works no matter which one.
Is it possible to run AutoHotKey in this way? And what should I do to make it work?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 11th, 2005, 6:13 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
You have to make sure that both autoexec are executed. So you could move
Code:
; Set the height of a rolled up window here.  The operating system
; probably won't allow the title bar to be hidden regardless of
; how low this number is:
ws_MinHeight = 25

; This line will unroll any rolled up windows if the script exits
; for any reason:
OnExit, ExitSub
return  ; End of auto-execute section
from window shade to the top of your combined script. But you have to remove the line
Code:
return  ; End of auto-execute section


Try it, if it works let us know. If not, post your script, please.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2005, 8:20 am 
Offline

Joined: February 21st, 2005, 9:07 am
Posts: 11
Thank you very much for your suggestion. As you suggested, I moved the WS's atuo-execute section to the top. But now only the window shade can be executed. Here I post the code. These codes are just copied from the showcase, and they work perfectly separately.

Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Window Shading (roll up a window to its title bar) -- by Rajat
; http://www.autohotkey.com
; This script reduces a window to its title bar and then back to its
; original size by pressing a single hotkey.  Any number of windows
; can be reduced in this fashion (the script remembers each).  If the
; script exits for any reason, all "rolled up" windows will be
; automatically restored to their original heights.

; Set the height of a rolled up window here.  The operating system
; probably won't allow the title bar to be hidden regardless of
; how low this number is:
ws_MinHeight = 25

; This line will unroll any rolled up windows if the script exits
; for any reason:
OnExit, WS_ExitSub
; Return ; End of WS_Auto-Execute Section


;___________________________________________
;_____VOSD Auto Execute Section__________________

; DON'T CHANGE ANYTHING HERE (unless you know what you're doing).

vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBM% CW%vol_CW%
vol_BarOptionsWave   = 2:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBW% CW%vol_CW%

; If the X position has been specified, add it to the options.
; Otherwise, omit it to center the bar horizontally:
if vol_PosX >= 0
{
   vol_BarOptionsMaster = %vol_BarOptionsMaster% X%vol_PosX%
   vol_BarOptionsWave   = %vol_BarOptionsWave% X%vol_PosX%
}

; If the Y position has been specified, add it to the options.
; Otherwise, omit it to have it calculated later:
if vol_PosY >= 0
{
   vol_BarOptionsMaster = %vol_BarOptionsMaster% Y%vol_PosY%
   vol_PosY_wave = %vol_PosY%
   vol_PosY_wave += %vol_Thick%
   vol_BarOptionsWave = %vol_BarOptionsWave% Y%vol_PosY_wave%
}

#SingleInstance
SetBatchLines, 10ms
Return


;___________________________________________

; End of VOSD_auto-execute section


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Volume On-Screen-Display (OSD) -- by Rajat
; http://www.autohotkey.com
; This script assigns hotkeys of your choice to raise and lower the
; master and/or wave volume.  Both volumes are displayed as different
; color bar graphs.

;_________________________________________________
;_______User Settings_____________________________

; Make customisation only in this area or hotkey area only!!

; The percentage by which to raise or lower the volume each time:
vol_Step = 4

; How long to display the volume level bar graphs:
vol_DisplayTime = 2000

; Master Volume Bar color (see the help file to use more
; precise shades):
vol_CBM = Red

; Wave Volume Bar color
vol_CBW = Blue

; Background color
vol_CW = Silver

; Bar's screen position.  Use -1 to center the bar in that dimension:
vol_PosX = -1
vol_PosY = -1
vol_Width = 150  ; width of bar
vol_Thick = 12   ; thickness of bar

; If your keyboard has multimedia buttons for Volume, you can
; try changing the below hotkeys to use them by specifying
; Volume_Up, ^Volume_Up, Volume_Down, and ^Volume_Down:
HotKey, #Up, vol_MasterUp      ; Win+UpArrow
HotKey, #Down, vol_MasterDown
HotKey, +#Up, vol_WaveUp       ; Shift+Win+UpArrow
HotKey, +#Down, vol_WaveDown

vol_WaveUp:
SoundSet, +%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_WaveDown:
SoundSet, -%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_MasterUp:
SoundSet, +%vol_Step%
Gosub, vol_ShowBars
return

vol_MasterDown:
SoundSet, -%vol_Step%
Gosub, vol_ShowBars
return

vol_ShowBars:
; To prevent the "flashing" effect, only create the bar window if it
; doesn't already exist:
IfWinNotExist, vol_Wave
   Progress, %vol_BarOptionsWave%, , , vol_Wave
IfWinNotExist, vol_Master
{
   ; Calculate position here in case screen resolution changes while
   ; the script is running:
   if vol_PosY < 0
   {
      ; Create the Wave bar just above the Master bar:
      WinGetPos, , vol_Wave_Posy, , , vol_Wave
      vol_Wave_Posy -= %vol_Thick%
      Progress, %vol_BarOptionsMaster% Y%vol_Wave_Posy%, , , vol_Master
   }
   else
      Progress, %vol_BarOptionsMaster%, , , vol_Master
}
; Get both volumes in case the user or an external program changed them:
SoundGet, vol_Master, Master
SoundGet, vol_Wave, Wave
Progress, 1:%vol_Master%
Progress, 2:%vol_Wave%
SetTimer, vol_BarOff, %vol_DisplayTime%
return

vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
Progress, 2:Off
return

;;;;;;;;;;;;;;;;;;;;;;;Windows Shadow;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#u::  ; Change this line to pick a different hotkey.
; Below this point, no changes should be made unless you want to
; alter the script's basic functionality.
; Uncomment this next line if this subroutine is to be converted
; into a custom menu item rather than a hotkey.  The delay allows
; the active window that was deactivated by the displayed menu to
; become active again:
;Sleep, 200
WinGet, ws_ID, ID, A
Loop, Parse, ws_IDList, |
{
   IfEqual, A_LoopField, %ws_ID%
   {
      ; Match found, so this window should be restored (unrolled):
      StringTrimRight, ws_Height, ws_Window%ws_ID%, 0
      WinMove, ahk_id %ws_ID%,,,,, %ws_Height%
      StringReplace, ws_IDList, ws_IDList, |%ws_ID%
      return
   }
}
WinGetPos,,,, ws_Height, A
ws_Window%ws_ID% = %ws_Height%
WinMove, ahk_id %ws_ID%,,,,, %ws_MinHeight%
ws_IDList = %ws_IDList%|%ws_ID%
return

WS_ExitSub:
Loop, Parse, ws_IDList, |
{
   if A_LoopField =  ; First field in list is normally blank.
      continue      ; So skip it.
   StringTrimRight, ws_Height, ws_Window%A_LoopField%, 0
   WinMove, ahk_id %A_LoopField%,,,,, %ws_Height%
}
ExitApp  ; Must do this for the OnExit subroutine to actually Exit the script.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#t::WinSet, AlwaysOnTop, Toggle, A


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2005, 8:49 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Your post is not a correct copy of the OSD script. The order has changed.

The OSD script is consiting of a long auto exec area also the comments say something different. I have combined the two scripts, but didn't test. Try it and add the comments I deleted.


Code:
vol_Step = 4
vol_DisplayTime = 2000
vol_CBM = Red
vol_CBW = Blue
vol_CW = Silver
vol_PosX = -1
vol_PosY = -1
vol_Width = 150  ; width of bar
vol_Thick = 12   ; thickness of bar
HotKey, #Up, vol_MasterUp      ; Win+UpArrow
HotKey, #Down, vol_MasterDown
HotKey, +#Up, vol_WaveUp       ; Shift+Win+UpArrow
HotKey, +#Down, vol_WaveDown
vol_BarOptionsMaster = 1:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBM% CW%vol_CW%
vol_BarOptionsWave   = 2:B ZH%vol_Thick% ZX0 ZY0 W%vol_Width% CB%vol_CBW% CW%vol_CW%
if vol_PosX >= 0
{
   vol_BarOptionsMaster = %vol_BarOptionsMaster% X%vol_PosX%
   vol_BarOptionsWave   = %vol_BarOptionsWave% X%vol_PosX%
}
if vol_PosY >= 0
{
   vol_BarOptionsMaster = %vol_BarOptionsMaster% Y%vol_PosY%
   vol_PosY_wave = %vol_PosY%
   vol_PosY_wave += %vol_Thick%
   vol_BarOptionsWave = %vol_BarOptionsWave% Y%vol_PosY_wave%
}
#SingleInstance
SetBatchLines, 10ms
ws_MinHeight = 25
OnExit, ExitSub
return  ; End of auto-execute section
;___________________________________________

vol_WaveUp:
SoundSet, +%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_WaveDown:
SoundSet, -%vol_Step%, Wave
Gosub, vol_ShowBars
return

vol_MasterUp:
SoundSet, +%vol_Step%
Gosub, vol_ShowBars
return

vol_MasterDown:
SoundSet, -%vol_Step%
Gosub, vol_ShowBars
return

vol_ShowBars:
; To prevent the "flashing" effect, only create the bar window if it
; doesn't already exist:
IfWinNotExist, vol_Wave
   Progress, %vol_BarOptionsWave%, , , vol_Wave
IfWinNotExist, vol_Master
{
   ; Calculate position here in case screen resolution changes while
   ; the script is running:
   if vol_PosY < 0
   {
      ; Create the Wave bar just above the Master bar:
      WinGetPos, , vol_Wave_Posy, , , vol_Wave
      vol_Wave_Posy -= %vol_Thick%
      Progress, %vol_BarOptionsMaster% Y%vol_Wave_Posy%, , , vol_Master
   }
   else
      Progress, %vol_BarOptionsMaster%, , , vol_Master
}
; Get both volumes in case the user or an external program changed them:
SoundGet, vol_Master, Master
SoundGet, vol_Wave, Wave
Progress, 1:%vol_Master%
Progress, 2:%vol_Wave%
SetTimer, vol_BarOff, %vol_DisplayTime%
return

vol_BarOff:
SetTimer, vol_BarOff, off
Progress, 1:Off
Progress, 2:Off
return

#z::
WinGet, ws_ID, ID, A
Loop, Parse, ws_IDList, |
{
   IfEqual, A_LoopField, %ws_ID%
   {
      ; Match found, so this window should be restored (unrolled):
      StringTrimRight, ws_Height, ws_Window%ws_ID%, 0
      WinMove, ahk_id %ws_ID%,,,,, %ws_Height%
      StringReplace, ws_IDList, ws_IDList, |%ws_ID%
      return
   }
}
WinGetPos,,,, ws_Height, A
ws_Window%ws_ID% = %ws_Height%
WinMove, ahk_id %ws_ID%,,,,, %ws_MinHeight%
ws_IDList = %ws_IDList%|%ws_ID%
return

ExitSub:
Loop, Parse, ws_IDList, |
{
   if A_LoopField =  ; First field in list is normally blank.
      continue      ; So skip it.
   StringTrimRight, ws_Height, ws_Window%A_LoopField%, 0
   WinMove, ahk_id %A_LoopField%,,,,, %ws_Height%
}
ExitApp

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 12th, 2005, 10:33 am 
Offline

Joined: February 21st, 2005, 9:07 am
Posts: 11
toralf wrote:
Your post is not a correct copy of the OSD script. The order has changed.

The OSD script is consiting of a long auto exec area also the comments say something different. I have combined the two scripts, but didn't test. Try it and add the comments I deleted.




Excellent!
Thanks toralf for your code. It runs smoothly now.
I misunderstood the auto-execute section of OSD script, and that's why the order was changed.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2008, 9:23 am 
Offline

Joined: March 18th, 2008, 9:21 am
Posts: 8
How do you apply the #Include command to AHK files that draw data from an INI file to run? :(


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, Google [Bot], Leef_me, tomL and 67 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