heyhey,
I'm very new to autohotkey and thought I would like to share one of my scripts:
Code:
#Singleinstance Force
Gui, -0x400000
Gui, +AlwaysOnTop
Gui, -ToolWindow
DetectHiddenWindows, On
k_IsVisible = y
k_MenuItemHide = Hide remote
k_MenuItemShow = Show remote
Menu, Tray, Add, %k_MenuItemHide%, k_ShowHide
Menu, Tray, Add, Exit, k_MenuExit
Menu, Tray, Default, %k_MenuItemHide%
Menu, Tray, NoStandard
WriteMemory(WVALUE,MADDRESS,PROGRAM)
{
winget, pid, PID, %PROGRAM%
ProcessHandle := DllCall("OpenProcess", "int", 2035711, "char", 0, "UInt", PID, "UInt")
DllCall("WriteProcessMemory", "UInt", ProcessHandle, "UInt", MADDRESS, "Uint*", WVALUE, "Uint", 4, "Uint *", 0)
DllCall("CloseHandle", "int", ProcessHandle)
return
}
ReadMemory(MADDRESS,PROGRAM)
{
winget, pid, PID, %PROGRAM%
VarSetCapacity(MVALUE,4,0)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory","UInt",ProcessHandle,"UInt",MADDRESS,"Str",MVALUE,"UInt",4,"UInt *",0)
Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
return, result
}
;Backgroundtrans vCaption guiMove
Gui, Font, S8 CRed, Verdana
Gui, Add, Text, w50 y5 h20 vEz , Player:
Gui, Font, S8 CBlack, Verdana
Gui, Add, Text, y5 w220 h15 vEzz , Song Name
Gui, Add, Slider, gSlideVolume vVolume Range0-10 Altsubmit ToolTip, 5
GuiControl, Hide, Volume
Gui, add, Button, y5 h10 w10 gVolume vVolumes , +
Gui, Font, S8 CBlack Bold, Verdana
Gui, Add, Text, y5 w15 vminute, 00
Gui, Add, Text, y5 , :
Gui, Add, Text, y5 w15 vseconds, 00
Gui, Font, S8 CBlack, Verdana
Gui, Add, Button, y5 h15 w15 gShow vShow, ^
Gui, Add, Text, y45 x5 w300 h15 v1, Up Arrow - Volume up
Gui, Add, Text, y60 x5 w300 h15 v2, Down Arrow - Volume down
Gui, Add, Text, y75 x5 w300 h15 v3, Left Arrow - Previous track
Gui, Add, Text, y90 x5 w300 h15 v4, Right Arrow - Next Track
Gui, Add, Text, y105 x5 w300 h15 v5, Ctrl + Space - Pause
Gui, Font, S8 CGreen, Verdana
Gui, Add, Checkbox, x240 y45 vtraytip, Show traytips
Gui, Add, Text, y77 x240 v7, Opacity:
Gui, Add, Slider, x240 y90 w120 h40 ToolTip Range25-100 Altsubmit vOpacity gSetopacity, 100
Gui, Font, S8 CBlue, Verdana
Gui, Add, Text, y30 x5 w300 h15 v6, Hotkeys:
GuiControl,, traytip, 1
GuiControl, Hide, 1
GuiControl, Hide, 2
GuiControl, Hide, 3
GuiControl, Hide, 4
GuiControl, Hide, 5
GuiControl, Hide, 6
GuiControl, Hide, 7
GuiControl, Hide, traytip
GuiControl, Hide, Opacity
GuiControl, Hide, Exit
y=%A_ScreenHeight%
x=%A_ScreenWidth%
y-=60
x-=410
Gui, Add, Button, +Border +Right CRed x385 y105 h17 w17 vExit, x
Gui, Show, x%x% y%y% h25 w407 , Easy Media
WinGet, k_ID, ID, A ; Get its window ID.
WinGetPos,,, k_WindowWidth, k_WindowHeight, A
SysGet, k_WorkArea, MonitorWorkArea, %k_Monitor%
k_WindowX = %k_WorkAreaRight%
k_WindowX -= %k_WorkAreaLeft%
k_WindowX -= %k_WindowWidth%
k_WindowY = %k_WorkAreaBottom%
k_WindowY -= %k_WindowHeight%
WinMove, A,, %k_WindowX%, %k_WindowY%
WinSet, AlwaysOnTop, On, ahk_id %k_ID%
k_IsVisible = y
y-=10
x-=10
Gui, Add, GroupBox, x-30 y-30 w500 h58 ,
Settimer, Ez, 500
Return
GuiClose:
ExitApp
Up::
ControlSend, ahk_parent, {up}, ahk_class Winamp v1.x
ControlSend, ahk_parent, ^{Up}, ahk_class SpotifyMainWindow ; Pause/Unpause
return
Down::
ControlSend, ahk_parent, {down}, ahk_class Winamp v1.x
ControlSend, ahk_parent, ^{Down}, ahk_class SpotifyMainWindow ; Pause/Unpause
return
Left::
ControlSend, ahk_parent, z, ahk_class Winamp v1.x
ControlSend, ahk_parent, ^{Left}, ahk_class SpotifyMainWindow ; Pause/Unpause
return
Right::
ControlSend, ahk_parent, b, ahk_class Winamp v1.x
ControlSend, ahk_parent, ^{Right}, ahk_class SpotifyMainWindow ; Pause/Unpause
return
^space::
ControlSend, ahk_parent, c, ahk_class Winamp v1.x
ControlSend, ahk_parent, {space}, ahk_class SpotifyMainWindow ; Pause/Unpause
return
Ez:
WinGetTitle, Title2, ahk_class SpotifyMainWindow
WinGetTitle, Title, ahk_class Winamp v1.x
IfWinExist, ahk_class SpotifyMainWindow
{
String = %Title2%
StringTrimLeft, Title2, String, 10
Guicontrol, text, Ez, Spotify:
Guicontrol, text, Ezz, %Title2%
If Title2=
{
Guicontrol, text, Ezz, Paused
}
varA = %Title2%
var2+=1
If var2=1
{
WinGetTitle, Title3, ahk_class SpotifyMainWindow
varB = %Title3%
}
Else
var2=0
If k_banned=1
Goto, o_banned
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;REKLAME FAEN;;;;;;;;;;;;;
IniRead, key, %A_ScriptDir%\BannedSongs.ini, Key Number, key
Loop, %key% {
WinGetTitle, Title5, ahk_class SpotifyMainWindow
IniRead, Titleban, %A_ScriptDir%\BannedSongs.ini, Blocked Spotify Songs, %A_Index%
If Title5=%Titleban%
{
WinGetTitle, k_bannedtitle, ahk_class SpotifyMainWindow
k_banned=1
Controlsend, ahk_parent, ^+{Down}, ahk_class SpotifyMainWindow
Controlsend, ahk_parent, {Space}, ahk_class SpotifyMainWindow
Loop {
WinGetTitle, realtitle2, ahk_class SpotifyMainWindow
If realtitle2=Paused
Controlsend, ahk_parent, {Space}, ahk_class SpotifyMainWindow
Else
{
If realtitle2=%Title5%
Continue
Else
Break
}
Break
}
}
Else
Continue
}
o_banned:
If k_banned=1
{
WinGetTitle, realtitle2, ahk_class SpotifyMainWindow
If realtitle2=Paused
{
Controlsend, ahk_parent, ^+{down}, ahk_class SpotifyMainWindow
Controlsend, ahk_parent, ^+{down}, ahk_class SpotifyMainWindow
Controlsend, ahk_parent, {Space}, ahk_class SpotifyMainWindow
}
WinGetTitle, realtitle, ahk_class SpotifyMainWindow
If realtitle=%k_bannedtitle%
Sleep, 1
Else
Loop, 1 {
Controlsend, ahk_parent, ^+{Down}, ahk_class SpotifyMainWindow
k_banned=0
}
}
;;;;;;;;;;;;;;;;;;;;;;REKLMAE ENDS::::
Reklamedone:
sleep, 1
}
Else
{
IfWinExist, ahk_class Winamp v1.x
{
String = %Title%
StringTrimRight, Title, String, 8
Guicontrol, text, Ez, WinAmp:
Guicontrol, text, Ezz, %Title%
WinGetTitle, Title, ahk_class Winamp v1.x
vartitle=%title%
WinSetTitle, %title%, , winamp
Value:=ReadMemory(0x491D0C,"winamp")
value2:=ReadMemory(0x491D14,"winamp")
WinSetTitle, winamp, , %title%
if value<10
value3=0%value%
else
value3=%value%
if value<10
value4=0%value2%
else
value4=%value2%
Guicontrol, text, minute, %value4%
Guicontrol, text, seconds, %value3%
If traytip=1
{
if Value4=00
{
if value3=00
{
#Persistent
TrayTip, New song playing!, %Title%, 3
SetTimer, RemoveTrayTip, 5000
return
}
}
}
Return
}
Else
Guicontrol, text, Ezz, No player found...
}
Return
Volume:
k_volume += 1
If k_volume=1
{
guicontrol, Hide, Ezz
GuiControl, Show, Volume
GuiControl, Move, Volume, y5 h20 w200
GuiControl,, Ez, Volume:
GuiControl,, volumes, -
}
Else
{
guicontrol, show, Ezz
Guicontrol, Hide, Volume
GuiControl,, Ez, Spotify:
GuiControl,, volumes, +
k_volume = 0
}
Return
SlideVolume:
Gui, Submit, NoHide
Loop, 10 {
ControlSend, ahk_parent, ^{down}, ahk_class SpotifyMainWindow
}
Loop %Volume% {
ControlSend, ahk_parent, ^{Up}, ahk_class SpotifyMainWindow
}
Sleep, 200
Return
Show:
Var+=1
Gui,submit,nohide
If Var=1
{
y=%A_ScreenHeight%
x=%A_ScreenWidth%
y-=160
x-=410
Gui, Show, h125 w407 , Easy Media
k_WindowX = %k_WorkAreaRight%
k_WindowX -= %k_WorkAreaLeft%
k_WindowX -= %k_WindowWidth%
k_WindowY = %k_WorkAreaBottom%
k_WindowY -= %k_WindowHeight%
k_WindowY -=100
WinMove, A,, %x%, %k_WindowY%
WinSet, AlwaysOnTop, On, ahk_id %k_ID%
Guicontrol, text, Show, v
Opacity+=30
GuiControl, Show, 1
GuiControl, Show, 2
GuiControl, Show, 3
GuiControl, Show, 4
GuiControl, Show, 5
GuiControl, Show, 6
GuiControl, Show, 7
GuiControl, Show, traytip
GuiControl, Show, Opacity
GuiControl, Show, Exit
If Opacity<80
{
Gui, Submit, NoHide
Opacity *= 5
WinSet, Transparent, %Opacity%, Easy Media
}
}
Else
{
y=%A_ScreenHeight%
x=%A_ScreenWidth%
y-=60
x-=410
Gui, Show, h25 w407 , Easy Media
k_WindowX = %k_WorkAreaRight%
k_WindowX -= %k_WorkAreaLeft%
k_WindowX -= %k_WindowWidth%
k_WindowY = %k_WorkAreaBottom%
k_WindowY -= %k_WindowHeight%
WinMove, A,, %x%, %k_WindowY%
WinSet, AlwaysOnTop, On, ahk_id %k_ID%
Guicontrol, text, Show, ^
GuiControl, Hide, 1
GuiControl, Hide, 2
GuiControl, Hide, 3
GuiControl, Hide, 4
GuiControl, Hide, 5
GuiControl, Hide, 6
GuiControl, Hide, 7
GuiControl, Hide, traytip
GuiControl, Hide, Opacity
GuiControl, Hide, Exit
Var=0
Gui, Submit, NoHide
Opacity *= 2.56
WinSet, Transparent, %Opacity%, Easy Media
}
Return
RemoveTrayTip:
SetTimer, RemoveTrayTip, Off
TrayTip
return
WM_ACTIVATE(wParam, lParam) {
IfGreaterOrEqual,wParam,1, Gui,Font,cFFFF80
IfLessOrEqual ,wParam,0, Gui,Font,c808080
GuiControl, Font, Caption
}
uiMove:
PostMessage, 0xA1, 2,,, A
return
Setopacity:
Gui, Submit, NoHide
Opacity *= 2.56
WinSet, Transparent, %Opacity%, Easy Media
Return
k_ShowHide:
if k_IsVisible = y
{
Gui, Cancel
Menu, Tray, Rename, %k_MenuItemHide%, %k_MenuItemShow%
k_IsVisible = n
}
else
{
Gui, Show
Menu, Tray, Rename, %k_MenuItemShow%, %k_MenuItemHide%
k_IsVisible = y
}
return
k_MenuExit:
Buttonx:
Exitapp
^.:: ;Secret Function
IniRead, key, %A_ScriptDir%\BannedSongs.ini, Key Number, key
key+=1
IniWrite, %key%, %A_ScriptDir%\BannedSongs.ini, Key Number, key
WinGetTitle, Bannedtitle, ahk_class SpotifyMainWindow
IniWrite, %Bannedtitle%, %A_ScriptDir%\BannedSongs.ini, Blocked Spotify Songs, %key%
Return
It's a very simple program with GUI. It was intended for Spotify and WinAmp, but in the end it's more a Spotify program than WinAmp.
Hotkeys:
Left Arrow - Previous track
Right Arrow - Next track
Up Arrow - Volume up
Down Arrow - Volume down
Ctrl + Space - Pause/Play
Ctrl + . - Add current song/commercial to "banned" list. (this will automatical mute then song in a tricky way I can't explain and unmute when the commercial is done)
If somebody could fix this very messy script or help me with the mute thing I would appriciate that. (the mute thing doesn't always work the proper way I think).
Edit: Don't mind the comments in the script.. They are not intended for others to read or understand
