 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
BF2142Guy Guest
|
Posted: Thu Sep 10, 2009 8:42 pm Post subject: Quick Question! Please look over this short macro! |
|
|
| 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 |
|
|
| Back to top |
|
 |
Carcophan
Joined: 24 Dec 2008 Posts: 1308 Location: :noitacoL
|
Posted: Thu Sep 10, 2009 10:27 pm Post subject: |
|
|
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
|
|
|
| Back to top |
|
 |
AnttiV
Joined: 14 Aug 2009 Posts: 237 Location: Finland
|
Posted: Thu Sep 10, 2009 10:39 pm Post subject: |
|
|
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
EDIT: Also, I thing the winkeys are defined to nil just because accidentally hitting a win-key mid-game can be a frustrating experience  |
|
| Back to top |
|
 |
The Original guy Guest
|
Posted: Sat Sep 12, 2009 12:46 am Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
Original Guy Guest
|
Posted: Sun Sep 13, 2009 3:36 pm Post subject: |
|
|
| Anyone know anything about hotkeys here? Please I need a bit of help |
|
| Back to top |
|
 |
AnttiV
Joined: 14 Aug 2009 Posts: 237 Location: Finland
|
Posted: Sun Sep 13, 2009 6:02 pm Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
Original Guy Guest
|
Posted: Mon Sep 14, 2009 12:08 am Post subject: |
|
|
| 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.. |
|
| Back to top |
|
 |
AnttiV
Joined: 14 Aug 2009 Posts: 237 Location: Finland
|
Posted: Mon Sep 14, 2009 12:28 am Post subject: |
|
|
| Experiment with SetKeyDelay and SendMode, games are known to be picky about timings and such. |
|
| Back to top |
|
 |
OriginGuy Guest
|
Posted: Tue Sep 15, 2009 12:25 am Post subject: |
|
|
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.. |
|
| Back to top |
|
 |
AnttiV
Joined: 14 Aug 2009 Posts: 237 Location: Finland
|
|
| Back to top |
|
 |
OriginGuy Guest
|
Posted: Tue Sep 15, 2009 1:31 am Post subject: |
|
|
Thanks I'll check out the Tuts and try them out.
I appreciate that you are helping me a lot, thanks! |
|
| Back to top |
|
 |
Original Guy Guest
|
Posted: Sat Sep 19, 2009 12:24 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
AnttiV
Joined: 14 Aug 2009 Posts: 237 Location: Finland
|
Posted: Sat Sep 19, 2009 12:38 pm Post subject: |
|
|
Try
| Code: | SendMode Input
SetKeyDelay, 50, 50 |
At the top of the script. |
|
| 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
|