找回密码  加入

AUTOIT CN

搜索
查看: 222|回复: 3

[AU3基础] WM_NOTIFY里面的Send导致键盘上的大写键失效 求解[已解决]

[复制链接]
发表于 2018-3-13 21:23:55 | 显示全部楼层 |阅读模式
本帖最后由 kk_lee69 于 2018-3-13 21:57 编辑

一个 LISTVIEW控件 与一个 INPUT控件,焦点切换时  会触发 WM_NOTIFY里面的 $NM_SETFOCUS与 $NM_KILLFOCUS

在  $NM_SETFOCUS与 $NM_KILLFOCUS 里面 分别放入 Send("{CTRLDOWN}")与Send("{CTRLUP}") 运作上本来没啥问题,但是最近发现会导致 键盘原本的大写灯号熄灭  变成小写

测试 方法 请 将 键盘大写灯号打开  然后 执行程序  切换焦点

你就会发现 灯号熄灭 但是 从程序代码来看 应该不会导致这样的结果才对

求解  但是 要求 Send("{CTRLDOWN}")与Send("{CTRLUP}") 程序代码位置不能更动 只能放在   $NM_SETFOCUS与 $NM_KILLFOCUS 里面

不知道 是否有高手 愿意协助解决!!

程式碼 如下:

[AU3]#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
$Debug_LV = False ;<<<<<<<<<+++
Global $ListView, $B_DESCENDING
_Example1()
Func _Example1()
Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE);<<<<<<<<<+++
Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER);<<<<<<<<<+++
GUICreate('升?或降序', 633, 454, 192, 114)
$ListView = GUICtrlCreateListView("", 10,10, 430, 300)
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES);<<<<<<<<<+++
GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT);<<<<<<<<<+++
_GUICtrlListView_AddColumn($ListView, "A", 100)
_GUICtrlListView_AddColumn($ListView, "B", 100)
_GUICtrlListView_AddColumn($ListView, "C", 100)
_GUICtrlListView_AddColumn($ListView, "D", 100)
_GUICtrlListView_JustifyColumn($ListView, 0, 2)
_GUICtrlListView_JustifyColumn($ListView, 1, 2)
_GUICtrlListView_JustifyColumn($ListView, 2, 2)
_GUICtrlListView_JustifyColumn($ListView, 3, 2)
GUICtrlCreateListViewItem("1|5|e|", $ListView)
GUICtrlCreateListViewItem("2|3|ee|", $ListView)
GUICtrlCreateListViewItem("3|8|eg|", $ListView)
GUICtrlCreateListViewItem("4|7|eg|", $ListView)
GUICtrlCreateListViewItem("5|6|ej|", $ListView)
GUICtrlCreateListViewItem("6|5|ek|", $ListView)
GUICtrlCreateListViewItem("7|2|le|", $ListView)
GUICtrlCreateListViewItem("8|1|je|", $ListView)
  GUICtrlCreateInput("", 10, 320, 300, 20)

GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY");<<<<<<<<<+++
Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($ListView)];<<<<<<<<<+++

   Do;<<<<<<<<<+++
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam);<<<<<<<<<+++
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $ListView
If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)

$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
   Case $hWndListView
    Switch $iCode
     Case $LVN_COLUMNCLICK ; A column was clicked
      $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)

  
     Case $NM_SETFOCUS ; The control has received the input focus
                ConsoleWrite("按下"&@CRLF)
                Send("{CTRLDOWN}") ;保持 A 鍵按下
      ; No return value
          
     Case $NM_KILLFOCUS ; The control has lost the input focus
                ConsoleWrite("放開"&@CRLF)
                Send("{CTRLUP}") ;釋放 A 鍵
      ; No return value
          
    EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY[/AU3]
发表于 2018-3-13 21:50:27 | 显示全部楼层
  1. Opt('SendCapslockMode',0)
复制代码
 楼主| 发表于 2018-3-13 21:53:02 | 显示全部楼层
回复 2# haijie1223

這樣就解決了嗎?? 放在 一開始嗎??
 楼主| 发表于 2018-3-13 21:55:56 | 显示全部楼层
回复 2# haijie1223

果然是高手~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|小黑屋|手机版|AUTOIT CN ( 鲁ICP备15028933号-3 )谷歌 百度

GMT+8, 2018-12-14 08:38 , Processed in 0.084009 second(s), 14 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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