Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

BF2: Paste (Ctrl+V) while running BF2


  • Please log in to reply
2 replies to this topic
Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005
Battlefield 2, for some reason, disabled the paste ability. Often you'll want to copy an IP address of a server to connect to and then can't paste it when you Alt+Tab over to BF2 - with this script you can:
;
; AutoHotkey      Version: 1.x
; Language:       English
; Platform:       Win9x/NT
;
#SingleInstance force
;
; Only run this script when BF2 is running in the foreground
;
SetTimer, KeepRunning
return

KeepRunning:

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

;
; Pressing Ctrl+V while BF2 is active
;
$^v::
   Sleep 200
   SetKeyDelay, 40
   Send, {Space}%clipboard%
   SetKeyDelay, 0
return

For whatever reason I needed to add a Sleep 200 before pasting into BF2 because it was removing the first character in the text it was pasting.

This works great in the server browser.
//TODO: Create kewl sig...

Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005
EDIT: I added a Keydelay of 40 and put {Space} before %clipboard% because it would clip the first character you paste. I use this for pasting text for the IP address and in-game now.
//TODO: Create kewl sig...

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004
I can't test this, but it looks cleaner (if you remove all the comments)...

#SingleInstance force
SetKeyDelay, 40
SetTimer, WatchBF2
return

WatchBF2:
SetTimer, WatchBF2, Off
Loop
{
	; Get the process name of the active window (i.e. notepad.exe)
	WinExist("a")
	;WinGet, id, id
	WinGet, pn, ProcessName
	if pn=bf2.exe
		Suspend, off
	else Suspend, on
	WinWaitNotActive
}
return

;//really need the hook?...it don't "send itself"...
;//$^v::

^v::
Sleep, 219

;//you should set this in the auto-execute section, if this is the only thing this script does...
;//SetKeyDelay, 40

;//SendRaw ensures no surprises on the clipboard...
SendRaw, %clipboard%

;//use %A_Space% if you still need a space...
;//SendRaw, %A_Space%%clipboard%

;//at the very least, you don't need to undo the change, since this is a sub-routine...
;//SetKeyDelay, 0
return

Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?