forked from camerb/AHKs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FcnLib-Opera.ahk
60 lines (54 loc) · 1.44 KB
/
FcnLib-Opera.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include FcnLib.ahk
RunOpera()
{
oldPath=C:\Program Files\Opera\opera.exe
newPath=C:\Program Files (x86)\Opera\opera.exe
if FileExist(oldPath)
Run, %oldPath%
else if FileExist(newPath)
Run, %newPath%
ForceWinFocus("ahk_class (OperaWindowClass|OpWindow)", "RegEx")
}
CloseAllTabs()
{
ForceWinFocus("ahk_class (OperaWindowClass|OpWindow)", "RegEx")
Send, ^w
Sleep, 100
while (WinGetActiveTitle() != "Speed Dial - Opera")
{
Send, ^w
Sleep, 100
}
if (WinGetActiveTitle() == "Downloads - Opera")
Send, ^w
}
GoToPage(url)
{
ForceWinFocus("ahk_class (OperaWindowClass|OpWindow)", "RegEx")
Send, !d
Sleep, 100
Send, %url%
oldTitle:=WinGetActiveTitle()
Send, {ENTER}
WinWaitActiveTitleChange(oldTitle)
;ShortSleep()
Sleep, 500
;TODO change this back to a long sleep if that broke anything
}
;Wait until the title of the active window changes
;(note that changing to another window sets it off, too)
WinWaitActiveTitleChange(oldTitle="")
{
;if they didn't give a title, try to grab the title as quickly as possible
;this is less reliable, but if we don't have the title, we'll just do the best we can
if (oldTitle == "")
WinGetActiveTitle, oldTitle
;loop until the window title changes
Loop
{
WinGetActiveTitle, newTitle
if (oldTitle != newTitle)
break
Sleep, 100
}
}