AutoHotkey Community

It is currently May 26th, 2012, 4:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: March 21st, 2008, 5:02 pm 
Offline

Joined: March 20th, 2008, 11:32 pm
Posts: 1
Hi,

I just found AutoHotKey on google yesterday 8)
I was searching for a way to control Foobar2000 with the 2 useless buttons on each side of the wheel.
I've play/pause and vol up/down on my keyboard, so I tought it could be great if I could use my mouse to skip the songs forward and backward.

To make it short: these buttons aren't xButton1/2 and were undetectable by AutoHotKey, I downloaded SetPoint & Uberoptions, next I assigned F21 & F22 to it.

Here is my script, working:
Code:
;FORWARD
~F22::
{
NextSong: ;skip song
GetKeyState, vButtonFWD, F22
if vButtonFWD = U
   {
   if A_TimeSinceThisHotkey < 190
   {
   SendInput {F14}
   }
   }
else if A_TimeSinceThisHotkey < 190
   {
   goto NextSong
   }
else if vButtonFWD = D
   {
   if A_TimeSinceThisHotkey >= 190
{
loop ;seek in song
{
if vslowtofast < 16
   {
   SendInput {Media_Next}
   Sleep, 200
   vslowtofast ++
   }
else
   {
   SendInput {Media_Next}
   Sleep, 70
   }
GetKeyState, vButtonFWD, F22
if vButtonFWD = U
   {
   vslowtofast = 0
   break
   }
}
}
}
}
return

;BACKWARD   
~F21::
{
PrevSong: ;skip
GetKeyState, vButtonBWD, F21
if vButtonBWD = U
   {
   if A_TimeSinceThisHotkey < 190
   {
   SendInput {F13}
   }
   }
else if A_TimeSinceThisHotkey < 190
   {
   goto PrevSong
   }
else if vButtonBWD = D
   {
   if A_TimeSinceThisHotkey >= 190
   {
loop ;seek
{
if vslowtofast < 16
   {
   SendInput {Media_Prev}
   Sleep, 200
   vslowtofast ++
   }
else
   {
   SendInput {Media_Prev}
   Sleep, 70
   }
GetKeyState, vButtonBWD, F21
if vButtonBWD = U
   {
   vslowtofast = 0
   break
   }
}
}
}
}
return


Keys assigned in Foobar:
-F13 and F14: Previous and Next
-Media_prev and Media_next: Seek back and seek ahead

What it does:
-A short clic will skip the song;
-Hold the button down will seek in the song,
-Hold longer will seek faster (after +/- 3sec)

The script is working, but I still have some questions (The last time I've scripted ... 1 or 2 years ago, in NeverWinter Nights... and I wans'nt skilled :P):
-> I first try(for exemple)
Code:
if vButtonFWD = U && A_TimeSinceThisHotkey < 190

It didn't work, I had to put a if into a if. Why?

-> Without "return" at the and of each button script, It didn't work as well as they are present... But in fact, I don't know the maining of "return"...

-> Is it possible to make this script looking better? :P

Thanks ;)

PS: I usually speak french, sorry for any language mistake...
PS2: You can't feel it in the message, but in fact I worked on it for HOURS :lol:


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: JamixZol and 12 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:
cron
Powered by phpBB® Forum Software © phpBB Group