Skip to content

Commit

Permalink
Reduced global vars with ByRef
Browse files Browse the repository at this point in the history
  • Loading branch information
skupjoe committed May 27, 2019
1 parent 6084ef8 commit 6973067
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
- Improve scrolling hotkey logic to be more efficient, or limit scrolling updates.

### Fix
- Make DisableSpeed fix error loop when name cannot obtained during speed loop.
- Move Album:
- Move album two levels deep does not remove empty parent folder.

## [2.2.1] - 2019-05-27
### Changed
- Reduced global vars with ByRef.
- Moved time parsing vars from GetSongInfo() to endSec().

## [2.2.0] - 2019-05-25
### Changed
- Move Album:
Expand Down Expand Up @@ -80,7 +86,8 @@
### Added
- First version commit.

[Unreleased]: https://github.com/skupjoe/foo-playback-helper/compare/v2.2.0...HEAD
[Unreleased]: https://github.com/skupjoe/foo-playback-helper/compare/v2.2.1...HEAD
[2.2.1]: https://github.com/skupjoe/foo-playback-helper/compare/v2.2.0...v2.2.1
[2.2.0]: https://github.com/skupjoe/foo-playback-helper/compare/v2.1.0...v2.2.0
[2.1.0]: https://github.com/skupjoe/foo-playback-helper/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/skupjoe/foo-playback-helper/compare/v2.0.0...v2.0.1
Expand Down
47 changes: 19 additions & 28 deletions foo-helper.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ Global old_dir := "Z:\scrap"
Global temp_dir_0 := "Z:\temp0"
Global temp_dir_1 := "Z:\temp1\_" ; pattern for your genre folders (eg. "Z:\temp1\_rock")
Global B_Toggle := 1
Global Toggle0
Global Toggle1
Global Toggle2
Global name
Global path
Global title
Global genres
Global time_scrl
Global time_curr_sec
Global time_end_sec


~^Del::
Expand Down Expand Up @@ -47,17 +37,17 @@ return

; Move album
~^!m::
GetSongInfo()
GetSongInfo(name,, p_dir)
if (name == "foobar2000") {
Send {CtrlDown} {Home} {CtrlUp}
Sleep, 3500
GetSongInfo()
GetSongInfo(name)
if (name == "foobar2000") {
msgbox, , , % "Foorbar2000 must be playing for move album to work!", 2
Exit
}
}
LoopGenres()
LoopGenres(genres)
Gosub, DisableSpeed
Sleep, 1000
Send {CtrlDown} {End} {CtrlUp}
Expand Down Expand Up @@ -148,7 +138,7 @@ return

GoSeq:
dest := GetGenreFolder(Chosen)
RunWait, %A_AhkPath% "%A_ScriptDir%\script\move_files.ahk" "%p_dir_nosp%" "%dest%" "%old_dir%" "%temp_dir_0%"
RunWait, %A_AhkPath% "%A_ScriptDir%\script\move_files.ahk" "%p_dir%" "%dest%" "%old_dir%" "%temp_dir_0%"
Sleep, 5000
Send {CtrlDown} {ShiftDown} {Space} {ShiftUp} {CtrlUp}
Sleep, 2500
Expand Down Expand Up @@ -204,7 +194,7 @@ return

; ############ Functions ############

WinGetAll(InType = "", In = "", OutType = "") {
WinGetAll(InType="", In="", OutType="") {
WinGet, wParam, List
Window := {}
loop %wParam% {
Expand All @@ -225,27 +215,28 @@ WinGetAll(InType = "", In = "", OutType = "") {
return % Window
}

GetSongInfo() {
GetSongInfo(ByRef name, ByRef time="", ByRef p_dir_nosp="") {
name := WinGetAll("Proc", "foobar2000.exe", "Name")
name_a := StrSplit(name, "` -:- ")
title_a := StrSplit(name_a[1], A_Space)
time := SubStr(title_a[title_a.MaxIndex()], 2, StrLen(title_a[title_a.MaxIndex()])-2)
time_a := StrSplit(time, "`/")
time_curr_a := StrSplit(time_a[1], "`:")
time_end_a := StrSplit(time_a[2], "`:")
time_curr_sec := (60*time_curr_a[1]+time_curr_a[2])
time_end_sec := (60*time_end_a[1]+time_end_a[2])
path := name_a[2]
p_dir := GetParentDir(path)
global p_dir_nosp := StrReplace(p_dir, A_Space, "\\\")
p_dir_nosp := StrReplace(p_dir, A_Space, "\\\")
return
}

endSec() {
ctr := 0
GetSongInfo()
GetSongInfo(name, time)
time_a := StrSplit(time, "`/")
time_curr_a := StrSplit(time_a[1], "`:")
time_end_a := StrSplit(time_a[2], "`:")
time_curr_sec := (60*time_curr_a[1]+time_curr_a[2])
time_end_sec := (60*time_end_a[1]+time_end_a[2])
while (time_end_sec == "" OR time_curr_sec == "") {
ctr++
GetSongInfo()
GetSongInfo(name, time)
msgbox, , , % "Cannot get time!", 1
Sleep, 5500
if (ctr == 5) {
Expand All @@ -257,13 +248,13 @@ endSec() {
return (time_end_sec - time_curr_sec)
}

LoopGenres() {
LoopGenres(ByRef genres) {
genres := {}
Loop, Files, % temp_dir_1 . "*", D
if A_LoopFileAttrib contains D
if SubStr(A_LoopFileName, 1, 1) = "_"
genres .= SubStr(A_LoopFileName, 2) . "|"
return genres
return
}

GetGenreFolder(genre) {
Expand Down Expand Up @@ -297,10 +288,10 @@ CheckBlacklist() {

isPlaying() {
ctr := 0
GetSongInfo()
GetSongInfo(name)
while (name == "foobar2000") {
ctr++
GetSongInfo()
GetSongInfo(name)
Sleep, 5500
if (ctr not in 1,2)
msgbox, , , % "Foobar2000 is not playing!", 1
Expand Down

0 comments on commit 6973067

Please sign in to comment.