Hi
Is it possible in ahk to get a message box as soon a website is opened?
Display MsgBox when certain website is opened
Re: Activate hotkeys in specific web page
Something like this? Far from refined, but should get you going.
Code: Select all
#Persistent
#SingleInstance, Force
SetTimer, YouTubeCheck, 500 ; Set in milliseconds
1stRun := true ; Variable to track the first run
Return
YouTubeCheck:
if (1stRun) ; Check if it's the 1st run.
{
if WinExist("ahk_exe firefox.exe") ; Modify the title as needed.
{
WinGetTitle, activeTitle, A
If (InStr(activeTitle, "YouTube")) ; Modify condition as needed.
{
SoundBeep, 1900, 750
MsgBox, YouTube Detected
1stRun := false ; Set the 1stRun variable to false after the first run.
SetTimer, YouTubeCheck, Off ; Turn timer Off to stop repeating once found.
}
}
}
Return
Re: Display MsgBox when certain website is opened
@Zubarm -- Your post and the reply have been split off to its own thread. Please don't add on to threads that aren't really related with a new question. Create a new thread if your question isn't directly addressing the thread you're thinking of posting in. (The thread you posted in was about making hotkeys active when certain web pages are active.)
Re: Display MsgBox when certain website is opened
@RDC thank you , your script , old idea , show again when youtube title is active
Code: Select all
#Warn
#Persistent
#SingleInstance, Force
SetTimer,YouTubeCheck, 500 ;- Set in milliseconds
i:=0
Return
;------------
YouTubeCheck:
{
if WinExist("ahk_exe chrome.exe") ;- Modify browser as needed.
{
WinGetTitle, activeTitle, A
if activetitle not contains YouTube
i=0
If (InStr(activeTitle, "YouTube")) ;- Modify title as needed.
{
if (i=0)
{
SoundBeep, 1900, 750
msgbox, 262208,FOUND YT ,YouTube Detected,2 ;- msgbox alwaysontop for 2 seconds
i=1
}
}
}
}
Return
;--------------------
esc::exitapp
;====================
Re: Display MsgBox when certain website is opened
Many thanks @garry, I had gotten assistance already from @flyingDman in another thread. It's pretty sleek too. And thanks for adding the ExitApp. I usually don't worry about adding that in the forums simply because my exit routine is a bit lengthy. Full script with flyingDman's input...
Code: Select all
/*
Refresh Script … … Ctrl + HOME key rapidly clicked 2 times.
Exit Script … … … … Ctrl + Escape key rapidly clicked 3 times.
- Script Updater: Auto-reload script upon saved changes.
If you make any changes to the script file and save it, the script will automatically reload itself and continue running without manual intervention.
*/
; ==================================================
; ================= Auto-Execute ===================
; ==================================================
#SingleInstance, Force
#Persistent
SetBatchLines -1
DetectHiddenWindows, On
SetTimer, UpdateCheck, 500 ; Checks for script changes every 1/2 second. (Script Updater)
SetKeyDelay, 250 ; Sets the TapCount allowed delay time (milliseconds) for script Exit. (tied to Reload/Exit routine)
; Menu, Tray, Icon, wmploc.dll, 99 ; Local White Star tray Icon.
; ===================================================
; =============== Auto-Execute End ==================
; ===================================================
/*
; … … … … HOTKEY-TRIGGER … … … … … … … … …
^T:: ; … … (Ctrl + T)
Gosub, IndicateDot1
Gui, Color, LIME ; <<<<-----IndicateDot Color.
Gosub, IndicateDot2
; … … … … … … … … … … … … … … … … … … … …
*/
; ===================================================
; ================= Script Coding =====================
; ===================================================
SetTitleMatchMode, 2 ; 1=startswith, 2=anywhere, 3=exact
Loop
{
WinWaitActive YouTube — Mozilla Firefox
SoundBeep, 1500, 250 ; Do something once
Gui,
+AlwaysOnTop
-Caption
+Owner
Gui, Color, 010B43
Gui, Margin, 15, 15
Gui, Font, s17 w600 cYELLOW q5
Gui, Add, Text, CENTER, Website`nDetected
Gui, Show
Sleep, 3000
Soundbeep, 1500, 75
Gui, Destroy
WinWaitNotActive YouTube — Mozilla Firefox
}
; ===================================================
; =============== Reload/Exit Routine ===============
; ===================================================
RETURN
; … … … … RELOAD SCRIPT … … … … … … … … … …
^Home:: ; … … [Home Button]
if (A_TimeSincePriorHotkey > 250)
{
TapCount := 1
KeyWait, Esc
} else {
TapCount++
if (TapCount = 2) ; <<<<---- Set TapCount to # of key taps wanted.
{
Gosub, IndicateDot1
Gui, Color, YELLOW ; <<<<-----IndicateDot Color.
Gosub, IndicateDot2
Reload
} else {
KeyWait, Esc
}
}
Return
; … … … … EXIT SCRIPT … … … … … … … … … … …
^Esc:: ; … … Ctrl + ((Esc) times (# of TapCounts))
if (A_TimeSincePriorHotkey > 250)
{
TapCount := 1
KeyWait, Esc
} else {
TapCount++
if (TapCount = 3) ; <<<<---- Set TapCount to # of key taps wanted.
{
Gosub, IndicateDot1
Gui, Color, RED ; <<<<-----IndicateDot Color.
Gosub, IndicateDot2
Gui, Destroy
ExitApp
} else {
KeyWait, Esc
}
}
Return
; … … … … Script Updater … … … … … … … … … …
UpdateCheck: ; Check if the script file has been modified.
oldModTime := currentModTime
FileGetTime, currentModTime, %A_ScriptFullPath%
; … … … … If the modification timestamp has changed, reload the script.
if (oldModTime = currentModTime) Or (oldModTime = "")
Return
Gosub, IndicateDot1
Gui, Color, BLUE ; <<<<-----IndicateDot Color.
Gosub, IndicateDot2
Reload
; … … … … SCRIPT GoSubs … … … … … … … … … …
IndicateDot1:
Gui, Destroy
SysGet, MonitorWorkArea, MonitorWorkArea
SysGet, TaskbarPos, 4
Gui, +AlwaysOnTop -Caption +hwndHGUI +LastFound
Return
; … … … … … … … … … … … … …
IndicateDot2:
Gui, Margin, 13, 13 ; <<<<-----Dot Size.
Gui, Show, Hide
WinGetPos, , , WinWidth, WinHeight, ahk_id %HGUI%
NewX := MonitorWorkAreaRight - 80
NewY := MonitorWorkAreaBottom - WinHeight - 5
R := Min(WinWidth, WinHeight) // 1 ; <<<<----- Set value of cornering. (0.5=Oval, 0=square, 1= round, 5=rounded corners).
WinSet, Region, 0-0 W%WinWidth% H%WinHeight% R%R%-%R%
Gui, Show, x%NewX% y%NewY%
SoundGet, master_volume
SoundSet, 7
Soundbeep, 2100, 100
SoundSet, % master_volume
Sleep, 500
Gui, Destroy
Return
; … … … … … … … … … … … … … … … … … … … … …
; ===================================================
; ==================== Script End ===================
; ===================================================
Who is online
Users browsing this forum: Bing [Bot], domingo, hiahkforum, mikeyww, Tvlao and 124 guests