找回密码
 加入
搜索
查看: 6564|回复: 20

[GUI管理] 【已解决】如何实现inputbox禁止粘贴

 火.. [复制链接]
发表于 2014-12-11 11:56:30 | 显示全部楼层 |阅读模式
本帖最后由 touch_xu 于 2015-1-22 17:23 编辑

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-12-11 15:42:14 | 显示全部楼层
本帖最后由 brucefay1115 于 2014-12-11 15:44 编辑

autoit 無法多線程檢測 所以沒辦法在inputbox出來同時又進行貼上檢測

我想到唯一方法只有比對inputbox值與ClipGet()是否一樣
Local $_String = InputBox("InputBox", "Input a string")
If $_String == ClipGet() Then MsgBox(0, "Message", "請勿複製貼上!")
如果不滿意就只能自己設計一個inputbox的Form了
发表于 2014-12-12 09:59:44 | 显示全部楼层
为什么不行,枚举子窗体获取inputbox句柄,设置窗体样式
 楼主| 发表于 2014-12-12 11:30:04 | 显示全部楼层
为什么不行,枚举子窗体获取inputbox句柄,设置窗体样式
netegg 发表于 2014-12-12 09:59



    句柄没问题,可是什么样的窗体样式是可以实现禁止粘贴的呢,谢谢!
发表于 2014-12-12 11:34:38 | 显示全部楼层
本帖最后由 netegg 于 2014-12-12 11:44 编辑

BOOL PersonDlg::PreTranslateMessage(MSG* pMsg)  
{  
    if (GetDlgItem(IDC_EDIT_USER_ID)->m_hWnd == pMsg->hwnd ||  
        GetDlgItem(IDC_EDIT_USER_NAME)->m_hWnd == pMsg->hwnd ||  
        GetDlgItem(IDC_EDIT_PHONE)->m_hWnd == pMsg->hwnd ||  
        GetDlgItem(IDC_EDIT_IDCARD)->m_hWnd == pMsg->hwnd )     
    {     
        if (pMsg->message == WM_RBUTTONUP || pMsg->message == WM_KEYDOWN && pMsg->wParam == 'V' && (GetAsyncKeyState(VK_CONTROL) & 0x8000))              
            return TRUE;         
    }  
    return CRTDialog::PreTranslateMessage( pMsg );  
}  
vc不懂,自己改吧
发表于 2014-12-12 11:47:48 | 显示全部楼层
或者试试看,当选择黏贴项的时候,先做一个清空剪贴板的操作,它粘了也没东西
 楼主| 发表于 2014-12-12 13:27:31 | 显示全部楼层
BOOL PersonDlg::PreTranslateMessage(MSG* pMsg)  
{  
    if (GetDlgItem(IDC_EDIT_USER_ID)->m_hWnd  ...
netegg 发表于 2014-12-12 11:34



    十分感谢!
 楼主| 发表于 2014-12-12 13:28:09 | 显示全部楼层
或者试试看,当选择黏贴项的时候,先做一个清空剪贴板的操作,它粘了也没东西
netegg 发表于 2014-12-12 11:47



    当选择黏贴项- 此动作很难截获吧,谢谢!
发表于 2014-12-12 13:30:57 | 显示全部楼层
很简单~ 直接禁用鼠标右键.....
发表于 2014-12-12 13:59:52 | 显示全部楼层
回复 8# touch_xu

右键菜单有索引的
发表于 2014-12-12 19:03:05 | 显示全部楼层
#include <GuiConstants.au3>

$Gui = GUICreate("test")

$Edit = GUICtrlCreateInput("Input1", 184, 168, 121, 21)
$DummyMenu      = GUICtrlCreateDummy()
$ContextMenu    = GUICtrlCreateContextMenu($DummyMenu)
$MenuItem1 = GUICtrlCreateMenuItem("我是假冒的", $ContextMenu)


GUISetState()

While 1
    $CurInfo = GUIGetCursorInfo($Gui)
    $Msg = GUIGetMsg()
    Select
        Case $Msg = -3
            Exit
        Case $CurInfo[3] = 1 And $CurInfo[4] = $Edit
            ShowMenu($Gui, $ContextMenu)
    EndSelect
WEnd

; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $nContextID)
    Local $hMenu = GUICtrlGetHandle($nContextID)
    $arPos = MouseGetPos()
    Local $x = $arPos[0]
    Local $y = $arPos[1]
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc
发表于 2014-12-13 12:18:30 | 显示全部楼层
gto250,你换个头像吧,每次见我都很纠结
发表于 2014-12-13 14:46:27 | 显示全部楼层
控件接收到WM_PASTE消息时啥也不做就可以了
发表于 2014-12-13 14:57:15 | 显示全部楼层
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 299, 136, 192, 114)
$Label1 = GUICtrlCreateLabel("禁止粘贴", 8, 8, 52, 17)
$Input1 = GUICtrlCreateInput("", 32, 48, 225, 21)
$wProcOld = GUIRegisterMsgEx($Input1, "_MyWindowProc") ;窗口子类化
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        GUIDelete($Form1)
                        Exit
        EndSwitch
WEnd

Func GUIRegisterMsgEx($ctrID, $funcName) ;控件id,函数名
        Local $wProcNew = DllCallbackRegister($funcName, "ptr", "hwnd;uint;long;ptr")
        Local $wProcOld = _WinAPI_SetWindowLong(GUICtrlGetHandle($ctrID), $GWL_WNDPROC, DllCallbackGetPtr($wProcNew))
        Return $wProcOld
EndFunc   ;==>GUIRegisterMsgEx

Func _MyWindowProc($hWnd, $uiMsg, $wParam, $lParam)
        Switch $uiMsg
                Case $WM_PASTE
                        Return 0 ;不处理这个消息
        EndSwitch
        ;向默认窗口进程传递未处理过的消息
        Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $uiMsg, $wParam, $lParam)
EndFunc   ;==>_MyWindowProc
发表于 2014-12-13 22:16:36 | 显示全部楼层
楼上的都不错
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 13:23 , Processed in 0.088154 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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