VSK Nordic Forum Forum Index VSK Nordic Forum

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AutoHotkey

 
Post new topic   Reply to topic    VSK Nordic Forum Forum Index -> På vannet
View previous topic :: View next topic  
Author Message
euphoria



Joined: 05 Apr 2006
Posts: 1377

PostPosted: Tue Oct 09, 2012 4:18 pm    Post subject: AutoHotkey Reply with quote

Hei,

Her er et script som alle som ønsker kan modifisere etter sine preferanser og bruke hvis de ønsker det. Scriptet kjøres i programmet AutoHotkey og forenkler teknikken ved stagvending i VSK.

Slik scriptet er satt opp trykker man F6/F7 for å starte en stagvending (det trykkes da på et gitt prosentvis rorutslag), og man trykker F5/F8 når man passerer vindøyet (det gis da litt mer rorutslag).

Brukeren må endre scriptet for å få det til å passe brukerens stil:
F5-F8 bør endres, hvis brukeren ikke velger å endre disse knappene i VSK (view directions).
Verdiene på roret må endres av brukeren. ( Er satt til 25%, 50% og 75% default, som ikke gir i nærheten av en god stagvending...)

Her er scriptet:

Code:
; Constants, don't change these:
ConstantX = 0.2453125   ; Just a constant that is found through calibration to hit between -100% to +100% on the rudder meter when used in formulas below
ConstantY = 0.9825      ; Similar for the vertical click position

; Default values - Change to suit your default screen size (or just use ctrl-w to calibrate each time you start vsk - I do that...)
WindowWidth = 1288   ;   Window width including borders
WindowHeight = 994   ;   Window height including borders
GameWidth = 1280   ;   Game area width
GameHeight = 960   ;   Game area height
DY = 30      ;   Size of the title field of the window



; Your predefined click positions on the rudder, from 0 to 100% (0 to 1.0), CHANGE TO SUIT YOUR TACKING STYLE

Pos1 = 0.25 ; This position is only accesible from the ctrl-arrow keys, edit 0.25 to define your own value
Pos2 = 0.50 ; This position is used to start a tack through F6 or F7 keys, edit 0.50 to define your own value
Pos3 = 0.75 ; This position is used to continue a tack when passing HTW through F5 and F8 keys, edit 0.75 to define your own value
Pos4 = 1.00 ; This position is only accesible from the ctrl-arrow keys, it clicks at 100%

; From this section you can define which keys that does what. The key is the one that is followed by two colons (::). ^ means ctrl.

F5::            ; Press F5 to continue a tack from port to stb from from HTW (Change from F5 to suit your prefered key)
Steer(-3)
Rudder = -3
return

F6::            ; Press F6 to start a tack from port to stb from closehauled (Change from F6 to suit your prefered key)
Steer(-2)
Rudder = -2
return

F7::            ; Press F7 to start a tack from stb to port from closehauled (Change from F7 to suit your prefered key)
Steer(2)
Rudder = 2
return

F8::            ; Press F8 to continue a tack from stb to port from from HTW (Change from F8 to suit your prefered key)
Steer(3)
Rudder = 3
return

; The following defines the ctrl-arrows to jump between center and the 4 positions in each direction:

^Left::            ; Press ctrl-left to move rudder one step top left
if (Rudder <> -4) {
   Rudder := Rudder - 1
}
Steer(Rudder)
return

^Down::            ; Press ctrl-down to center rudder (and reset counter).
Rudder = 0
Steer(Rudder)
return

^Right::         ; Press ctrl-right to move rudder one step top right
if (Rudder <> 4) {
   Rudder := Rudder + 1
}
Steer(Rudder)
return

^w::            ; Press ctrl-w for the script to measure screen size and calibrates script to suit the size
WindowSize()
return



; Everything below this line is procedures and should not require any changes (or understanding...)

; Initiating
RudderPos()
Rudder = 0

WindowSize()
{
   global DY
   global GameHeight
   global GameWidth
   global WindowWidth

   WinGetPos,,, WindowWidth, WindowHeight, A

   If (WindowHeight = A_ScreenHeight) {
      DY = 0
      GameHeight := WindowHeight
      GameWidth := WindowWidth
   } else {
      DY = 30
      GameHeight := WindowHeight - 34
      GameWidth := WindowWidth - 8
   }
   
   RudderPos()
}

RudderPos()
{
   global ConstantX
   global ConstantY
   global Pos1
   global Pos2
   global Pos3
   global Pos4
   global WindowWidth
   global GameWidth
   global RudderCenter
   global RudderPort4
   global RudderPort3
   global RudderPort2
   global RudderPort1
   global RudderStarboard1
   global RudderStarboard2
   global RudderStarboard3
   global RudderStarboard4
   global RudderY
   global DY
   global GameHeight
   RudderCenter := WindowWidth / 2 - 0.5
   RudderPort4 := RudderCenter - GameWidth * ConstantX * Pos4
   RudderPort3 := RudderCenter - GameWidth * ConstantX * Pos3
   RudderPort2 := RudderCenter - GameWidth * ConstantX * Pos2
   RudderPort1 := RudderCenter - GameWidth * ConstantX * Pos1
   RudderStarboard1 := RudderCenter + GameWidth * ConstantX * Pos1
   RudderStarboard2 := RudderCenter + GameWidth * ConstantX * Pos2
   RudderStarboard3 := RudderCenter + GameWidth * ConstantX * Pos3
   RudderStarboard4 := RudderCenter + GameWidth * ConstantX * Pos4
   RudderY := DY + ConstantY * GameHeight
}

Steer(Rudder)
{
   global RudderCenter
   global RudderPort4
   global RudderPort3
   global RudderPort2
   global RudderPort1
   global RudderStarboard1
   global RudderStarboard2
   global RudderStarboard3
   global RudderStarboard4

   if (Rudder = -4) {
      Position := RudderPort4
   }   
   if (Rudder = -3) {
      Position := RudderPort3
   }   
   if (Rudder = -2) {
      Position := RudderPort2
   }   
   if (Rudder = -1) {
      Position := RudderPort1
   }   
   if (Rudder = 0) {
      Position := RudderCenter
   }   
   if (Rudder = 1) {
      Position := RudderStarboard1
   }   
   if (Rudder = 2) {
      Position := RudderStarboard2
   }   
   if (Rudder = 3) {
      Position := RudderStarboard3
   }   
   if (Rudder = 4) {
      Position := RudderStarboard4
   }   
   ClickPosition(Position)
}

ClickPosition(Position)
{
   global RudderY
   MouseMove, Position, RudderY
   Sleep, 5
   Click
   Sleep, 5
   Click
   Sleep, 5
   Click
   Sleep, 5
   Click
}


Harald

Steer
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    VSK Nordic Forum Forum Index -> På vannet All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group