【已解决】如何实现inputbox禁止粘贴
本帖最后由 touch_xu 于 2015-1-22 17:23 编辑本帖最后由 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了 为什么不行,枚举子窗体获取inputbox句柄,设置窗体样式 为什么不行,枚举子窗体获取inputbox句柄,设置窗体样式
netegg 发表于 2014-12-12 09:59 http://www.autoitx.com/images/common/back.gif
句柄没问题,可是什么样的窗体样式是可以实现禁止粘贴的呢,谢谢! 本帖最后由 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不懂,自己改吧 或者试试看,当选择黏贴项的时候,先做一个清空剪贴板的操作,它粘了也没东西 BOOL PersonDlg::PreTranslateMessage(MSG* pMsg)
{
if (GetDlgItem(IDC_EDIT_USER_ID)->m_hWnd...
netegg 发表于 2014-12-12 11:34 http://www.autoitx.com/images/common/back.gif
十分感谢! 或者试试看,当选择黏贴项的时候,先做一个清空剪贴板的操作,它粘了也没东西
netegg 发表于 2014-12-12 11:47 http://www.autoitx.com/images/common/back.gif
当选择黏贴项- 此动作很难截获吧,谢谢! 很简单~ 直接禁用鼠标右键..... 回复 8# touch_xu
右键菜单有索引的 #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 = 1 And $CurInfo = $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
Local $y = $arPos
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc gto250,你换个头像吧,每次见我都很纠结 控件接收到WM_PASTE消息时啥也不做就可以了 #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
楼上的都不错
页:
[1]
2