AutoHotkey Community

It is currently May 26th, 2012, 10:35 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: September 10th, 2009, 9:42 pm 
Code:
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook


SetTimer, KeepRunning
return

KeepRunning:

  ; Get the process name of the active window (i.e. Notepad.exe)
  WinGet, szProcessName, ProcessName, A
  if szProcessName = BF2142.exe
  {
    Suspend, off
  }
  else
  {
    Suspend, on
  }
return

;
; Disable the Window's keys so they don't switch to desktop while in-game
;
$LWin::   ; Left Windows Button
$RWin::   ; Right Windows Button
   ; Do nothing
return

ThrowC4andExplode()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 500
   MouseClick, Left, , , , , D
   Sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, right, , , , , D
   Sleep 100
   MouseClick, right, , , , , U
   Sleep 200
   MouseClick, left, , , , , D
   Sleep 100
   MouseClick, left, , , , , U
}
return

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

SwitchThenDetonate()
{
   MouseClick, Right , , , , , D
   Sleep 100
   MouseClick, Right , , , , , U
   Sleep 300   ;The wait for the switch sequence of detonator.
   MouseClick, Left, , , , , D
   Sleep 100
   MouseClick, Left, , , , , U
}
return

F13::ThrowC4andExplode()
F14::SwitchThenDetonate()


So this is what I've compiled together, using some codes from the BF Macro Summary Thread.

But the sad part is, that IT DOES NOT WORK!

Can someone kindly help me fix this up? Thank you.


P.S. I don't understand what the following does..
Code:
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook


SetTimer, KeepRunning
return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2009, 11:27 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
You do not have anything that activates the BF game , so you could just be sending blank commands to another window.


The:
Quote:
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook


SetTimer, KeepRunning
return


make it so this script can only have one instance at a time, to avoid mix-ups, and 'installs' the 'drivers' for the KB and Mouse, which pretty much allows KB/Mouse hot keys.

Your SetTimer, is missing a 'delay' after "KeepRunning" so it runs instantly vs after a set duration.


Also:
Code:
$LWin::   ; Left Windows Button
$RWin::   ; Right Windows Button
   ; Do nothing
return
:?:

and:
Code:
;why not
F14::   ;instead of "F14::SwitchThenDetonate()"  :?:
{
   MouseClick, Right , , , , , D
   Sleep 100
   MouseClick, Right , , , , , U
   Sleep 300   ;The wait for the switch sequence of detonator.
   MouseClick, Left, , , , , D
   Sleep 100
   MouseClick, Left, , , , , U
}
return







Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2009, 11:39 pm 
Offline

Joined: August 14th, 2009, 2:40 pm
Posts: 237
Location: Finland
I'd have done it with functions also, leaves you better room to re-use code with different keys. I'm against specifying commands directly to a hotkey if you can write a function of it :)

yes, I like functions :P

EDIT: Also, I thing the winkeys are defined to nil just because accidentally hitting a win-key mid-game can be a frustrating experience :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 12th, 2009, 1:46 am 
Carcophan wrote:
You do not have anything that activates the BF game , so you could just be sending blank commands to another window.


So what should I add? But the BF game is activated by me..

What should I add in as delay? Just the sleep syntax or does the "delay" syntax exist too? Then how much delay?

yeah, I just like to re-organize them like that.. So I can switch around the keys that are binded to them..

I'm really new and have no idea.. Can someone rewrite it so that it should work?

Thanks,
Jason


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2009, 4:36 pm 
Anyone know anything about hotkeys here? Please I need a bit of help


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2009, 7:02 pm 
Offline

Joined: August 14th, 2009, 2:40 pm
Posts: 237
Location: Finland
I don't understand the usage of the timer here. What is it's purpose?

I mean, why not just:

Code:
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook

; define the two functions here

return

#IfWinActive, What ever isBF's window title.
;
; Disable the Window's keys so they don't switch to desktop while in-game
;
$LWin::   ; Left Windows Button
$RWin::   ; Right Windows Button
   ; Do nothing
return

F13::ThrowC4andExplode()

F14::SwitchThenDetonate()

#IfWinActive


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2009, 1:08 am 
AnttiV wrote:
I don't understand the usage of the timer here. What is it's purpose?

I mean, why not just:

Code:
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook

; define the two functions here

return

#IfWinActive, What ever isBF's window title.
;
; Disable the Window's keys so they don't switch to desktop while in-game
;
$LWin::   ; Left Windows Button
$RWin::   ; Right Windows Button
   ; Do nothing
return

F13::ThrowC4andExplode()

F14::SwitchThenDetonate()

#IfWinActive


I still get NO response from the hotkey! I can't figure out why it's doing nothing..


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2009, 1:28 am 
Offline

Joined: August 14th, 2009, 2:40 pm
Posts: 237
Location: Finland
Experiment with SetKeyDelay and SendMode, games are known to be picky about timings and such.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2009, 1:25 am 
I dont understand the SendMode because I haven't used it yet..

But for the SetKeyDelay, I'm using sleep if that works.

I would experiment with the delay times, but the first click, left click, does not even register into the game! It means that hotkey is not working, period..


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2009, 1:55 am 
Offline

Joined: August 14th, 2009, 2:40 pm
Posts: 237
Location: Finland
No, no. SetKeyDelay is definitely not the same as sleep. With SetKeyDelay, you can define the pause between key presses and the time the key stays pressed. It may be, that the keypress does not register for the simple reason that the game does not have time to notice it.

Thus -> increase the time the key stays pressed and it may work.

http://www.autohotkey.com/docs/commands/SetKeyDelay.htm
http://www.autohotkey.com/docs/commands/SendMode.htm


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2009, 2:31 am 
Thanks :) I'll check out the Tuts and try them out.

I appreciate that you are helping me a lot, thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 19th, 2009, 1:24 pm 
Ok, so i've tried using sendmode and setkeydelay but I think I screwed up on the syntax part... but I don't have enough time to think it over with all the extra curriculars and tutors and lessons and school and sports...
Can someone give me an example of appropriately coded lines into my previous code?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 19th, 2009, 1:38 pm 
Offline

Joined: August 14th, 2009, 2:40 pm
Posts: 237
Location: Finland
Try

Code:
SendMode Input
SetKeyDelay, 50, 50


At the top of the script.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: JSLover, Miguel, rbrtryn and 64 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