AutoHotkey Community

It is currently May 27th, 2012, 8:48 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: November 12th, 2005, 7:01 am 
Offline

Joined: November 6th, 2005, 5:25 am
Posts: 182
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:
Code:
;
; 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...


Last edited by Harmor on July 15th, 2006, 3:32 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 15th, 2006, 3:30 pm 
Offline

Joined: November 6th, 2005, 5:25 am
Posts: 182
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...


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 16th, 2006, 8:19 am 
Offline
User avatar

Joined: December 20th, 2004, 12:19 pm
Posts: 798
Location: LooseChange911.com Ask Questions, Demand Answers █ The WTC bldgs █ shouldn't have fallen █ that fast
I can't test this, but it looks cleaner (if you remove all the comments)...

Code:
#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

_________________
AutoHotkey-Hotstring.ahk - Helping the world spell "AutoHotkey" correctly! (btw, it's a lowercase k!)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: tomoe_uehara, Xx7 and 9 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