ウィンドウのサイズ変更
6WF1 2013/6/5(Wed) 19:55:24|NO.54599
アクティブになってるウィンドウが
指定したサイズでなかったら
指定したサイズに変更。
という形にしたいのですが
お分かりの方ぜひ教えていただけないでしょうか?(*;ω人)
ht. 2013/6/5(Wed) 20:19:19|NO.54600
アクティブというのは他のプロセスが所有するウインドウを含めるのでしょうか。
それとも自作のウインドウがアクティブになったタイミングでサイズ調整をしたいということですか?
6WD1 2013/6/6(Thu) 12:12:35|NO.54616
他のプロセスですね!
指定したサイズが見つかれば
また、別の指定したサイズに
変更。
と言う形にしたいのです笑
cats 2013/6/6(Thu) 19:23:10|NO.54625
こんな感じでしょうか。
GetForegroundWindowでアクティブなウィンドウのハンドルを取得し
GetWindowRectでサイズを取得
SetWindowPosで位置とサイズを指定します。
#uselib "user32.dll"
#func GetForegroundWindow "GetForegroundWindow"
#func SetWindowPos "SetWindowPos" int,int,int,int,int,int,int
#func GetWindowRect "GetWindowRect" int,int
screen 0,640,480
dim rect, 4
repeat
redraw 0
color 255,255,255:boxf:color
GetForegroundWindow
hwnd_=stat
GetWindowRect hwnd_,varptr(rect)
pos 0,0
mes "アクティブなウィンドウのハンドル:"+hwnd_
mes rect(2)
mes rect(3)
if rect(2)!640 and rect(3)!480{//もしX=640,Y=480でなかったら
//SetWindowPos hwnd_,,rect(0),rect(1),640,480,
//上の行のコメントを外せばアクティブウィンドウが640x480に変わります(注意)
}
wait 1
redraw 1
loop
ただ指定したサイズ以外のアクティブなウィンドウのサイズをすべて変更するのは
ユーザーとしては困る気がします(ブラウザ小さくなったり)
6WF1 2013/6/6(Thu) 21:46:52|NO.54636
あぁ、、確かに・・・
例えばこれがIEだけを指定して
IEがそのサイズでなければ。
ってのはできるんでしょうか?
cats 2013/6/7(Fri) 18:27:11|NO.54648
IEのサイズ変えるんですね。
IEのハンドル取得すればいいだけなので検索サイトを活用しましょう。
#uselib "user32.dll"
#cfunc FindWindow "FindWindowA" sptr, sptr
#func GetForegroundWindow "GetForegroundWindow"
#func SetWindowPos "SetWindowPos" int,int,int,int,int,int,int
#func GetWindowRect "GetWindowRect" int,int
screen 0,640,480
dim rect, 4
repeat
redraw 0
color 255,255,255:boxf:color
GetForegroundWindow
hwnd_=stat
GetWindowRect hwnd_,varptr(rect)
pos 0,0
mes "アクティブなウィンドウのハンドル:"+hwnd_
mes rect(2)
mes rect(3)
if hwnd_=FindWindow("internet explorer_server", 0){
if rect(2)!640 and rect(3)!480{//もしX=640,Y=480でなかったら
//SetWindowPos hwnd_,,rect(0),rect(1),640,480,
//上の行のコメントを外せばアクティブウィンドウが640x480に変わります(注意)
}
}
wait 1
redraw 1
loop
6WF1 2013/6/7(Fri) 19:49:22|NO.54655
サンプルどうもありがとうございます!
早速ためしてみます!
6WF1 2013/6/7(Fri) 19:49:39|NO.54656
解決!