More ... | 特定のアプリケーションのウィンドウを中央に特定のアプリケーションのウィンドウを中央に
; 特定のアプリケーションのウィンドウを中央に
; thanks
; http://www.kumei.ne.jp/c_lang/sdk/sdk_16.htm
; http://yokohama.cool.ne.jp/chokuto/urawaza/struct/RECT.html
; modify 2005/06/27
; 一部をβ10以降の関数形式に修正
; (β9以前との互換用はコメントアウト=本当は#ifdefで切り替えた方が
; いいと思いますが)
; HSPバージョンは#define置換に変更
; 一部のコメント修正
; HSPウィンドウハンドルを取得は直接システム変数取得も併記
#uselib "user32.dll"
#cfunc FindWindow "FindWindowA" sptr, sptr ; β10以降用
; #func FindWindow "FindWindowA" sptr, sptr ; β9以前互換
#cfunc GetDesktopWindow "GetDesktopWindow" ; β10以降用
; #func GetDesktopWindow "GetDesktopWindow" ; β9以前互換
#func GetWindowRect "GetWindowRect" int, int
#func SetWindowPos "SetWindowPos" int, int, int, int, int, int, int
; #define _HSPVER "ver.3.0b10" ; HSPのバージョン(HSPのウィンドウハンドルをFindWindowで検索する際にコメントを外す)
dim deskrc, 4
dim rc, 4
; ↓ウィンドウハンドルを検索する場合
; β10以降用
hw = FindWindow("onipad", 0) ; HSP スクリプトエディタのhwndを検索
; hw = FindWindow("notepad", 0) ; メモ帳のhwndを検索
; hw = FindWindow(0, "Hot Soup Processor " + _HSPVER) ; HSP(hsp3.exe)のhwndを検索
/*
; β9以前互換
FindWindow "onipad", 0 ; HSP スクリプトエディタのhwndを検索
; FindWindow "notepad", 0 ; メモ帳のhwndを検索
; FindWindow 0, "Hot Soup Processor " + _HSPVER ; HSP(hsp3.exe)のhwndを検索
hw = stat
*/
; ↓現在のHSPウィンドウハンドルを指定する場合
; hw = hwnd ; この場合は http://quasiquote.org/hspwiki/HSP%a4%ce%a5%a6%a5%a3%a5%f3%a5%c9%a5%a6%a4%f2%c3%e6%b1%fb%a4%cb を使用した方が簡単
; β10以降用
hDeskWnd = GetDesktopWindow()
/*
; β9以前互換
GetDesktopWindow
hDeskWnd = stat
*/
GetWindowRect hDeskWnd, varptr(deskrc)
GetWindowRect hw, varptr(rc)
x = (deskrc(2) - (rc(2) - rc(0))) / 2
y = (deskrc(3) - (rc(3) - rc(1))) / 2
SetWindowPos hw, 0, x, y, rc(2) - rc(0), rc(3) - rc(1), 1
stop
|