-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(win32-api): user32.FlashWindow()
- Loading branch information
1 parent
c04b7af
commit a0b1903
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import assert from 'node:assert/strict' | ||
import { spawn } from 'node:child_process' | ||
|
||
import { fileShortPath } from '@waiting/shared-core' | ||
import ref from 'ref-napi' | ||
import { sleep } from 'zx' | ||
|
||
// import * as CS from '../../src/index.consts.js' | ||
import { | ||
DModel as M, | ||
DTypes as W, | ||
DStruct as DS, | ||
StructFactory, | ||
} from '../../src/index.js' | ||
import { calcLpszClassNotepad } from '../config.unittest.js' | ||
import { user32, destroyWin } from '../helper.js' | ||
|
||
|
||
describe(fileShortPath(import.meta.url), () => { | ||
|
||
describe.only('Should FlashWindow() work', () => { | ||
it('true', async () => { | ||
const child = spawn('notepad.exe') | ||
await sleep(1000) | ||
|
||
const hWnd = await user32.FindWindowExW(0, 0, calcLpszClassNotepad, null) | ||
assert((typeof hWnd === 'string' && hWnd.length > 0) || hWnd > 0) | ||
|
||
const state = await user32.FlashWindow(hWnd, 1) | ||
assert(state > 0) | ||
await sleep(100) | ||
const state2 = await user32.FlashWindow(hWnd, 0) | ||
assert(state2 === 0, state2.toString()) | ||
|
||
// await sleep(10000) | ||
await destroyWin(hWnd) | ||
child.kill() | ||
}) | ||
|
||
it('false', async () => { | ||
const child = spawn('notepad.exe') | ||
await sleep(1000) | ||
|
||
const hWnd = await user32.FindWindowExW(0, 0, calcLpszClassNotepad, null) | ||
assert((typeof hWnd === 'string' && hWnd.length > 0) || hWnd > 0) | ||
|
||
const state = await user32.FlashWindow(hWnd, 0) | ||
assert(state > 0) | ||
|
||
// await sleep(10000) | ||
await destroyWin(hWnd) | ||
child.kill() | ||
}) | ||
|
||
}) | ||
}) | ||
|