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


HSPTV!掲示板


未解決 解決 停止 削除要請

2011
0212
grapecolorタスクトレイ常駐について質問(初投稿)7未解決


grapecolor

リンク

2011/2/12(Sat) 19:59:10|NO.37048

僕が今作っているソフトに(ボタンを押すだけで)タスクトレイに常駐できる
機能を加えたいと思っています。
ただし、常駐中もソフトとして動作するようにしたいのですが、
どうすればできるのか教えてください><
下に機能を加えたいプログラムを載せておきます・・・

//パックファイル&実行ファイル名 #epack "logo.bmp" #packopt name "screencapture" //起動ロゴ cls screen 0,,,2 bgscr 2,200,600,0,150,150 title "起動中..." picload "logo.bmp" wait 200 //起動時の画面 *start cls screen 2,ginfo_dispx,ginfo_dispy,2 screen 0,150,100,4 title "メニュー" objsize 150,25 button "通常モード",*start1 button "連写モード",*start2 button "保存画像を見る",*kan stop ;-------------------------------------------------------------------------------------------- //通常モードプログラムここから *start1 cls screen 2,ginfo_dispx,ginfo_dispy,2 screen 0,160,110,4 title "通常モード" mes " Print Screenキー" mes " を押してください" objsize 160,25 pos 0,35:button "モード切替",*start2 button "保存画像を見る",*kan1 //キーに反応するやつ *lp1 await 1 getkey k,44 if k=1:goto,*program1 goto *lp1 //メインプログラム *program1 #uselib "user32.dll" #func global OpenClipboard "OpenClipboard" int #cfunc global GetClipboardData "GetClipboardData" int #func global CloseClipboard "CloseClipboard" #uselib "gdi32.dll" #func global CreateCompatibleDC "CreateCompatibleDC" int #cfunc global GetObject "GetObjectA" int, int, var #func global SelectObject "SelectObject" int, int #func global BitBlt "BitBlt" int, int, int, int, int, int, int, int, int #func global DeleteDC "DeleteDC" int #module #deffunc clipgetg local i #define newBmp i.0 #define oldBmp i.1 #define memhdc i.2 #define sizex i.3 #define sizey i.4 await 1 OpenClipboard hwnd // クリップボードを開く if stat = 0 : return 1 // 開けなかったら終了 newBmp = GetClipboardData(2) // クリップボードから画像(2:CF_BITMAP)取得 if newBmp = 0 { CloseClipboard // 取得できなければ終了 return 1 } // ビットマップオブジェクト情報取得(BITMAP構造体24byte) dim bmp, 6 if GetObject(newBmp, 24, bmp) = 0 { CloseClipboard // 取得できなければ終了 return 2 } // メモリデバイスコンテキストを作成 CreateCompatibleDC hdc memhdc = stat // ビットマップオブジェクトを選択(旧オブジェクトは退避しておく) SelectObject memhdc, newBmp oldBmp = stat // 画像情報をコピー if bmp.1 > ginfo_sx : sizex = ginfo_sx : else : sizex = bmp.1 if bmp.2 > ginfo_sy : sizey = ginfo_sy : else : sizey = bmp.2 BitBlt hdc, ginfo_cx, ginfo_cy, sizex, sizey, memhdc, , , 0x00CC0020 // SRCCOPY redraw 1 // 終了処理 SelectObject memhdc, oldBmp // オブジェクトを元に戻す DeleteDC memhdc // メモリデバイスコンテキストを削除 CloseClipboard // クリップボードを閉じる return 0 #global //操作先ウィンドウを2に変更 gsel 2 //clipgetg 命令の使用 clipgetg if stat : dialog "画像の取得に失敗しました。何回も出る場合はお問い合わせ下さい。" //画像の保存 chdir "C:\\Program Files\\screencapture\\capturepicture\\通常モード" bmpsave ""+gettime(0)+gettime(1)+gettime(3)+gettime(4)+gettime(5)+gettime(6)+gettime(7)+".bmp" //操作先ウィンドウを戻す gsel 2 //処理一時停止 wait 200 //最初に戻す gosub *start1 stop //通常モードプログラムここまで ;----------------------------------------------------------------------------------------------------- //連写モードプログラムここから *start2 cls screen 2,ginfo_dispx,ginfo_dispy,2 screen 0,160,110,4 title "連写モード" mes " Print Screenキー" mes " を押してください" objsize 160,25 pos 0,35:button "モード切替",*start1 button "保存画像を見る",*kan2 //キーに反応するやつ *lp2 await 1 getkey k,44 if k=1:goto,*program2 goto *lp2 //メインプログラム *program2 await 1 OpenClipboard hwnd // クリップボードを開く if stat = 0 : return 1 // 開けなかったら終了 newBmp = GetClipboardData(2) // クリップボードから画像(2:CF_BITMAP)取得 if newBmp = 0 { CloseClipboard // 取得できなければ終了 return 1 } // ビットマップオブジェクト情報取得(BITMAP構造体24byte) dim bmp, 6 if GetObject(newBmp, 24, bmp) = 0 { CloseClipboard // 取得できなければ終了 return 2 } // メモリデバイスコンテキストを作成 CreateCompatibleDC hdc memhdc = stat // ビットマップオブジェクトを選択(旧オブジェクトは退避しておく) SelectObject memhdc, newBmp oldBmp = stat // 画像情報をコピー if bmp.1 > ginfo_sx : sizex = ginfo_sx : else : sizex = bmp.1 if bmp.2 > ginfo_sy : sizey = ginfo_sy : else : sizey = bmp.2 BitBlt hdc, ginfo_cx, ginfo_cy, sizex, sizey, memhdc, , , 0x00CC0020 // SRCCOPY redraw 1 // 終了処理 SelectObject memhdc, oldBmp // オブジェクトを元に戻す DeleteDC memhdc // メモリデバイスコンテキストを削除 CloseClipboard // クリップボードを閉じる //操作先ウィンドウを2に変更 gsel 2 //clipgetg 命令の使用 clipgetg if stat : dialog "画像の取得に失敗しました。何回も出る場合はお問い合わせ下さい。" //画像の保存 chdir "C:\\Program Files\\screencapture\\capturepicture\\連写モード" bmpsave ""+gettime(0)+gettime(1)+gettime(3)+gettime(4)+gettime(5)+gettime(6)+gettime(7)+".bmp" //操作先ウィンドウを戻す gsel 2 //最初に戻る gosub *start2 stop //連写モードプログラムここまで *kan exec "explorer C:\\Program Files\\screencapture\\capturepicture"//保存先のフォルダを開く goto *start stop *kan1 exec "explorer C:\\Program Files\\screencapture\\capturepicture"//保存先のフォルダを開く goto *start1 stop *kan2 exec "explorer C:\\Program Files\\screencapture\\capturepicture"//保存先のフォルダを開く goto *start2 stop



この記事に返信する


cookies

リンク

2011/2/12(Sat) 21:16:19|NO.37053

「hsp タスクトレイ」あたりでググろう。



いかろ

リンク

2011/2/12(Sat) 22:15:06|NO.37054




grapecolor

リンク

2011/2/12(Sat) 22:39:30|NO.37057

いかろさん
そのプログラムも試しましたが、タスクトレイに入れた途端、ソフトの機能が動作しません。
なにか良い方法はないでしょうか



info

リンク

2011/2/12(Sat) 23:34:38|NO.37063

こういうことでしょうか?


#uselib "user32.dll" #cfunc IsWindowVisible "IsWindowVisible" int #func ShowWindow "ShowWindow" int,int #uselib "kernel32.dll" #func GetModuleFileName "GetModuleFileNameA" int , var , int #uselib "shell32.dll" #func ExtractIconEx "ExtractIconEx" str,int,int,var,int #func Shell_NotifyIcon "Shell_NotifyIcon" int,var // ツールチップのテキスト screen 0,500,30 mes "通知領域にアイコンが追加されています" // 自分のアイコンを取得 sdim ExeFileName , 0x104+1 , 0 GetModuleFileName 0 , ExeFileName , 0x104 ExtractIconEx ExeFileName,0,0,hDefaultIcon,1 // NOTIFYICONDATA を作成 #const NOTIFYICONDATA_STRUCTSIZE 6*4+64 dim nid , NOTIFYICONDATA_STRUCTSIZE/4 nid.0 = NOTIFYICONDATA_STRUCTSIZE , hwnd , 0 nid.3 = 0x7 // NIF_MESSAGE | NIF_ICON | NIF_TIP nid.4 = 0x0501 , hDefaultIcon poke nid.6,0,"クリックで表示状態を切り替えます" // アイコンを表示 Shell_NotifyIcon 0 /*NIM_ADD*/,nid onexit *exit oncmd gosub *oncmd_MYWM_NOTIFYICON , 0x0501 stop *oncmd_MYWM_NOTIFYICON // WM_LBUTTONDOWN 〜 左クリック if (0x0201==lparam){ if IsWindowVisible( hwnd ) { gsel 0,-1 }else{ gsel 0,1 } } return *exit // アイコンを削除 Shell_NotifyIcon 2 /*NIM_DELETE*/,nid end



grapecolor

リンク

2011/2/13(Sun) 10:41:59|NO.37069

infoさん
具体的にメインプログラムをそのプログラムにどうやって組み込めばいいのでしょうか
あと、常時常駐したいのではなく、ボタンを押したときにだけ
タスクトレイに常駐させるようにしたいのですが、可能ですか?



cookies

リンク

2011/2/13(Sun) 13:08:11|NO.37071

grapecolorさん
>そのプログラムも試しましたが、タスクトレイに入れた途端、ソフトの機能が動作しません。
>なにか良い方法はないでしょうか

http://hspnext.com/hspkura/hspkura02.htm#contents21を組み込んで
「ソフトの機能が動作しません」とはどういう状態のことでしょう?
まさか、「格納したら、ウィンドウが表示されなくなった」ということではないですよね?



info

リンク

2011/2/14(Mon) 06:18:37|NO.37110

上記のスクリプトでは、

Shell_NotifyIcon 0 /*NIM_ADD*/,nid
の部分で、タスクトレイにアイコンを追加しています。

よって、button を押した際に
Shell_NotifyIcon 0 /*NIM_ADD*/,nid
が実行されるようにプログラムすれば、
意図した動作になるはずです。

タスクトレイのアイコンと、ウィンドウは別物です。
一つのアプリケーションで、複数個のアイコンを登録する事も出来ます。

NOTIFYICONDATA

Shell_NotifyIcon

で検索してみたら理解できるかもしれません。



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