AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: July 4th, 2009, 4:38 am 
Offline

Joined: July 2nd, 2009, 6:54 am
Posts: 9
I'm trying to make a simple hotkey to control a program called ClipX with a Win-RightClick hotkey combination.

I've been having problems getting it just right.

What I want it to do is this:
Remap Win-RightClick to the following actions--
If Clipx is open, send Win-Insert (default hotkey to open ClipX pasting menu)
Otherwise, open ClipX and THEN send Win-Insert.

This is the Window info for ClipX
CLIPX_MAIN
ahk_class CLIPX_CLASS

I've tried the following:


Code:
#RButton::
IfWinNotActive, CLIPX_MAIN
   Send, #{Ins}
Else
   Run, C:\Program Files\ClipX\clipx.exe
Return


That opens the menu properly, but doesn't open ClipX if it's not already opened.

Code:
#RButton::
IfWinNotExist, CLIPX_MAIN
   Run, C:\Program Files\ClipX\clipx.exe
Else
   Send, #{Ins}
Return


This opens ClipX if it's not open, but rather than opening the preferred menu of ClipX for pasting, it opens the Settings Menu when I use the Win-RightClick hotkey.

Surely there must be something I'm missing?


Last edited by supulton on July 4th, 2009, 12:00 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 4th, 2009, 7:42 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Try this and see what you get:

Code:
#RButton::
IfWinNotExist, CLIPX_MAIN
{
  Run, C:\Program Files\ClipX\clipx.exe, , UseErrorLevel
  if !ErrorLevel ; if ErrorLevel is empty or zero, meaning program launched successfully
    Send, #{INS}
}
else if !WinActive("CLIPX_MAIN") ; if window is not active
  Send, #{INS}
Return

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 4th, 2009, 8:58 am 
Offline

Joined: July 2nd, 2009, 6:54 am
Posts: 9
sinkfaze wrote:
Try this and see what you get:

Code:
#RButton::
IfWinNotExist, CLIPX_MAIN
{
  Run, C:\Program Files\ClipX\clipx.exe, , UseErrorLevel
  if !ErrorLevel ; if ErrorLevel is empty or zero, meaning program launched successfully
    Send, #{INS}
}
else if !WinActive("CLIPX_MAIN") ; if window is not active
  Send, #{INS}
Return


I tried the code, but it went buggy when it launched so I tried a sleep—

Code:
#RButton::
IfWinNotExist, CLIPX_MAIN
{
  Run, C:\Program Files\ClipX\clipx.exe, , UseErrorLevel
  if !ErrorLevel ; if ErrorLevel is empty or zero, meaning program launched successfully
   Sleep, 500
    SendInput, #{INS}
}
else if !WinActive("CLIPX_MAIN") ; if window is not active
   Send, #{INS}
Return


and when ClipX launched, it appropriately opened the menu. But a second Win-RightClick just opened up the configuration again (strange!).

I've experimented with the following window classes in ClipX but to no avail.

Configuration menu:
ClipX - Configuration
ahk_class #32770

Popup menu:
CLIPX_MAIN
ahk_class CLIPX_CLASS

Strangely, when I reverted to my old method—

Code:
#RButton::#Ins


It brought up just the desired popup without a hitch. So I assume that the problem is window control issues? I'm not sure how one would suppress the ClipX configuration window (or why it pops up in the first place).

Thanks for the hand, though


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2009, 12:00 pm 
Offline

Joined: July 2nd, 2009, 6:54 am
Posts: 9
I think I finally got it right.

Instead of dealing with the ActiveWindow (it wasn't working with ClipX), I used the ClipX process.

Code:
#RButton::
Process, Exist, clipx.exe ; Sets ErrorLevel to the Process ID (PID)
if (ErrorLevel) ; if a matching process exists
{
    Send, #{INS}
}
Else ; if ErrorLevel is 0
{
    Run, C:\Program Files\ClipX\clipx.exe   
    Sleep, 500
    SendInput, #{INS}
}
Return


And it works fine now. :)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Exabot [Bot], krajan, patgenn123 and 60 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