 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
suntrop
Joined: 21 Feb 2005 Posts: 3
|
Posted: Mon Feb 21, 2005 1:35 pm Post subject: Gathering my favorite scripts in one file. |
|
|
Hi,
I tried to put my favorite ahk scripts in one file and compile it.
If I execute them one by one they work perfect but some scripts
doesn't work after I've put them into my favorite ahk script file.
For example the EasyWindowDrag script run very poorly and
the Eject CD script gives me an error message.
Maybe there is another way to start all my favorite scripts with Windows
without having all the icons in my systray.
Many thanks. |
|
| Back to top |
|
 |
Newb Guest
|
Posted: Mon Feb 21, 2005 1:54 pm Post subject: no icons in tray huh? |
|
|
| i think you'll need to use at the begging of script, but i dont think that has anything todo with your error messages |
|
| Back to top |
|
 |
ILL.1
Joined: 29 Sep 2004 Posts: 84
|
Posted: Mon Feb 21, 2005 2:25 pm Post subject: |
|
|
You should be able to have all your scripts in one exe with no problems. It might help if you posted your combined script so that others can take a look. As far as errors, there is probably an error. So, double check all paths, variable names, parameters, etc. Look through the help file for SetBatchLines to speed things up. Without having any more info, that is all I can do to help. _________________ ===============
----------ILL.1-----------
=============== |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 283 Location: Hungary, Budapest
|
Posted: Mon Feb 21, 2005 2:53 pm Post subject: |
|
|
One idea: why not keep the scripts still in separate files, and #include them into a master file? Works for me. And it is easier to maintain them this way. _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Mon Feb 21, 2005 3:06 pm Post subject: |
|
|
ppl are very helpful here!
actually just #including or copying all of them into one big script won't do the trick. the way to attain its is carefully 'merging' them... the most important part is getting the 'auto-execute' section right... get this section of all scripts at one place before the first return or exit and then the rest of the stuff. one more thing, the vars and section names shouldn't conflict!
 _________________
 |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Mon Feb 21, 2005 6:29 pm Post subject: |
|
|
Rajat's correct, but it'd be much easier for you to post your scripts so we can show you by example. Unless you think you can handle all that by yourself, on the first try.  |
|
| Back to top |
|
 |
suntrop
Joined: 21 Feb 2005 Posts: 3
|
Posted: Mon Feb 21, 2005 6:38 pm Post subject: |
|
|
Thanks for the quick reply.
@Newb
#notrayicon is what I've been looking for. thanks
I've tried to include the other files but it doesn't work.
The EasyWindowDrag script work very poorly and the
VolumeOSD doesn't work. But only if I put them into a
single file.
Here is my favorite.ahk Download |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Mon Feb 21, 2005 7:16 pm Post subject: |
|
|
Alright, I've doctored it a little. Basically all I did was check for conflicting Gui's and Progress's (I found none) and conflicting variables (ditto). Then I moved the auto-execute section of each script to the top and merged them. By the way, in the process of doing this, I removed the comments because it was getting very hard to work with them. Anyway, here's my first try, but I haven't tested it yet:
| Code: | #SingleInstance
vol_Step = 4
vol_DisplayTime = 2000
vol_CBM = Red
vol_CBW = Blue
vol_CW = Silver
vol_PosX = -1
vol_PosY = -1
vol_Width = 150
vol_Thick = 12
HotKey, #Up, vol_MasterUp
HotKey, #Down, vol_MasterDown
HotKey, +#Up, vol_WaveUp
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%
}
SetWinDelay,2
FadeSpeed_ejct = 3
CoordMode,Mouse
return
^q::
WinClose, A
return
~^N::
WinGetClass, ActiveClass, A
If ActiveClass in ExploreWClass,CabinetWClass
{
ControlGetText, MyCurrentExplorerDirectory, Edit1, ahk_class %ActiveClass%
FileCreateDir, %MyCurrentExplorerDirectory%\Neuer Ordner
if ErrorLevel = 0
{
Loop,20
{
IfExist, %MyCurrentExplorerDirectory%\Neuer Ordner
{
Send,{F5}
Send,Neuer Ordner{F2}
break
}
Sleep,100
}
}
}
IfWinActive, ahk_class #32770
{
PostMessage, 0x111, 40962
}
return
!LButton::
If DoubleAlt
{
MouseGetPos,,,KDE_id
PostMessage,0x112,0xf020,,,ahk_id %KDE_id%
DoubleAlt := false
return
}
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
return
WinGetPos,KDE_WinX1,KDE_WinY1,,,ahk_id %KDE_id%
Loop
{
GetKeyState,KDE_Button,LButton,P
If KDE_Button = U
break
MouseGetPos,KDE_X2,KDE_Y2
KDE_X2 -= KDE_X1
KDE_Y2 -= KDE_Y1
KDE_WinX2 := (KDE_WinX1 + KDE_X2)
KDE_WinY2 := (KDE_WinY1 + KDE_Y2)
WinMove,ahk_id %KDE_id%,,%KDE_WinX2%,%KDE_WinY2%
}
return
!RButton::
If DoubleAlt
{
MouseGetPos,,,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
WinRestore,ahk_id %KDE_id%
Else
WinMaximize,ahk_id %KDE_id%
DoubleAlt := false
return
}
MouseGetPos,KDE_X1,KDE_Y1,KDE_id
WinGet,KDE_Win,MinMax,ahk_id %KDE_id%
If KDE_Win
return
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
If (KDE_X1 < KDE_WinX1 + KDE_WinW / 2)
KDE_WinLeft := true
Else
KDE_WinLeft := false
If (KDE_Y1 < KDE_WinY1 + KDE_WinH / 2)
KDE_WinUp := true
Else
KDE_WinUp := false
Loop
{
GetKeyState,KDE_Button,RButton,P
If KDE_Button = U
break
MouseGetPos,KDE_X2,KDE_Y2
WinGetPos,KDE_WinX1,KDE_WinY1,KDE_WinW,KDE_WinH,ahk_id %KDE_id%
KDE_X2 -= KDE_X1
KDE_Y2 -= KDE_Y1
If KDE_WinLeft
{
KDE_WinX1 += KDE_X2
KDE_WinW -= KDE_X2
}
Else
KDE_WinW += KDE_X2
If KDE_WinUp
{
KDE_WinY1 += KDE_Y2
KDE_WinH -= KDE_Y2
}
Else
KDE_WinH += KDE_Y2
WinMove,ahk_id %KDE_id%,,%KDE_WinX1%,%KDE_WinY1%,%KDE_WinW%,%KDE_WinH%
KDE_X1 := (KDE_X2 + KDE_X1)
KDE_Y1 := (KDE_Y2 + KDE_Y1)
}
return
!MButton::
If DoubleAlt
{
MouseGetPos,,,KDE_id
WinClose,ahk_id %KDE_id%
DoubleAlt := false
return
}
return
~Alt::
DoubleAlt := false
KeyWait,Alt,D T0.6
If Errorlevel
return
DoubleAlt := true
return
ScrollLock::
Drive_ejct = H:
gosub, Eject
Return
+ScrollLock::
Drive_ejct = I:
gosub, Eject
Return
Eject:
transparent_ejct = 150
distY_ejct = %A_ScreenHeight%
posY_ejct = %A_ScreenHeight%
distY_ejct /= 4
posY_ejct -= %distY_ejct%
ifExist, %A_ScriptDir%\Eject.bmp
{
Gui, Add, pic, x0 y0, %A_ScriptDir%\Eject.bmp
DetectHiddenWindows on
WinWait, %A_ScriptName%
WinSet, TransColor ,0000FF %transparent_ejct%
WinSet, AlwaysOnTop, On
Gui, -Caption
Gui, Show, w150 h150 y%posY_ejct%
}
Drive, Eject, %Drive_ejct%
if A_TimeSinceThisHotkey < 1000
{
Drive, Eject, %Drive_ejct%, 1
}
ifExist, %A_ScriptDir%\Eject.bmp
{
Count_ejct = %transparent_ejct%
Count_ejct /= %FadeSpeed_ejct%
Loop, %Count_ejct%
{
transparent_ejct -= %FadeSpeed_ejct%
WinSet, TransColor,0000FF %transparent_ejct%
}
Gui, Destroy
}
return
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:
IfWinNotExist, vol_Wave
Progress, %vol_BarOptionsWave%, , , vol_Wave
IfWinNotExist, vol_Master
{
if vol_PosY < 0
{
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
}
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 |
Sorry if it looks really messed up.  |
|
| Back to top |
|
 |
suntrop
Joined: 21 Feb 2005 Posts: 3
|
Posted: Mon Feb 21, 2005 8:47 pm Post subject: |
|
|
Thanks a million. The script works
I really don't know what you did but it works.
Maybe I can try it myself if I knwo more
about ahk thitherto thanks for your work. |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Mon Feb 21, 2005 8:59 pm Post subject: |
|
|
| All I really changed was the auto-execute section, which you can learn more about here. It's kind of hard to explain, but when you're putting together multiple scripts, they all have to share that section at the top. |
|
| Back to top |
|
 |
SanskritFritz
Joined: 17 Feb 2005 Posts: 283 Location: Hungary, Budapest
|
Posted: Wed Feb 23, 2005 9:29 am Post subject: |
|
|
In a nutshell: all statements not belonging to a label (hotkey, hotstring) must be at the beginning of the script, otherwise they will not be executed. This is the so called "auto-execute section". _________________ Is there another word for synonym? |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|