 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Bkid
Joined: 26 Sep 2005 Posts: 44 Location: Hephzibah, GA
|
Posted: Sun Oct 14, 2007 11:27 am Post subject: SetKeyDelay not...setting. :( |
|
|
I'm not sure what's going wrong here, but I'm just not getting SetKeyDelay and my game controller buttons to work nicely together. I know SetKeyDelay is getting the correct variable (user input from an edit box), but they keys just aren't acting like it..
Just to avoid any confusion: User enters a number into the edit box. This number will be used as the SetKeyDelay number (in milliseconds). Something just doesn't seem to be working out right...
| Code: | #SingleInstance Force
Menu, Tray, NoStandard
Menu, Tray, Add, Restore, Restore
Menu, Tray, Add, Exit, GuiClose
Menu, Tray, Default, Restore
GuiTitle=Pop'n Delay v1.0
Gui, Show, w215 h230, %GuiTitle%
Gui, Add, Tab, w195 h180, Delay Settings|Key Config|Credits
Gui, Tab, 1
Gui, Add, Text,, Set delay (in milliseconds)*:
Gui, Add, Edit, w30 Limit4 Number vbuttondelay, 0
Gui, Add, Text, w180, This is where you will set the actual delay that you will feel in-game, using any number of milliseconds in the box above.
Gui, Add, Text, y+5 w180, Please remember that Config.exe MUST be set up as zsxdcfvgb, Home as test switch, and Esc as exit.
Gui, Add, Button, x+-190 y+20 Default, Set
Gui, Add, Text,x+5 y+-23, * Note that -1 is no delay at all and`n 0 is the smallest possible delay.
Gui, Tab, 2
Gui, Add, Text,, Coming soon!
Gui, Tab, 3
Gui, Add, Text,, Created by Bkid [Bkid@bemaniso.ws]
Gui, Add, Text, y+10 x+-103, for
Gui, Add, Picture, y+15 x+-90 h40 w180 gLaunchSows, %A_ScriptDir%\img\sows.png
Gui, Show
Return
ButtonSet:
Gui, Submit
SetKeyDelay, %buttondelay%
MsgBox, 64, Pop'n Delay, Button delay has been set to %buttondelay%ms. Have a enjoy!
TrayTip, Pop'n Delay, Minimized to tray, 1, 1
Gosub, start
Return
LaunchSows:
Run http://bemaniso.ws/
Return
GuiSize:
GuiWidth:=A_GuiWidth
GuiHeight:=A_GuiHeight
WinGetPos, GuiX, GuiY, , , %GuiTitle%, , ,
If (GuiWidth = 0) && If (GuiHeight = 0) && If (GuiX = -32000) && If (GuiY = -32000)
{
TrayTip, Pop'n Delay, Minimized to tray, 1, 1
Gui, Hide
}
Return
Start:
SetTimer, WatchAxis, %buttondelay%
return
WatchAxis:
GetKeyState, JoyY, JoyY ; Get position of Y axis.
KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any).
if JoyY > 99
KeyToHoldDown =
else if JoyY < 1
KeyToHoldDown = g
else
KeyToHoldDown =
if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down (or no key is needed).
return
if KeyToHoldDownPrev
Send, {%KeyToHoldDownPrev% up}
if KeyToHoldDown
Send, {%KeyToHoldDown% down}
return
Joy1::
Send {z down}
SetTimer, WaitForButtonUp1, %buttondelay%
return
WaitForButtonUp1:
if GetKeyState("Joy1")
return
Send {z up}
SetTimer, WaitForButtonUp1, off
return
Joy2::
Send {s down}
SetTimer, WaitForButtonUp2, %buttondelay%
return
WaitForButtonUp2:
if GetKeyState("Joy2")
return
Send {s up}
SetTimer, WaitForButtonUp2, off
return
Joy8::
Send {x down}
SetTimer, WaitForButtonUp8, %buttondelay%
return
WaitForButtonUp8:
if GetKeyState("Joy8")
return
Send {x up}
SetTimer, WaitForButtonUp8, off
return
Joy3::
Send {d down}
SetTimer, WaitForButtonUp3, %buttondelay%
return
WaitForButtonUp3:
if GetKeyState("Joy3")
return
Send {d up}
SetTimer, WaitForButtonUp3, off
return
Joy7::
Send {c down}
SetTimer, WaitForButtonUp7, %buttondelay%
return
WaitForButtonUp7:
if GetKeyState("Joy7")
return
Send {c up}
SetTimer, WaitForButtonUp7, off
return
Joy4::
Send {f down}
SetTimer, WaitForButtonUp4, %buttondelay%
return
WaitForButtonUp4:
if GetKeyState("Joy4")
return
Send {f up}
SetTimer, WaitForButtonUp4, off
return
Joy6::
Send {v down}
SetTimer, WaitForButtonUp6, %buttondelay%
return
WaitForButtonUp6:
if GetKeyState("Joy6")
return
Send {v up}
SetTimer, WaitForButtonUp6, off
return
Joy5::
Send {b down}
SetTimer, WaitForButtonUp5, %buttondelay%
return
WaitForButtonUp5:
if GetKeyState("Joy5")
return
Send {b up}
SetTimer, WaitForButtonUp5, off
return
Joy9::
Send {esc down}
SetTimer, WaitForButtonUp9, %buttondelay%
return
WaitForButtonUp9:
if GetKeyState("Joy9")
return
Send {esc up}
SetTimer, WaitForButtonUp9, off
return
Joy10::
Send {Home down}
SetTimer, WaitForButtonUp10, %buttondelay%
return
WaitForButtonUp10:
if GetKeyState("Joy10")
return
Send {Home up}
SetTimer, WaitForButtonUp10, off
return
Restore:
Gui, Show
Return
GuiClose:
ExitApp |
It's 6:30AM, and I've been working on this for the past 3 hours..I really hope it's not just something I overlooked.  _________________ --Bkid-- |
|
| Back to top |
|
 |
tekkie2412
Joined: 22 May 2007 Posts: 46
|
Posted: Sun Oct 14, 2007 11:42 am Post subject: |
|
|
I dont see any keys being pushed in your script that SetKeyDelay would apply too. Maybe Im blind but it looks like your controlling every key press already with a "down" and "up" and I dont think SetKeyDelay controls those.
Maybe try putting a "Sleep, %buttondelay%" after each of the {button down}'s |
|
| Back to top |
|
 |
Bkid
Joined: 26 Sep 2005 Posts: 44 Location: Hephzibah, GA
|
Posted: Sun Oct 14, 2007 11:53 am Post subject: |
|
|
Well I had | Code: | | SetTimer, WaitForButtonUp1, %buttondelay% | hoping it would create some sort of delay, but I guess that's not how SetTimer works.  _________________ --Bkid-- |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2558 Location: Australia, Qld
|
Posted: Sun Oct 14, 2007 1:44 pm Post subject: |
|
|
| SetKeyDelay wrote: | Sets the delay that will occur after each keystroke sent by Send and ControlSend.
...
Note: SetKeyDelay is not obeyed by SendInput; there is no delay between keystrokes in that mode. This same is true for Send when SendMode Input is in effect.
A short delay (sleep) is done automatically after every keystroke sent by Send or ControlSend. This is done to improve the reliability of scripts because a window sometimes can't keep up with a rapid flood of keystrokes. | SetKeyDelay, %buttondelay% would apply to both {key down} and {key up} events, but it probably wouldn't give the effect you're after. Also, | Quote: | | Every newly launched thread (such as a hotkey, custom menu item, or timed subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script). | Hotkeys, GUI and timer labels all run in their own "thread," meaning in your ButtonSet subroutine, the SetKeyDelay setting would be restored to its default as soon as the subroutine returns.
| Quote: | | ... but I guess that's not how SetTimer works. | I will explain.
WaitForButtonUp would run every %buttondelay% milliseconds, starting %buttondelay% ms after the hotkey executes. Say you held Joy10 down for 250 ms and buttondelay was 100 ms:
- The script sends {Home down}.
- At 100 ms, the script checks if Joy10 has been released. It has not, so it returns.
- At 200 ms, the script checks if Joy10 has been released. It has not, so it returns.
- At 300 ms, the script checks if Joy10 has been released. It was released 50 ms ago, so the script sends {Home up} and disables the timer.
Assuming I understand the effect you're after, you need to add another timer.
- Have the first, frequent (say, 10ms) timer checking whether the button has been released.
- Have the second timer execute once with a delay of %buttondelay% milliseconds, to send the {key up}. (Set the second timer from the subroutine of the first.)
Small tip: | Quote: | | Run only once [v1.0.46.16+]: Specify a negative Period to indicate that the timer should run only once. For example, specifying -100 would run the timer 100 ms from now then disable the timer as though SetTimer, Label, Off had been used. |
|
|
| Back to top |
|
 |
Bkid
Joined: 26 Sep 2005 Posts: 44 Location: Hephzibah, GA
|
Posted: Sun Oct 14, 2007 8:05 pm Post subject: |
|
|
Ok so now that I'm awake, I can put a little more time into this..Now, I really don't feel like making another time, so I'm going to have to find another way around this..I just hate the fact that SetKeyDelay isn't scriptwide. Or rather, doesn't stay default scriptwide..
I'll figure it out eventually. :/
EDIT: Here's the basics of the code, the only two problems being:
1) I want them to PRESS with a delay, but release instantly.
and
2) You can't press 2 at the same time (It will press one, then the other right after).
| Code: | SetKeyDelay, 70
SetTimer, WatchAxis, 0
return
WatchAxis:
GetKeyState, JoyY, JoyY
KeyToHoldDownPrev = %KeyToHoldDown%
if JoyY > 99
KeyToHoldDown =
else if JoyY < 1
KeyToHoldDown = g
else
KeyToHoldDown =
if KeyToHoldDown = %KeyToHoldDownPrev%
return
if KeyToHoldDownPrev
Send, {%KeyToHoldDownPrev% up}
if KeyToHoldDown
Send, {%KeyToHoldDown% down}
return
Joy1::
Send {z down}
Keywait Joy1
Send {z up}
return
Joy2::
Send {s down}
Keywait Joy2
Send {s up}
return
Joy8::
Send {x down}
Keywait Joy8
Send {x up}
return
Joy3::
Send {d down}
Keywait Joy3
Send {d up}
return
Joy7::
Send {c down}
Keywait Joy7
Send {c up}
return
Joy4::
Send {f down}
Keywait Joy4
Send {f up}
return
Joy6::
Send {v down}
Keywait Joy 6
Send {v up}
return
Joy5::
Send {b down}
Keywait Joy5
Send {b up}
return
Joy9::
Send {esc down}
SetTimer, WaitForButtonUp9, 0
return
WaitForButtonUp9:
if GetKeyState("Joy9")
return
Send {esc up}
SetTimer, WaitForButtonUp9, off
return
Joy10::
Send {Home down}
SetTimer, WaitForButtonUp10, 0
return
WaitForButtonUp10:
if GetKeyState("Joy10")
return
Send {Home up}
SetTimer, WaitForButtonUp10, off
return
Restore:
Gui, Show
Return
GuiClose:
ExitApp |
_________________ --Bkid-- |
|
| 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
|