Search found 23 matches

by escape75
Wed Jan 21, 2026 12:15 am
Forum: Coding Questions
Topic: WebViewGadget question ...
Replies: 1
Views: 153

WebViewGadget question ...

Can WebViewExecuteScript be called right after adding WebViewGadget,
or do we have to use BindWebViewCallback with DOMContentLoaded first?

:)
by escape75
Sun Jan 18, 2026 10:36 pm
Forum: Coding Questions
Topic: Enable Windows Sleep while playing sound?!
Replies: 3
Views: 254

Re: Enable Windows Sleep while playing sound?!

Thanks for the tips ... I was more interested in having the program not prevent regular scheduled sleep states,
however I believe the issue is not with PB but my Realtek driver, when sound plays it keeps a request open:

powercfg -requests

SYSTEM:
[DRIVER] Realtek High Definition Audio
An audio ...
by escape75
Sat Jan 17, 2026 10:33 pm
Forum: Coding Questions
Topic: Enable Windows Sleep while playing sound?!
Replies: 3
Views: 254

Enable Windows Sleep while playing sound?!

Consider the following code that plays a sound with a timer, the sound is just a bit shorter than the timer ... almost a loop ...

This seems to prevent windows from going to sleep, and I was wondering if anyone would have a solution to this ..



InitSound()
UseOGGSoundDecoder()

OpenWindow(1, 200 ...
by escape75
Thu Jan 15, 2026 4:24 am
Forum: Coding Questions
Topic: Possibly a bug - maybe it's by design?
Replies: 0
Views: 233

Possibly a bug - maybe it's by design?

Consider the following code,- it seems to prevent Windows from going to sleep:



EnableExplicit

Enumeration 100
#Window
#WebView
EndEnumeration

OpenWindow(#Window, 100, 100, 400, 200, "Test", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
WebViewGadget(#WebView, 0, 0, 400, 200 ...
by escape75
Wed Jan 14, 2026 9:13 pm
Forum: Coding Questions
Topic: PlaySound with a 20KHz file produces sound ?!
Replies: 29
Views: 1177

Re: PlaySound with a 20KHz file produces sound ?!

Ok that makes sense, although I've noticed that when you FreeMemory it just overwrites a few bytes at the beginning of the buffer
and you can actually make a second call to CatchSound afterwards and it will still play correctly as just the text strings are corrupted ...

This makes it hard to test ...
by escape75
Tue Jan 13, 2026 6:13 pm
Forum: Coding Questions
Topic: PlaySound with a 20KHz file produces sound ?!
Replies: 29
Views: 1177

Re: PlaySound with a 20KHz file produces sound ?!

Great, I was fixing it in a similar way but yours is a bit cleaner :)

Couple questions ...

Would memory de-allocate here cause any issues:

CatchSound(Sound, *WAVBuffer)
FreeMemory(*WAVBuffer)

I was thinking make it a global at the start of the program and don't free until program exit ...
by escape75
Tue Jan 13, 2026 5:08 pm
Forum: Coding Questions
Topic: Detect Desktop after Resume from Sleep ...
Replies: 7
Views: 366

Re: Detect Desktop after Resume from Sleep ...

Mine is similar code, and I only tested with a local admin account as that's what I've got setup:



EnableExplicit

Enumeration 100
#Window
EndEnumeration

#NOTIFY_FOR_THIS_SESSION = 0
#WM_WTSSESSION_CHANGE = $02B1
#WTS_SESSION_UNLOCK = $8

Import "wtsapi32.lib"
WTSRegisterSessionNotification ...
by escape75
Mon Jan 12, 2026 9:27 pm
Forum: Coding Questions
Topic: Detect Desktop after Resume from Sleep ...
Replies: 7
Views: 366

Re: Detect Desktop after Resume from Sleep ...

I don't think it would help but I think I have found a solution via #WM_WTSSESSION_CHANGE & #WTS_SESSION_UNLOCK

Thanks!
by escape75
Mon Jan 12, 2026 5:45 am
Forum: Coding Questions
Topic: PlaySound with a 20KHz file produces sound ?!
Replies: 29
Views: 1177

Re: PlaySound with a 20KHz file produces sound ?!

Ok perfect, that's what I have ...

Unfortnately I located another bug, with 24 bit generation, the 2 channels have different data, and playback is scrambled ... hmm!
by escape75
Mon Jan 12, 2026 12:43 am
Forum: Coding Questions
Topic: PlaySound with a 20KHz file produces sound ?!
Replies: 29
Views: 1177

Re: PlaySound with a 20KHz file produces sound ?!

I have made the following changes, maybe someone can double check if this was a correct fix:

From

Code: Select all

Time = Sample / SamplingRate * 8
Tone = Sin(Time * Frequency) * 32767 * Volume
To

Code: Select all

Tone = Sin(2 * #PI * Frequency * Sample / SamplingRate) * 32767 * Volume
by escape75
Mon Jan 12, 2026 12:29 am
Forum: Coding Questions
Topic: PlaySound with a 20KHz file produces sound ?!
Replies: 29
Views: 1177

Re: PlaySound with a 20KHz file produces sound ?!

I found an issue after analyzing the wave file and it seems the center frequency is 25460hz instead of 20000hz

I suspect the bug is around here somewhere:

Time = Sample / SamplingRate * 8
Tone = Sin(Time * Frequency) * 32767 * Volume


The complete code with wave output, the program should be ...
by escape75
Sun Jan 11, 2026 11:17 pm
Forum: Coding Questions
Topic: Detect Desktop after Resume from Sleep ...
Replies: 7
Views: 366

Re: Detect Desktop after Resume from Sleep ...

I have tried it, but it only works when Windows restarts, as when it goes to sleep while logged in, the taskbar is already loaded :(
by escape75
Sun Jan 11, 2026 10:02 pm
Forum: Coding Questions
Topic: PlaySound with a 20KHz file produces sound ?!
Replies: 29
Views: 1177

Re: PlaySound with a 20KHz file produces sound ?!

I think it's safe to say the code works :)
by escape75
Sun Jan 11, 2026 9:43 pm
Forum: Coding Questions
Topic: PlaySound with a 20KHz file produces sound ?!
Replies: 29
Views: 1177

Re: PlaySound with a 20KHz file produces sound ?!

Sometimes it helps for someone else to glance over the code to spot a mistake :)

I found out some clicks are caused by volume starting at 100% even though the sound should not be heard there's a click when beginning and ending playback ...

EDIT:

The For Next loop you specified was the same as ...
by escape75
Sun Jan 11, 2026 9:23 pm
Forum: Coding Questions
Topic: Detect Desktop after Resume from Sleep ...
Replies: 7
Views: 366

Detect Desktop after Resume from Sleep ...

Does anyone know how to easily detect when the Desktop is loaded after a wake up event ?

It seems the following code resumes while on the lock screen and certain Windows actions are not yet availabe until the user unlocks and goes into a Desktop session ?



Enumeration 100
#Window
#Timer ...