ArxBzFhblxphS Posted April 30, 2009 Share Posted April 30, 2009 (edited) Edited August 9, 2009 by Thanubis Link to comment Share on other sites More sharing options...
CodyBarrett Posted April 30, 2009 Share Posted April 30, 2009 (edited) stringinstr() ? edit... yeah i think you will have to regex... but i know you can set it to either numbers or letters... SPECIFICS? i have no idea except editing it afterwards Edited April 30, 2009 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
zorphnog Posted April 30, 2009 Share Posted April 30, 2009 Something like this should work: #include <GuiConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> GUICreate("Input Filter", 300, 30, -1, -1) $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState(@SW_SHOW) While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd GUIRegisterMsg($WM_COMMAND, "") Exit Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) If $hWndFrom = GUICtrlGetHandle($inTest) And $iCode = $EN_CHANGE Then GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', "")) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Link to comment Share on other sites More sharing options...
zorphnog Posted April 30, 2009 Share Posted April 30, 2009 Well then just change: GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', "")) to: GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', " ")) Link to comment Share on other sites More sharing options...
Valuater Posted April 30, 2009 Share Posted April 30, 2009 Something like this should work: #include <GuiConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> GUICreate("Input Filter", 300, 30, -1, -1) $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState(@SW_SHOW) While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd GUIRegisterMsg($WM_COMMAND, "") Exit Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) If $hWndFrom = GUICtrlGetHandle($inTest) And $iCode = $EN_CHANGE Then GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', "")) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Nice example zorph!! 8) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 30, 2009 Moderators Share Posted April 30, 2009 Thanubis, Another way to do it:#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUISetState() Local $sPreviousInput = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch Local $sInput = GUICtrlRead($hInput) ; Check if input has changed If $sPreviousInput <> $sInput Then ; Check latest input for banned char If StringRegExp($sInput, '[\\/:*?"<>\|]') Then $sInput = StringTrimRight($sInput, 1) GUICtrlSetData($hInput, $sInput) EndIf $sPreviousInput = $sInput EndIf WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Authenticity Posted April 30, 2009 Share Posted April 30, 2009 #include <Constants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Dim $hGUI = GUICreate('Title', 200, 50) Dim $Edit = GUICtrlCreateEdit('', 0, 20, 200, 25, 0) Dim $hEdit = GUICtrlGetHandle(-1) Dim $hFunc, $pFunc, $hOldWndProc $hFunc = DllCallbackRegister('WndProc', 'dword', 'dword;dword;dword;dword') $pFunc = DllCallbackGetPtr($hFunc) $hOldWndProc = _WinAPI_GetWindowLong($hEdit, $GWL_WNDPROC) _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $pFunc) GUISetState() Do Until GUIGetMsg() = -3 GUIDelete() DllCallbackFree($hFunc) Func WndProc($hwnd, $iMsg, $iwParam, $ilParam) If $iMsg = $WM_CHAR Then If StringRegExp(Chr($iwParam), '[\Q\/:*?"<>|\E]') Then Return EndIf EndIf Return _WinAPI_CallWindowProc($hOldWndProc, $hwnd, $iMsg, $iwParam, $ilParam) EndFunc Link to comment Share on other sites More sharing options...
Valuater Posted May 1, 2009 Share Posted May 1, 2009 Wow, and I thought zorphnog's code was complex. DLL and API calls seem a bit extreme for something so simple. Your code does work perfectly, but it's 128 bytes bigger than zorphnog's and uses 1.5 MB more RAM. Thanks for another fine example though.I've just about finished building a GUI around zorphnog's code.Great testing you are doing too, Thanubis. Many people don't consider the "overhead" of what appears to be a small script. I do prefer the GUIRegisterMessage() also8) Link to comment Share on other sites More sharing options...
ResNullius Posted May 1, 2009 Share Posted May 1, 2009 Wow, and I thought zorphnog's code was complex. DLL and API calls seem a bit extreme for something so simple. Your code does work perfectly, but it's 128 bytes bigger than zorphnog's and uses 1.5 MB more RAM. Thanks for another fine example though.I've just about finished building a GUI around zorphnog's code.Similar but slightly different version to all from CyberSlughttp://www.autoitscript.com/forum/index.ph...st&p=354577 Link to comment Share on other sites More sharing options...
andybiochem Posted May 1, 2009 Share Posted May 1, 2009 #include <GuiConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> GUICreate("Input Filter", 300, 30, -1, -1) $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState(@SW_SHOW) While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(10) WEnd GUIRegisterMsg($WM_COMMAND, "") Exit Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) $iCode = BitShift($iwParam, 16) If $hWndFrom = GUICtrlGetHandle($inTest) And $iCode = $EN_CHANGE Then GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', "")) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND why bother with all the BitAND / SHIFTing ?? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Input Filter", 300, 30) $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState() Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIRegisterMsg($WM_COMMAND, "") Func _WM_COMMAND($hWnd,$iMsg) GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', "")) EndFunc - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 1, 2009 Moderators Share Posted May 1, 2009 why bother with all the BitAND / SHIFTing ?? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Input Filter", 300, 30) $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState() Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIRegisterMsg($WM_COMMAND, "") Func _WM_COMMAND($hWnd,$iMsg) GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', "")) EndFuncWhy have a Sleep() command in a loop that uses GUIGetMsg? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
andybiochem Posted May 1, 2009 Share Posted May 1, 2009 Why have a Sleep() command in a loop that uses GUIGetMsg? Touche!! I'm an OnEvent guy... I don't 'get' GetMsg. - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2009 Moderators Share Posted May 1, 2009 Thanubis, How did you get the 'forbidden' characters into the input when using my code? I would like to know so that I can modify it - although with so many other alternatives on offer in this thread I might decide not to bother and just plagiarise! ;-) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
zorphnog Posted May 1, 2009 Share Posted May 1, 2009 why bother with all the BitAND / SHIFTing ?? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Input Filter", 300, 30) $inTest = GUICtrlCreateInput("", 5, 5, 290) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState() Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIRegisterMsg($WM_COMMAND, "") Func _WM_COMMAND($hWnd,$iMsg) GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', "")) EndFunc Well I had just copied and pasted the _WM_COMMAND function I had in another script and modified it. However, assuming that the GUI is going to have more that one control in it, you would not want to be updating the input every time a message is received. And the Sleep(10) was to reduce CPU usage. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2009 Moderators Share Posted May 1, 2009 zorphnog,Apologies for butting in, but you do not need a Sleep in a GUIGetMsg loop. From the help file:"This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU."M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
youknowwho4eva Posted May 1, 2009 Share Posted May 1, 2009 I don't know how to use the information on MSDN, I'm not even sure if this is the right place to look, but I found this and it looks semi what your looking for, if someone is nice enough to show us how to make a style for it http://msdn.microsoft.com/en-us/library/ms532967(VS.85).aspx Giggity Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2009 Moderators Share Posted May 1, 2009 youknowwho4eva,I hate to be a wet blanket, but your link deals with the Alpha of a object. This is an additional element of the colour - imagine RGBA rather than RGB. Take a look here ( http://en.wikipedia.org/wiki/RGBA_color_space ) for a full explanation.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Valuater Posted May 1, 2009 Share Posted May 1, 2009 It happens when I hit two forbidden characters at once. Try hitting both "<" and ">" at the same time. You don't even have to be quick about it, just hit them at the same time. Your script will block one of them, but the other will go through. It may be unlikely to happen under normal use, but I need to plan for everything. ~~~ Try that with this one.. #include <GUIConstants.au3> $GUI = GUICreate("Enter a name for a new folder....", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES $file = GUICtrlCreateInput ( "", 10, 20, 300, 20) $btn = GUICtrlCreateButton ("Ok", 40, 95, 60, 20) GuiSetState(@SW_SHOW) Dim $previousText While 1 $msg = GUIGetMsg() If $msg = $btn Or $msg = $GUI_EVENT_CLOSE Then Exit $text = GuiCtrlRead($file) If $previousText <> $text Then ToolTip("") If StringRegExp($text, '\\|/|:|\*|\?|\"|\<|\>|\|') Then GuiCtrlSetData($file, StringRegExpReplace($text, '\\|/|:|\*|\?|\"|\<|\>|\|', "")) DllCall ("user32.dll", "int", "MessageBeep", "int", 0xFFFFFFFF) ;Beep Local $tooltipPos = WinGetPos($GUI) ToolTip("A file name cannot contain any of the following characters:" & @LF & _ ' \ / : * ? " < > |', $tooltipPos [0]+160, $tooltipPos [1]+60, Default, Default, 3) $previousText = GuiCtrlRead($file) Endif Wend ResNull posted this as a thread to CyberSlug 8) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 1, 2009 Moderators Share Posted May 1, 2009 (edited) Thanubis,hit two forbidden characters at onceAs a one-and-a-half fingered typist that was never a problem for me! :-)But thanks for the info - best I do not offer that solution to anyone else.M23Edit: Val, thanks for that suggestion. Edited May 1, 2009 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Valuater Posted May 1, 2009 Share Posted May 1, 2009 Final...http://www.autoitscript.com/forum/index.ph...st&p=6766128) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now