Example #1
0
        private void ShowForegroundWindow(object sender, EventArgs e)
        {
            var FW = GetForegroundWindow();

            /*
             * StringBuilder SB = new StringBuilder();
             * //char[] filepath = new char[10000];
             * //uint maxfilepathlength = 1000;
             * try
             * {
             *  GetWindowText(FW, SB, 1000);
             * }
             * catch (Exception ex)
             * {
             *  Debug.Write(ex.Message);
             * }
             */
            //Debug.Write(SB);
            //QueryFullProcessImageName(new IntPtr(GetCurrentProcessID(FW)), 0, filepath, ref maxfilepathlength);
            var P  = Process.GetProcessById(GetCurrentProcessID(FW));
            var PP = FindHostedProcess.Find();

            if (PP == null)
            {
                return;
            }
            TB.Text = PP.ProcessName + "|" + PP.MainModule.FileName + "|" + PP.MainWindowTitle;
            //Bitmap img = Consts.Base64String2Icon(Consts.Icon2Base64String(System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName))).ToBitmap();
            Icon icon  = System.Drawing.Icon.ExtractAssociatedIcon(PP.MainModule.FileName);
            Icon icon2 = Consts.Base64String2Icon(Consts.Icon2Base64String(icon));

            IMG.Source = Consts.ChangeBitmapToImageSource(icon2.ToBitmap());
        }
Example #2
0
        public static bool AddActions(Actions A)
        {
            using (SQLiteConnection con = new SQLiteConnection("Data Source=Actions.db;Version=3;"))
            {
                con.Open();
                using (SQLiteCommand cmd = new SQLiteCommand("INSERT INTO Actions (TimeStamp, Type, Action, Title, Icon) VALUES (@TS, @Type, @Action, @Title, @Icon)", con))
                {
                    cmd.Parameters.AddWithValue("@TS", DateTime.Now.Ticks);
                    if (A.Type != 0 && A.Type != 1)
                    {
                        return(false);
                    }
                    cmd.Parameters.AddWithValue("@Type", A.Type);
                    cmd.Parameters.AddWithValue("@Action", A.Action);
                    cmd.Parameters.AddWithValue("@Title", A.Title);
                    cmd.Parameters.AddWithValue("@Icon", Consts.Icon2Base64String(A.Icon));

                    cmd.ExecuteNonQuery();
                    return(true);
                }
            }
        }