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 Previous  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 11:59 am    Post subject: Reply with quote

No, does not work both together.
Seems that the first script blocks the next.

Ive tried removing #persistent and #oneinstance but no luck
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Sat Feb 26, 2005 12:15 pm    Post subject: Reply with quote

Well, it looks like I need some advise as well Wink

A workaround (?):
Use the "HotkeyScript" separately with AHK's #NoTrayIcon directive.
That way you'll see/get only the TrackIR Zoom Script's - TrayIcon.
Hope that helps.

Cool
Back to top
BoBo
Guest





PostPosted: Sat Feb 26, 2005 12:17 pm    Post subject: Reply with quote

And yes, start the "HotKeyScript" from within the Master script Wink
Back to top
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 12:41 pm    Post subject: Reply with quote

Wink
Precisely my intention was to avoid to load two files Embarassed
In the waiting if someone knows how to join both scripts, IŽll use two scripts separately. Anyway, your help has been great! Razz

Hope anybody knows the answer...
Back to top
View user's profile Send private message
Mats
Guest





PostPosted: Sat Feb 26, 2005 1:41 pm    Post subject: Reply with quote

Just a wild guess:
Have you tried to put the hotkey definitions at the very end of the script? As far as i know, ahk auto-executes your script till it sees the first "return". So in this case, it executes the "run" and the first hotkey (!F9 - as if it has been triggered) and then stops, waiting only for the hotkeys to be pressed.
Back to top
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 2:04 pm    Post subject: Reply with quote

Mats, youŽve found the answer! TNX!!

The final script will be:
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

Run, tir2joy.exe, C:\Juegos\IL-2 Sturmovik Forgotten Battles\tir2joy, Hide

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

   

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

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

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


#NoTrayIcon



Still there are some details that would like to solve:

- F11 Hotkey to close the program doesnt work. IŽve tried Winkill and other commands, but no luck

- Is there a way to close a program (in this case, tir2joy) at the same time you close AHK. Now I have learned how to open a script and a program toggther, I would like to know how to close both at the same time. I dont know if Im explaining myself correctly.
The main target is to use a sigle keytroke or program to run something and the same to close it.
Thanks por your patience. Embarassed
Back to top
View user's profile Send private message
Mats
Guest





PostPosted: Sat Feb 26, 2005 2:21 pm    Post subject: Reply with quote

Quote:
Still there are some details that would like to solve:[...]

Ok, try to extend your "run"-statement to
Code:
Run, tir2joy.exe, C:\Juegos\IL-2 Sturmovik Forgotten Battles\tir2joy, Hide, PID


and then redefine !F11:: like:
Code:
!F11::
    Process, close, %PID% ; kill your proggy
    ExitApp               ; quit AHK
return


Hope it helps!
(btw.: untested, BUT commented Wink )
Back to top
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 3:15 pm    Post subject: Reply with quote

Umm, it closes AHK but leaves tir2joy alive.

PID? Excuse my ignorance Embarassed
Do you mean I must write PID or the number of the process on the Spy ahk_class #32770?

Writing PID doesnt work. Writing 32770 neither...
Back to top
View user's profile Send private message
Mats
Guest





PostPosted: Sat Feb 26, 2005 3:41 pm    Post subject: Reply with quote

luke97 wrote:
Do you mean I must write PID or the number of the process on the Spy ahk_class #32770?

You have to use %PID% (literal and don't forget the %!)

%PID% is just a variable, that is set by the run command - that's the reason why you had to change the run statement, too (without the percent signs there!)
Back to top
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 3:59 pm    Post subject: Reply with quote

Still, dont work.
The variable PID asociated to the tir2joy run process is not closed when hit the hotkey. Only is closed AHK program.

Embarassed
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Sat Feb 26, 2005 4:13 pm    Post subject: Reply with quote

That's AHK's Process syntax
Quote:
Process, Cmd, PID-or-Name [, Param3]
I would recommend to start tir2joy and use the taskmanager to identify the name it uses (tir2joy.exe ?). Afterwards use it within that command. Done.
Back to top
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 5:28 pm    Post subject: Reply with quote

Tnx Bobo, I think I have it:

Code:

Run, tir2joy.exe, C:\Juegos\IL-2 Sturmovik Forgotten Battles\tir2joy, Hide, tir2joy ;  I think this is right

!F11:: ; ALT+F11 to close both programs
Process, Close, tir2joy.exe ; kill your proggy
ExitApp               ; quit AHK
return



If you find that any improvement could be done, please, tell me.
Back to top
View user's profile Send private message
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Sat Feb 26, 2005 5:46 pm    Post subject: Reply with quote

I just have to insert my two cents here....

BoBo's style of "Support" is certainly interesting.

1) The default of SetTitleMatchMode is 1, not 3.
2) The auto-execute section is not every snippet of "hanging code," it's a very specific section at the start which is basically a label without a label. It must come at the start, and when it encounters a return it will terminate. Period.
3) The forcefulness with which you enforced your slightly error-ridden views is kinda funny. Laughing

P.S. Another note on auto-execute; if it has no return, it will continue executing right into the next label, so make sure you "return" after you're done with it!

Edit: This post was jokingly burning BoBo, not Luke. Sorry for the confusion.


Last edited by jonny on Sat Feb 26, 2005 8:20 pm; edited 2 times in total
Back to top
View user's profile Send private message
luke97



Joined: 26 Feb 2005
Posts: 14

PostPosted: Sat Feb 26, 2005 8:02 pm    Post subject: Reply with quote

Jonny, I think you posted on the wrong thread.. I havent understood anything youve posted... Shocked
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 8:14 pm    Post subject: Reply with quote

ranomore wrote:
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.

mats wrote:
Just a wild guess:
Have you tried to put the hotkey definitions at the very end of the script? As far as i know, ahk auto-executes your script till it sees the first "return". So in this case, it executes the "run" and the first hotkey (!F9 - as if it has been triggered) and then stops, waiting only for the hotkeys to be pressed.

Myself, Mats, and Jonny are all trying to tell you about the autoexecute section. It's in the manual.
Jonny is in exactly the right place. You're whole problem could have been solved a lot faster by actually going to the link I gave you 10 hours ago, RTFM, and then trying a little harder to think through the process.

and besides, I think he was commenting more on Bobo than on you.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page Previous  1, 2, 3  Next
Page 2 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