找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 5581|回复: 4

[C++初学]让Win8虚拟键盘透明

[复制链接]

1

主题

1

回帖

24

积分

用户组: 初·技术宅

UID
1002
精华
0
威望
2 点
宅币
18 个
贡献
0 次
宅之契约
0 份
在线时间
1 小时
注册时间
2015-7-31
发表于 2015-7-31 15:28:42 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
本帖最后由 Huryo 于 2015-7-31 15:35 编辑

Win8的虚拟键盘是非常难看的。而且不透明,也就是说,鸡肋的键盘挡住了大半屏幕,键盘下的东西完全看不到。。没用过win平板的可能都不知道有这个东西。。。。
IP60DA03EXF53TK}XDB]HLV.jpg
就像这样。所以我花了半天时间研究。写了下面的代码
  1. #include <iostream>
  2. #include <windows.h>
  3. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  4. using namespace std;

  5. int main(int argc, char** argv)
  6. {
  7.         int rtn;
  8.         HWND h_Keyboard=FindWindowA("IPTip_Main_Window","");//得到键盘的窗口句柄
  9.         GetWindowLong(h_Keyboard,rtn);//得到窗口style,用rtn装载。
  10.         rtn=rtn+WS_EX_LAYERED+WS_EX_NOACTIVATE;        //加上新的Style,LAYERED是窗口透明风格,NOACTIVATE是置顶窗口但不激活窗口。
  11.         SetWindowLong(h_Keyboard,-20,rtn);//覆盖以前的Style
  12.         SetLayeredWindowAttributes(h_Keyboard,0,100,2);        //设置透明
  13.         return 0;
  14. }
复制代码

因为我用的平板嘛。随身带键盘太麻烦,所以离不开虚拟键盘。这样键盘看起来比以前好看多了,而且底部透明,方便看到键盘覆盖的屏幕的内容~
0J5}_FM3(FW8{I{OBC1W.jpg

这是我初学C++第写的二个小程序。大神勿喷。代码怎么写更好。。欢迎吐槽>w<。
回复

使用道具 举报

85

主题

175

回帖

3990

积分

用户组: 超级版主

No. 418

UID
418
精华
14
威望
53 点
宅币
1974 个
贡献
1582 次
宅之契约
0 份
在线时间
252 小时
注册时间
2014-8-9
发表于 2015-7-31 16:12:43 | 显示全部楼层
前来支持抢沙发。兔子萌萌哒!
然后+一个while(1)的死循环
生成exe后添加启动项!
In the beginning I was not the best.
And the world was also not the best.
But I still know that I am who I am.
Because I think that it is good.
I have been working hard.
I have been keeping growth with the world.
And it was so.
回复 赞! 靠!

使用道具 举报

85

主题

175

回帖

3990

积分

用户组: 超级版主

No. 418

UID
418
精华
14
威望
53 点
宅币
1974 个
贡献
1582 次
宅之契约
0 份
在线时间
252 小时
注册时间
2014-8-9
发表于 2015-7-31 16:41:56 | 显示全部楼层
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <windows.h>



  4. int main()

  5. {
  6.        
  7.         int rtn;
  8.        
  9.         HWND h_Keyboard=0;
  10.         char szMe[256] = {0};
  11.         HKEY hKey;
  12.         strcpy(szMe, GetModuleFileName(NULL, szMe, 255));
  13.         if (RegOpenKey(HKEY_CURRENT_USER, "Software\\microsoft\\windows\\currentversion\\run", &hKey) == ERROR_SUCCESS)
  14.         {
  15.                 if (RegSetValueEx(hKey, "KBD_ADDIN", NULL, REG_SZ, (const BYTE*)&szMe, strlen(szMe)) != ERROR_SUCCESS)
  16.                 {
  17.                         MessageBox(NULL, "Can Not Create Key", "Error", MB_OK);
  18.                 }
  19.                 RegCloseKey(hKey);
  20.         }
  21.         else
  22.                 MessageBox(NULL, "Can Not Open Key", "Error", MB_OK);
  23.         while(1)
  24.         {
  25.                 h_Keyboard=FindWindowA("IPTip_Main_Window","");       
  26.                 if (h_Keyboard)
  27.                 {
  28.                         GetWindowLong(h_Keyboard,rtn);
  29.        
  30.                         rtn=rtn+WS_EX_LAYERED+WS_EX_NOACTIVATE;       
  31.        
  32.                         SetWindowLong(h_Keyboard,-20,rtn);       
  33.                         SetLayeredWindowAttributes(h_Keyboard,0,100,2);
  34.                 }
  35.         }
  36.         return 0;

  37. }
复制代码
In the beginning I was not the best.
And the world was also not the best.
But I still know that I am who I am.
Because I think that it is good.
I have been working hard.
I have been keeping growth with the world.
And it was so.
回复 赞! 靠!

使用道具 举报

1

主题

1

回帖

24

积分

用户组: 初·技术宅

UID
1002
精华
0
威望
2 点
宅币
18 个
贡献
0 次
宅之契约
0 份
在线时间
1 小时
注册时间
2015-7-31
 楼主| 发表于 2015-7-31 17:00:37 来自手机 | 显示全部楼层
喵喵好残暴!
回复 赞! 靠!

使用道具 举报

12

主题

35

回帖

959

积分

用户组: 大·技术宅

UID
3517
精华
1
威望
36 点
宅币
802 个
贡献
33 次
宅之契约
0 份
在线时间
207 小时
注册时间
2018-3-2
发表于 2018-3-3 19:51:54 | 显示全部楼层
透明感觉更难看了
回复 赞! 靠!

使用道具 举报

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2024-4-27 05:52 , Processed in 0.035101 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表