M
M
Maxim Mymrin2019-02-12 14:39:33
autohotkey
Maxim Mymrin, 2019-02-12 14:39:33

2 ahk scripts work alone but don't work in one ahk file?

Guys, why is it so, what is wrong in the code?. Scripts work individually, but not in one file
1) Script By f2 copies text and url together

spoiler
; Allow partial titlebar text matches.
SetTitleMatchMode, 2
; Create a window title group to match on for our hotkey.
GroupAdd, myBrowsers, Mozilla Firefox
GroupAdd, myBrowsers, Google Chrome
#IfWinActive, ahk_group myBrowsers
{
F2::
{
; Copy user selection to a variable.
SendInput, ^c
Sleep, 50
myText := Clipboard
Sleep, 100
; Switch to address bar in browser and copy URL to another variable.
SendInput, ^l
Sleep, 100
SendInput, ^c
Sleep, 100
myURL := Clipboard
Sleep, 100
; Format data bits.
;myData := myURL . "`r`n`r`n" . myText ; удалить кавычки и можно сделать чтобы линки были вначале
myData := myText . "`r`n`r`n" . myURL
Sleep, 100
; Put formatted data back onto clipboard.
Clipboard := myData
}
Return
}
#IfWinActive
return

2) Alt + N opens any document in the explorer in the notepad
spoiler
#NoEnv
SetWorkingDir %A_ScriptDir%
GroupAdd, Explore, ahk_class CabinetWClass
GroupAdd, Explore, ahk_class ExploreWClass
#ifWinActive,ahk_group Explore
!sc31::
ClipSaved := ClipboardAll
Clipboard := ""
Send ^c
ClipWait, 0.5
file := Clipboard
Clipboard := ClipSaved
Run C:\Program Files (x86)\Notepad++\notepad++.exe "%file%"
#IfWinActive
return

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Mymrin, 2019-02-13
@reifwp

Suggested the answer, maybe it will help someone

spoiler
;14) По Ф2 Копировать текст выделенный и урл
#NoEnv
SetTitleMatchMode, 2
SetWorkingDir %A_ScriptDir%
GroupAdd, Explore, ahk_class CabinetWClass ; Add a class to the group
GroupAdd, Explore, ahk_class ExploreWClass ; Add a other class to the group
GroupAdd, myBrowsers, Mozilla Firefox
GroupAdd, myBrowsers, Google Chrome
#IfWinActive, ahk_group myBrowsers
{
F2::
{
; Copy user selection to a variable.
clipboard =
SendInput, ^c
Sleep, 50
myText := Clipboard
Sleep, 100
; Switch to address bar in browser and copy URL to another variable.
SendInput, ^l
Sleep, 100
SendInput, ^c
Sleep, 100
myURL := Clipboard
Sleep, 100
; Format data bits.
;myData := myURL . "`r`n`r`n" . myText ; удалить кавычки и можно сделать чтобы линки были вначале
myData := myText . "`r`n`r`n" . myURL
Sleep, 100
; Put formatted data back onto clipboard.
Clipboard := myData
}
Return
}
#IfWinActive
;16)$ Открыть любой файл в проводнике в блокноте по альт+N
; Always on Top CTRL+SPACE on current window
; www.labnol.org/software/tutorials/keep-window-alwa...
^SPACE:: Winset, Alwaysontop, , A
; Open file With Notepad++ from Explorer using Alt+N hotkey
; https://autohotkey.com/board/topic/77665-open-file...
#ifWinActive,ahk_group Explore ; Set hotkeys to work in explorer only
; Alt+N
!sc20::
ClipSaved := ClipboardAll
Clipboard := ""
Send ^c
ClipWait, 0.5
file := Clipboard
Clipboard := ClipSaved
Run C:\Program Files (x86)\Notepad++\notepad++.exe "%file%"
return
#IfWinActive

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question