AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Please, help me to create a very special script.
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 9:53 am    Post subject: Please, help me to create a very special script. Reply with quote

Hi all. This is my first post.
I discover this great app after trying to find a way to use my TrackIR 3 Vector Expansion on my favorite game, Pacific Fighters.
In order to use that hardware on that game, is needed to load two programs: a program called tir2joy, that translates TrackIR movements to a virtual joystcik and an AHK script that translates joystick movements to keys.
My question is about automatice the loading of both programs on a single keystroke or executable.
I would like to:
1. Load the AHK script
2. Load the program tir2joy (its just a simple .exe)
3. Send tir2joy window to the tray (or some kind of hide)

I´ve found on AHK page, a script that send to tray any active window using Win key + H.
Is there any way to do what I need?

I dont know if it is possible to combine inside the same "H" (the tray green icon of AHK) various scripts, or each script has its own "H"

Can anybody help me?

Tnx a lot!

(BTW, this is the page where is the joystick script explained: http://forums.naturalpoint.com/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=8&t=000121#000016)
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Sat Feb 26, 2005 10:09 am    Post subject: Reply with quote

1. Load the AHK script
2. Load the program tir2joy (its just a simple .exe)
3. Send tir2joy window to the tray (or some kind of hide)

a) add/write this lines to your AHKScript

Code:
#Persistent ; will keep your script active

!F9:: ; Hotkey - press ALT+F9 to UnHide your tir2Joy window
WinShow, <tir2joy WindowsTitle>
Return

Run, tir2joy.exe,<EnterHereTheTir2Joy.exePath>, Hide ; Execute tir2joy
WinHide, <tir2joy WindowsTitle> ; hide its window


That additional code will start tir2joy, but keeps its window hidden.
Pressing Alt+F9 (you can change that) will show/unhide tir2joy's window.

Hopefully ... Rolling Eyes

btw: would make sense if you provide some code! So there's a chance to tweak it to your needs.
Back to top
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 10:23 am    Post subject: Reply with quote

Excuse me. Here is the script of the joystick:
http://forums.naturalpoint.com/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=8&t=000121#000016)

(Please, excuse me if I do not copy and paste the script here, cause I´ve been unable to make them appear correctly aligned Embarassed )

My tir2joy program is on C:\juegos\tir2joy\tir2joy.exe, so in the line you mention, should I put:
Run, tir2joy.exe <C:\juegos\tir2joy\tir2joy.exe> ?

Should I paste your script AFTER the last line (return) of my joystick script?

Thanks in advance!
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Sat Feb 26, 2005 10:35 am    Post subject: Reply with quote

Amazing. Yo gaming geeks are quite sophisticated AHK coders Wink
I think Chris and/or Rajat and/or another programming guru (hidden style Wink ) can help you out. Stay tuned.

It would make sense if you edit the code to post it here, as I had a problem to identify your/the final release which we should tweak.
Thanks. Cool
Back to top
Guest






PostPosted: Sat Feb 26, 2005 10:44 am    Post subject: Reply with quote

Quote:
My tir2joy program is on C:\juegos\tir2joy\tir2joy.exe, so in the line you mention, should I put:
Run, tir2joy.exe <C:\juegos\tir2joy\tir2joy.exe> ?

Yes, following AHK's syntax on [Run/RunWait] :

Quote:
Run / RunWait
--------------------------------------------------------------------------------
Runs an external program. Unlike Run, RunWait will wait until the program finishes before continuing.

Run, Target [, WorkingDir, Max|Min|Hide|UseErrorLevel, OutputVarPID]


The working directory should be set (IMHO), otherwise the script has to stay within the same folder as the called/executed program.

Code:
Run, tir2joy.exe, C:\juegos\tir2joy, Hide


btw: please don't ignore my post above Wink
Back to top
ranomore



Joined: 06 Nov 2004
Posts: 178
Location: Salt Lake City, UT

PostPosted: Sat Feb 26, 2005 10:46 am    Post subject: Reply with quote

read more about the auto-execute section here: http://www.autohotkey.com/docs/Scripts.htm

This may help you understand where to paste different parts of what BoBo suggested.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 10:50 am    Post subject: Reply with quote

This is the final version of the script I mentioned first.

Code:

; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other
;
; Script Function:
; Template AutoHotkey script.
;

; TrackIR Zoom Script for IL2FB/AEP/PF
; http://www.lufthunden.com
; This script is used to send single keypresses to manage FOV in IL2.
; =LH=Mave's Xmas present for the IL2 community 
#SingleInstance
SetFormat, float, 03 ; Omit decimal point from axis position percentages.
JoystickNumber = 2 ; Increase this to test a joystick other than the first.
JoystickAxis = V ; Set this to the axis you want to use.
GetKeyState, axis_count, %JoystickNumber%JoyAxes
if axis_count < 1
{
MsgBox Joystick #%JoystickNumber% does not appear to be attached to the system.
ExitApp
}
Loop
{
GetKeyState, joystate, %JoystickNumber%Joy%JoystickAxis%
if joystate between 000 and 013
ifNotEqual, sent_button, 1
{
sent_button = 1
Send, +{Numpad0 1}
}
if joystate between 014 and 018
ifNotEqual, sent_button, 2
{
sent_button = 2
Send, +{Numpad9 1}
}
if joystate between 019 and 023
ifNotEqual, sent_button, 3
{
sent_button = 3
Send, +{Numpad8 1}
}
if joystate between 024 and 028
ifNotEqual, sent_button, 4
{
sent_button = 4
Send, +{Numpad7 1}
}
if joystate between 029 and 033
ifNotEqual, sent_button, 5
{
sent_button = 5
Send, +{Numpad6 1}
}
if joystate between 034 and 038
ifNotEqual, sent_button, 6
{
sent_button = 6
Send, +{Numpad5 1}
}
if joystate between 039 and 043
ifNotEqual, sent_button, 7
{
sent_button = 7
Send, +{Numpad4 1}
}
if joystate between 044 and 048
ifNotEqual, sent_button, 8
{
sent_button = 8
Send, +{Numpad3 1}
}
if joystate between 049 and 056
ifNotEqual, sent_button, 9
{
sent_button = 9
Send, +{Numpad2 1}
}
if joystate between 057 and 061
ifNotEqual, sent_button, 10
{
sent_button = 10
Send, +{Numpad1 1}
}
if joystate between 062 and 066
ifNotEqual, sent_button, 11
{
sent_button = 11
Send, +{NumpadMult 1}
}
if joystate between 067 and 071
ifNotEqual, sent_button, 12
{
sent_button = 12
Send, +{NumpadSub 1}
}
if joystate between 072 and 100
ifNotEqual, sent_button, 13
{
sent_button = 13
Send, +{NumpadAdd 1}
}
if joystate between 000 and 023 ;If state "023" or below, enable precision mode
ifNotEqual, precision_mode, 1
{
precision_mode = 1
Send, {F10 down}
}
if joystate between 024 and 100 ;If state "024" or more, disable precision mode
ifNotEqual, precision_mode, 0
{
precision_mode = 0
Send, {F10 up}
}

Sleep, 25
}
return


I hope you can help me

Tnx for you fast answers!
Back to top
View user's profile Send private message
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 11:00 am    Post subject: Reply with quote

I created this script, using your guidelines:

Code:

#Persistent ; will keep your script active

!F9:: ; Hotkey - press ALT+F9 to UnHide your tir2Joy window
WinShow, <TrackIR2Joystick v1.2>
Return

Run, tir2joy.exe, C:\tir2joy, Hide
WinHide, <TrackIR2Joystick v1.2>


First I created a folder named tir2joy and pasted the tir2joy executable there. No luck.
I removed the <> of the script, and No luck.

The tir2joy program doesnt start. Any idea?
Back to top
View user's profile Send private message
ranomore



Joined: 06 Nov 2004
Posts: 178
Location: Salt Lake City, UT

PostPosted: Sat Feb 26, 2005 11:07 am    Post subject: Reply with quote

Code:
Run, tir2joy.exe, C:\tir2joy, Hide
WinHide, <TrackIR2Joystick v1.2>

these two lines aren't associated with a label or a hotkey - they're hanging out in nowhereville.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 11:13 am    Post subject: Reply with quote

WEll, I have some progress

Using this:
Code:
Run, tir2joy.exe, C:\tir2joy, Hide


The program runs hidden and works. The problem is that I need to Ctrl+Alt+Brk for close it, but its a beggining.

Now, I need to close it with a hotkey and use this script at the same time of the long joystick script I posted.
Can I use the same .ahk file for both?
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Sat Feb 26, 2005 11:24 am    Post subject: Reply with quote

I guess the error is here:
Code:
Run, tir2joy.exe, C:\tir2joy, [color=red]Hide[/color] ; the window gets hidden here
WinHide, <TrackIR2Joystick v1.2> ; so that line, makes no sense (:oops:) at this stage

, beside the fact that I doubt that the window title contains any <> chars ! and [SetTitleMatchMode] is set to the default to 3 ([v1.0.11]: A window's title must exactly match WinTitle to be a match. - I guess) Maybe you should change that.

Quote:
these two lines aren't associated with a label or a hotkey
Shouldn't make any difference. The app should be executed at startup of the script, and that's it.

The hotkey should trigger to unhide/show it!

Code:
!F9:: ; ALT+F9 to show the window
WinShow, TrackIR2Joystick v1.2
Return


Eh, yep we should have another one to hide again.

Code:
!F10:: ; ALT+F10 to hide the window
WinHide, TrackIR2Joystick v1.2
Return


btw: have seen your post this sec. maybe some of my above statement has become useless this way ...
Back to top
BoBo
Guest





PostPosted: Sat Feb 26, 2005 11:27 am    Post subject: Reply with quote

Should have used quote, instead of code (to keep the code intact and show the marked/colored section. Rolling Eyes
Quote:
Run, tir2joy.exe, C:\tir2joy, Hide ; the window gets hidden here
Back to top
BoBo
Guest





PostPosted: Sat Feb 26, 2005 11:32 am    Post subject: Reply with quote

Quote:
!F11:: ; ALT+F11 to shutdown the app
WinClose, TrackIR2Joystick v1.2
Return


Alternative [AHK commands] to shutdown a window/app ---> WinKill or Process
Back to top
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 11:34 am    Post subject: Reply with quote

Great! Now works!

Now I need to execute my Joystick script AND your script. If possible, I would like to show only one green "H" for both scripts Smile

Tnx

I used this:
Code:
Run, tir2joy.exe, C:\tir2joy, Hide ;    the window gets hidden here
WinHide, <TrackIR2Joystick v1.2> ;          so that line, makes no sense (:oops:) at this stage

!F9:: ; ALT+F9 to show the window
WinShow, TrackIR2Joystick v1.2
Return

!F10:: ; ALT+F10 to hide the window
WinHide, TrackIR2Joystick v1.2
Return
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Sat Feb 26, 2005 11:41 am    Post subject: Reply with quote

Can't see why you shouldn't be able to use your above outcome within the same script ...

Quote:
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other
;
; Script Function:
; Template AutoHotkey script.
;

; TrackIR Zoom Script for IL2FB/AEP/PF
; http://www.lufthunden.com
; This script is used to send single keypresses to manage FOV in IL2.
; =LH=Mave's Xmas present for the IL2 community
#SingleInstance

#Persistent

Run, tir2joy.exe, C:\tir2joy, Hide ; the window gets hidden here

!F9:: ; ALT+F9 to show the window
WinShow, TrackIR2Joystick v1.2
Return

!F10:: ; ALT+F10 to hide the window
WinHide, TrackIR2Joystick v1.2
Return


SetFormat, float, 03 ; Omit decimal point from axis position percentages.
JoystickNumber = 2 ; Increase this to test a joystick other than the first.
JoystickAxis = V ; Set this to the axis you want to use.
GetKeyState, axis_count, %JoystickNumber%JoyAxes
if axis_count < 1
.
.
.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group