AutoHotkey Community

It is currently May 27th, 2012, 1:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: November 17th, 2009, 1:18 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
Hi all,

Have been searching for hours to try solving this problem. No "joy" :D
Am way no expert with this language, but here goes what I need.
I know how to program (using Send) keystrokes to a Joystick button.
But I need to have the re-mappings changed when I press a specific Joy button, for the same joystick.

Ex:

;Profile 1
Joy1:: Send {LShift}{NumpadDiv}
.
.
.
Joy32 -> "Load profile 2"

;profile2
Joy1:: Send {Shift}{Alt}1
.
.
.
Joy32 -> Load Profile 1


Hope made my self clear.

Thanks in advance.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 2:49 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Try this:
Code:
current=1
Hotkey,Joy1,1Joy1

1Joy1:
Send {LShift}{NumpadDiv}
Return
2Joy1:
Send {Shift}{Alt}1
Return

Joy32::
current++
If !IsLabel(%current%Joy1)
  current=1
Hotkey,Joy1,%current%Joy1
Return


or even simpler.

Code:
Joy1::Send % (profile = 1 ? "{LShift}{NumpadDiv}" : "{Shift}{Alt}1")

Joy32::profile:=profile=2 ? 1 : 2

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 3:48 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
HotKeyIt wrote:
Try this:
Code:
current=1
Hotkey,Joy1,1Joy1

1Joy1:
Send {LShift}{NumpadDiv}
Return
2Joy1:
Send {Shift}{Alt}1
Return

Joy32::
current++
If !IsLabel(%current%Joy1)
  current=1
Hotkey,Joy1,%current%Joy1
Return


or even simpler.

Code:
Joy1::Send % (profile = 1 ? "{LShift}{NumpadDiv}" : "{Shift}{Alt}1")

Joy32::profile:=profile=2 ? 1 : 2


Hey mate, thanks.

But... 1Joy and 2Joy refer to multiple joysticks, I believe...
Correct me if am wrong, maybe am not understanding your 1st code, but that's not the problem.
Have only one joystick and want it to send some keys if "profile" is 1 and other keys (same joy) if "profile" is 2...
"Profile" is only a flag here, which is defined by the 32 or 31 button.

Thou, your 2nd code may solve this... will test it

Cheers.


Last edited by flyway on November 17th, 2009, 4:24 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 4:19 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
Well,

Your 2nd code works ok, till I try this... :D

Code:
Joy1::Send % (profile = 1 ? "{LShift down}{NumpadDiv down}" : "{Shift down}{Alt down}{1 down}")
KeyWait Joy1
Send % (profile = 1 ? "{LShift up}{NumpadDiv up}" : "{Shift up}{Alt up}{1 up}")

Joy31::profile:=profile=2 ? 1 : 2


Here, can only see the "down" assignements. :oops:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 8:02 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
Could use some help here.. :D
Anyone?

Cheers.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 9:31 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
This is what am trying to develop...

Code:
#Persistent  ; Keep this script running until the user explicitly exits it.
SetTimer, WatchPOV, 5
return

WatchPOV:
GetKeyState, POV, JoyPOV  ; Get position of the POV control.

If POV=18000
profile=1

If POV=0
profile=2

If POV=9000
profile=3

Return

Joy1::Send % (profile = 1 ? "{LShift}{NumpadDiv}" : "{Ctrl}{Alt}1" : "{Shift}{Alt}1")


POV buttons to define what keys to send by each joystick button...
But like this, not working.
Can anyone help with this ?

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2009, 11:36 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Have you checked if profile var is being set at all?
Does Send not work at all?

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2009, 3:39 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
HotKeyIt wrote:
Have you checked if profile var is being set at all?
Does Send not work at all?


Nop, didn't made any of those tests.
Thought this last code of mine was wrong anyware... is it wright?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2009, 6:20 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
flyway wrote:
HotKeyIt wrote:
Have you checked if profile var is being set at all?
Does Send not work at all?


Nop, didn't made any of those tests.
Thought this last code of mine was wrong anyware... is it wright?


Try this:
Code:
_1800={LShift}{NumpadDiv}
_0={Ctrl}{Alt}1
_9000={Shift}{Alt}1
SetTimer, WatchPOV, 100
return

WatchPOV:
GetKeyState, POV, JoyPOV  ; Get position of the POV control.
send:=_%POV%
Return

Joy1::SendInput % send

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 6:39 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
Hey HotKeyIt,

Thanks alot for your efforts my friend.
Can understand your code, but there's a problem with it and it's because of mine, for lacking explanations...

I'll need that code to do exactly the same for all 32 buttons, see?
Same way... POV will tell what keys each button to send.
Believe that code will only work for button 1...

My bad, using JOY1 as an example, thought I could manage the rest of the code, but with your last code, cannot figure out how to do it...

Cheers.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 7:17 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Code:
#Persistent
Loop 32
 Hotkey,JOY%A_Index%,Send
_1800={LShift}{NumpadDiv}
_0={Ctrl}{Alt}1
_9000={Shift}{Alt}1
SetTimer, WatchPOV, 100
return

WatchPOV:
GetKeyState, POV, JoyPOV  ; Get position of the POV control.
send:=_%POV%
Return

Send:
 SendInput % send
Return

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 8:10 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
Hey HKI,

Again, didn't express myself correctly.
Sorry for that, I sayd "...same for all 32 buttons", but this is not correct.
What's the same for all 32 buttons is the way POV defines keystrokes for each button.
But each Joystick button has it's 3 assignments and are not the same for all, see?

Example:

Profile=1
Joy1 send "Ctrl 1"
Joy2 send "Ctrl 2"
.
.

Profile=2
Joy1 send "Alt 1"
Joy2 send "Alt 2"
.
.

Profile=3
Joy1 send "Shift 1"
Joy2 send "Shitf 2"
.
.

Hope this explains it better.
Sorry again.

Thanks alot mate.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 9:58 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Try this:
Code:
#Persistent
1_1800=^1 ;JOY1 profile 1
2_1800=!1 ;JOY2 profile 1 ...
3_1800={LShift}{NumpadDiv}
1_0={Ctrl}{Alt}1 ;JOY1 profile 2 ...
2_0={Ctrl}{Alt}1
3_0={Ctrl}{Alt}1
1_9000={Shift}{Alt}1
2_9000={Shift}{Alt}1
3_9000={Shift}{Alt}1
Loop 3 ;as many times as many hotkeys
 Hotkey,JOY%A_Index%,Send
SetTimer, WatchPOV, 100
return

WatchPOV:
GetKeyState, POV, JoyPOV  ; Get position of the POV control.
If POV not in 1800,0,9000
   Return
Loop 3 ;as many times as many hotkeys
   JOY%A_Index%_send:=%A_Index%_%POV%
Return

Send:
 SendInput % %A_ThisHotkey%_send
Return

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 19th, 2009, 10:23 pm 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
WOW, thanks alot.
That will require some study :D from me.
Will try it and keep you posted about it.

Thanks again.

Cheers.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 20th, 2009, 11:57 am 
Offline

Joined: November 17th, 2009, 1:12 pm
Posts: 37
Hey HotKeyIt,

Good news here. Thanks alot.

Now another problem am facing...
Here's my code (so far... POV=18000 is almost ready, other POV values still to be worked out...)
Code:
#Persistent

;ICP
1_18000={Shift}{NumpadDiv}
2_18000={Shift}{NumpadMult}
3_18000={Shift}{Numpad7}
4_18000={Shift}{Numpad9}
5_18000={Shift}{Numpad0}
6_18000={Shift}{NumpadDot}
7_18000={Ctrl}{Numpad1}
8_18000={Ctrl}{Numpad2}
9_18000={Ctrl}{Numpad3}
10_18000={Ctrl}{NumpadDot}
11_18000={Ctrl}{NumpadAdd}
12_18000={Ctrl}{NumpadSub}
13_18000={Ctrl}{Numpad4}
14_18000={Ctrl}{Numpad5}
15_18000={Ctrl}{Numpad6}
16_18000={Ctrl}{NumpadEnter}
17_18000={Ctrl}{Numpad7}
18_18000={Ctrl}{Numpad8}
19_18000={Ctrl}{Delete}
20_18000={Ctrl}{Home}
21_18000={Ctrl}{Numpad9}
22_18000={Ctrl}{Numpad0}
23_18000={Ctrl}{PgDn}
24_18000={Ctrl}{Enter}
25_18000={Shift}{Ctrl}{Alt}W
26_18000={Shift}{Ctrl}{Alt}7 ; Drift C/O On
;??_18000={Shift}{Ctrl}{Alt}8 ; Drift C/O Off

;MFDleft
1_0={Ctrl}{Alt}1
2_0={Ctrl}{Alt}2
3_0={Ctrl}{Alt}3

;MFDright
1_9000={Shift}1
2_9000={Shift}2
3_9000={Shift}3

Loop 3 ;as many times as many hotkeys
 Hotkey,2JOY%A_Index%,Send
SetTimer, WatchPOV, 100
return

WatchPOV:
GetKeyState, POV, 2JoyPOV  ; Get position of the POV control.
If POV not in 18000,0,9000
   Return

Loop 3 ;as many times as many hotkeys
   2JOY%A_Index%_send:=%A_Index%_%POV%
Return

Send:
 SendInput % %A_ThisHotkey%_send
Return



I need to assign {Shift}{Ctrl}{Alt}7 to button 26 (POV=26_18000) but when this joystivk button goes down.
And to assign {Shift}{Ctrl}{Alt}8 when it goes up.
See?
This should be same for any POV value.

Is this possible within this code... ?
Maybe best approach to work it out outside POV conditioning... asking...
:D

Sorry to bother you so much.

Thanks mate.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 40 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: iDrug, Ohnitiel and 24 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:
Powered by phpBB® Forum Software © phpBB Group