HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2016
0824
saltHSPウィンドウ外のMOUSEUPなどのイベント取得7解決


salt

リンク

2016/8/24(Wed) 17:08:41|NO.76709


oncmd gosub *move, $200 oncmd gosub *ldown, 0x0201 oncmd gosub *rdown, 0x0204 oncmd gosub *lup, 0x0202 oncmd gosub *ldown, 0x0205 time=0 record=0 position=0 /***** ボタン作成部分 *****/ bgscr 1,100,20,,0,0//ボタン用のウィンドウ作る gsel 1,2//そのボタン用ウィンドウのIDは1なので、それにフォーカスを当てるkkk objsize 100,20//ボタンのサイズは100×50 button gosub "END",*ending /***** ボタン作成部分 *****/ repeat time++ await 1 loop stop *ending notesel buf repeat length(record) noteadd str(record(cnt)) loop notesave "record.txt" end *move record(position)="<Event>"+"<Msg>"+"MOVE"+"<X>"+str(ginfo(0))+"</X>"+"<Y>"+str(ginfo(1))+"</Y>"+"<Time>"+str(time)+"</Time>"+"</Event>" position++ time=0 return *ldown record(position)="<Event>"+"<Msg>"+"L_DOWN"+"<X>"+str(ginfo(0))+"</X>"+"<Y>"+str(ginfo(1))+"</Y>"+"<Time>"+str(time)+"</Time>"+"</Event>" position++ time=0 return *rdown record(position)="<Event>"+"<Msg>"+"R_DOWN"+"<X>"+str(ginfo(0))+"</X>"+"<Y>"+str(ginfo(1))+"</Y>"+"<Time>"+str(time)+"</Time>"+"</Event>" position++ time=0 return *lup record(position)="<Event>"+"<Msg>"+"L_UP"+"<X>"+str(ginfo(0))+"</X>"+"<Y>"+str(ginfo(1))+"</Y>"+"<Time>"+str(time)+"</Time>"+"</Event>" position++ time=0 return *rup record(position)="<Event>"+"<Msg>"+"R_UP"+"<X>"+str(ginfo(0))+"</X>"+"<Y>"+str(ginfo(1))+"</Y>"+"<Time>"+str(time)+"</Time>"+"</Event>" position++ time=0 return
現在、このようなスクリプトでマウスのイベントを取得しています。
今回、自分はHSPのウィンドウにフォーカスが当たっていない状態でも取得したいと考えています。
oncmdだと無理そうなので・・・。
どのようにすればいいでしょうか?



この記事に返信する


salt

リンク

2016/8/24(Wed) 17:10:12|NO.76710

ボタン作成部分のコメントはミスなので気にしなくて大丈夫です!



(--)

リンク

2016/8/24(Wed) 20:00:49|NO.76712

stickとginfo_mx,yを取得すれば出来ます。

repeat stick key, 768, 0 if ((key & 256) != 0 && (key0 & 256) == 0) { // PET gosub *ldown } if ((key & 256) == 0 && (key0 & 256) != 0) { // NET gosub *lup } if ((key & 512) != 0 && (key0 & 512) == 0) { // PET gosub *rdown } if ((key & 512) == 0 && (key0 & 512) != 0) { // NET gosub *rup } key0 = key if (mx0 != ginfo_mx || my0 != ginfo_my) { gosub *move } mx0 = ginfo_mx : my0 = ginfo_my await 1 loop



salt

リンク

2016/8/24(Wed) 22:08:46|NO.76714

マウスのボタンを離した瞬間をイベントドリブン的に取得できませんか?恐らくWinAPI使わないと無理だと思うのですが・・・。もし分かればお願いします!



へび

リンク

2016/8/25(Thu) 08:10:01|NO.76716

キーボードフックを使えばできますが
グローバルフックはDLLを作らないとできません。
まず、C++でDLLを作って、それをHSPから呼び出す必要があります。

このまえ、DLLをつくってC++から呼び出せたので、できないことはないと思いますが。
とりあえずリンク貼っておきます
http://fa11enprince.hatenablog.com/entry/2015/04/10/051454
https://msdn.microsoft.com/ja-jp/library/cc430103.aspx?f=255&MSPPError=-2147217396



salt

リンク

2016/8/25(Thu) 11:38:29|NO.76717

分かりました・・・!
それだったら普通にC#とかC++使った方が良さそうですね(笑)ありがとうございます!



MillkeyStars

リンク

2016/8/25(Thu) 11:49:45|NO.76718

こういう事かな?

#define VK_LBUTTON 0x01 #define VK_RBUTTON 0x02 #uselib "user32.dll" #cfunc GetAsyncKeyState "GetAsyncKeyState" int gsel 0,2 // 状況確認しやすくするので、ウィンドウを最前面にする *main LeftButton = GetAsyncKeyState(VK_LBUTTON) if (LeftButton != 0)&(MouseLock == 0) : MouseLock = 1 : title "左ボタンが押されてた" if (LeftButton == 0)&(MouseLock == 1) : MouseLock = 0 : title "なにもない" await 10 goto *main

普通にハードウェア入力の状態を取得しちゃえばいいと思うよ。
使い方は、https://msdn.microsoft.com/ja-jp/library/cc364583.aspx



salt

リンク

2016/8/26(Fri) 10:07:18|NO.76725

getkeyでやるのが良さそうですね、ありがとうございます!



ONION software Copyright 1997-2023(c) All rights reserved.