topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday April 20, 2024, 5:45 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Display FARR Near Pointer  (Read 3353 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Display FARR Near Pointer
« on: December 07, 2011, 02:54 AM »
The following AHK_L script should display FARR's main window and then move it close to the pointer.  I use this when there's something near the pointer I want to drop in FARR's main window (reduce dragging distance and hence risk of mis-drop).

May want to tweak the full path to FARR's exe (see FarrFullPath in code) and/or the hotkey (see KeySequence in code).

Tested on XP SP3 and 7 Pro SP1.

promotion
The script may end up as part of Nea.


Code: Autohotkey [Select]
  1.  
  2. ; change this as desired
  3. KeySequence := "^+p"
  4.  
  5. ; XXX: may need to change this
  6. FarrFullPath := A_ProgramFiles . "\FindAndRunRobot\FindAndRunRobot.exe"
  7.  
  8. CoordMode, Mouse, Screen
  9.  
  10. ShowFARRAtPointer()
  11. {
  12.   global FarrFullPath
  13.   SplitPath, FarrFullPath, FarrExe
  14.   Process, Exist, % FarrExe
  15.   If (ErrorLevel != 0) ; yes FARR
  16.   {
  17.     MouseGetPos, X, Y
  18.     Run, % FarrFullPath . " -show"
  19.     WinWaitActive, % "Find and Run Robot 2 ahk_class TMainForm"
  20.     If (ErrorLevel == 1)
  21.     {
  22.       OutputDebug, % "WinWaitActive timed out waiting for FARR"
  23.       Return
  24.     }
  25.     ; XXX: will this work for multi-display set-ups?
  26.     WinMove, % "Find and Run Robot 2 ahk_class TMainForm", , % X, % Y
  27.   }
  28.   Else ; no FARR
  29.   {
  30.     ; OK/Cancel - esc dismisses dialog
  31.     MsgBox, 1, % "Did Not Find Running FARR"
  32.           , % "FARR doesn't seem to be running.`n`nOk to start FARR?"
  33.     IfMsgBox, OK
  34.     {
  35.       Run, % FarrFullPath
  36.     }
  37.   }
  38.   Return
  39. }
  40.  
  41. Hotkey, % KeySequence, DoShowFARRAtPointer
  42.  
  43. Return
  44.  
  45. DoShowFARRAtPointer:
  46. {
  47.   ShowFARRAtPointer()
  48.   Return
  49. }

Updated: as per Nod5's suggestion to use A_ProgramFiles
« Last Edit: December 07, 2011, 05:19 PM by ewemoa »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,901
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Display FARR Near Pointer
« Reply #1 on: December 07, 2011, 06:55 AM »
neat.  :up:

Nod5

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: Display FARR Near Pointer
« Reply #2 on: December 07, 2011, 11:28 AM »
nice  :up:

Tip: Autohotkey's variable A_ProgramFiles makes the default script compatible with different localized paths for the program files folder.
FarrFullPath = %A_ProgramFiles%\FindAndRunRobot\FindAndRunRobot.exe
edit: I made a mistake in the code above (had both qoutes and %'s), fixed now.
« Last Edit: December 07, 2011, 05:22 PM by Nod5 »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: Display FARR Near Pointer
« Reply #3 on: December 07, 2011, 05:17 PM »
Thanks a lot for the tip, Nod5  :)

Think I'll update the original post.