problems with ifwinactive on several windows

Get help with using AutoHotkey and its commands and hotkeys
Yugo
Posts: 24
Joined: 01 Mar 2018, 05:20

problems with ifwinactive on several windows

05 Mar 2018, 05:00

hi, i have a little problem to understand why the script below did not work propably. i know i can use #ifwinactive instead, but i rather would like to stay with the if else condition. thanks for your time

Code: Select all

NumpadPgDn::
If WinActive ("ahk_class MozillaWindowClass")
{
    ;_________________voclist
    clipboard :=  ""
    send ^c
    sleep 50
    clipwait, 1
    voc2 := clipboard
    FileAppend, %voc1%`t%voc2%`n, %A_ScriptDir%\%ibox1%.txt, UTF-8 ;default voclist.txt, fileappend macht keinen NEUEN Ordner, wenn dieser nicht bereits existiert!
    ;____________________________
    ;> seite wiederherst./tab löschen + zurück zum potpalyer
    Send ^0 ;normalgröße in ff
    Send ^w ; schließt letzten tab
    Process, Exist, potplayermini64.exe
    WinActivate, ahk_pid %ErrorLevel%
    MouseMove, 500, 500
    return
}
else If WinActive ("hk_class PotPlayer64")
{
msgbox, im palyer
return
}

as mantioned do not see a issue in here :?:
Johana
Posts: 189
Joined: 02 May 2017, 02:34

Re: problems with ifwinactive on several windows

05 Mar 2018, 05:07

What excatly isn't working?
GEV
Posts: 844
Joined: 25 Feb 2014, 00:50

Re: problems with ifwinactive on several windows

05 Mar 2018, 05:28

Where do you get the values for the variables "voc1" and "ibox1" from?

Code: Select all

NumpadPgDn::
If WinActive("ahk_class MozillaWindowClass")
{
    ;_________________voclist
    clipboard :=  ""
    send ^c
    sleep 50
    clipwait, 1
    voc2 := clipboard	
    FileAppend, %voc1%`t%voc2%`n, %A_ScriptDir%\%ibox1%.txt, UTF-8 ;default voclist.txt, fileappend macht keinen NEUEN Ordner, wenn dieser nicht bereits existiert!
    ;____________________________
    ;> seite wiederherst./tab löschen + zurück zum potpalyer
    Send ^0 ;normalgröße in ff
    Send ^w ; schließt letzten tab
    Process, Exist, potplayermini64.exe
    If !(ErrorLevel)  	; is running
    {
		WinActivate, ahk_pid %ErrorLevel%
		WinWaitActive, ahk_pid %ErrorLevel%
		MouseMove, 500, 500
    }
}
else If WinActive ("ahk_class PotPlayer64")
	msgbox, im player
return
Yugo
Posts: 24
Joined: 01 Mar 2018, 05:20

Re: problems with ifwinactive on several windows

05 Mar 2018, 05:53

voc 1 also an "clipboard var", ibox1 is declarated as an inputbox for changing the name of the file further below the script
GEV
Posts: 844
Joined: 25 Feb 2014, 00:50

Re: problems with ifwinactive on several windows

05 Mar 2018, 06:03

Without seeing the way you get those values, I cannnot say what's wrong.
Yugo
Posts: 24
Joined: 01 Mar 2018, 05:20

Re: problems with ifwinactive on several windows

05 Mar 2018, 06:24

Code: Select all

#if WinActive("ahk_class PotPlayer64")
~LButton::
WinWaitActive, ahk_class MozillaWindowClass
sleep,1000
    Loop, 6 		;6x > 200% zoom
    {
	Send, ^{+}
    }
;_______ vocliste________
clipboard := "" 
send ^c
sleep 50 ; <---  this could prevent possible issues
clipwait, 1 ; <------ prevents infinite wait time
voc1 := clipboard
;_________________________

Send {Right}
Send *
Send {Tab} ;obere 3z für > markierung/liste raus aus eingabefeld von dict.cc
FileAppend, %voc1%`n, %A_ScriptDir%\%ibox1% - oe.txt ;moegl. nur eng vocs zu tracken
#IfWinActive
   
    LOOP{
	SetTitleMatchMode,2
    	If WinActive("Deutsch-Englisch")
    	{
;Send ^+{Escape}
Gosub, back2pot 
break
} 
 }
return

back2pot:
SetTitleMatchMode,2
If WinActive("Deutsch-Englisch")
clipboard :=  ""
send ^c
sleep 50
clipwait, 1
voc2 := clipboard
FileAppend, %voc1%`t%voc2%`n, %A_ScriptDir%\%ibox1%.txt, UTF-8
;____________________________
;> seite wiederherst./tab löschen + zurück zum potpalyer
Send ^0 ;normalgröße in ff
Send ^w ; schließt letzten tab
Process, Exist, potplayermini64.exe
WinActivate, ahk_pid %ErrorLevel%
MouseMove, 500, 500
return

NumpadDel::
;If WinActive ("ahk_class MozillaWindowClass")
;{

#if WinActive("ahk_class MozillaWindowClass")

;wenn player/fenster aktiv dann hk "sperren" > sonst kackt ab wenn auversehen im player gedruckt!
; > eerkennen von innen/außen, local/global keys

    Loop, 6 		;6x > 200% zoom
    {
	Send, ^{+}
    }
;_______ vocliste________
clipboard := "" 
send ^c
sleep 50 ; <---  this could prevent possible issues
clipwait, 1 ; <------ prevents infinite wait time
voc1 := clipboard
;_________________________

Send {Right}
Send *
Send {Tab} ;obere 3z für > markierung/liste raus aus eingabefeld von dict.cc
FileAppend, %voc1%`n, %A_ScriptDir%\%ibox1% - oe.txt ;moegl. nur eng vocs zu tracken
return
#IfWinActive

    
;}
;else If WinActive ("hk_class PotPlayer64")
;{

#if WinActive("ahk_class PotPlayer64")

msgbox, im palyer
return
#IfWinActive
;}


NumpadPgDn::
#IfWinActive ("ahk_class MozillaWindowClass")
;If WinActive ("ahk_class MozillaWindowClass")
;{
    ;_________________voclist
    clipboard :=  ""
    send ^c
    sleep 50
    clipwait, 1
    voc2 := clipboard
    FileAppend, %voc1%`t%voc2%`n, %A_ScriptDir%\%ibox1%.txt, UTF-8 ;default voclist.txt, fileappend macht keinen NEUEN Ordner, wenn dieser nicht bereits existiert!
    ;____________________________
    ;> seite wiederherst./tab löschen + zurück zum potpalyer
    Send ^0 ;normalgröße in ff
    Send ^w ; schließt letzten tab
    Process, Exist, potplayermini64.exe
    WinActivate, ahk_pid %ErrorLevel%
    MouseMove, 500, 500
    return
;}
;else If WinActive ("hk_class PotPlayer64")
;{
#if WinActive("ahk_class PotPlayer64")
msgbox, im palyer
return
#IfWinActive
;}




^o::
InputBox, ibox1, voclist, Dateinamen eingeben:,,w,128,x,y,,,voclist
return

^i::
InputBox, ibox2, phraser, enter word/phrase:,,w,128,x,y,,,
clipboard :=  ""
Clipboard := ibox2
sleep 50
clipwait, 1
run, https://www.dict.cc/?s=%ibox2%

;clipboard danach cleanen/restoren?
return

i tried now the #ifwinactive statement, but it either not work!

Return to “Ask For Help”

Who is online

Users browsing this forum: anv, Bing [Bot], effel, JAutohotkey, mikeyww, teadrinker and 48 guests