Need little help with "WinActivate" (or something similar..)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Peter2
Posts: 325
Joined: 21 Sep 2014, 14:38
Location: CH

Need little help with "WinActivate" (or something similar..)

24 Sep 2018, 08:47

Hi

I have a small and simple code which works fine. It ...

1) checks if UltraEdit is active
2) if yes, copy the current selection to clipboard
3) check if AutoCAD exits
4) if yes, jump to AutoCAD and paste the clipboard into in

Here is the code:

Code: Select all

; Belegung der Taste "Ctrl+ü".
; Codetest: Markierten Text in Zwischenablage, im AutoCAD Textfenster einfügen und mit Enter auslösen
^ü::
SetTitleMatchMode, 2

IfWinActive, UltraEdit 64-bit
{
    SetTitleMatchMode, 1
    AutoTrim Off  ; Retain any leading and trailing whitespace on the clipboard.
    Clipboard =  ; Must start off blank for detection to work.
    Send ^c
    ClipWait 1
    ifWinExist, AutoCAD-Textfenster
        WinActivate, AutoCAD-Textfenster
    Else
    {
        WinActivate, Autodesk AutoCAD
        Send (textscr){enter}
        Sleep, 100
    ;    msgbox "Fenster fehlt"
    ;    Return
    }
    ifWinExist, AutoCAD-Textfenster
    {
        Send ^V
        sleep, 100
        send {enter}
    }
}
else
TrayTip , clip2acad.ahk, Aufruf vom falschen Programm, 1, 33
return

Now I want to a simple, last step:

5) Jump back to UltraEdit

I tried something with WinActivate and so on, but nothing happens. The cursor keeps active in AutoCAD. What's wrong?

Peter
Peter (AHK Beginner) / Win 10 x64, AHK Version v1.1.33

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Nerafius and 103 guests