Jump to content
Sign in to follow this  
ArxBzFhblxphS

..

Recommended Posts

ArxBzFhblxphS
Posted Image Edited by Thanubis

Share this post


Link to post
Share on other sites
CodyBarrett

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 by CodyBarrett

Share this post


Link to post
Share on other sites
zorphnog

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

Share this post


Link to post
Share on other sites
zorphnog

Well then just change:

GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', ""))

to:

GUICtrlSetData($inTest, StringRegExpReplace(GUICtrlRead($inTest), '[\\/:*?"<>\|]', " "))

Share this post


Link to post
Share on other sites
Valuater

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Authenticity

#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

Share this post


Link to post
Share on other sites
Valuater

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() also

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
ResNullius

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 CyberSlug

http://www.autoitscript.com/forum/index.ph...st&p=354577

Share this post


Link to post
Share on other sites
andybiochem

#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!

Share this post


Link to post
Share on other sites
SmOke_N

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
Why 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.

Share this post


Link to post
Share on other sites
andybiochem

Why have a Sleep() command in a loop that uses GUIGetMsg? ;):D

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!

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
zorphnog

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.

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
youknowwho4eva

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

Share this post


Link to post
Share on other sites
Melba23

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Valuater

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)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Melba23

Thanubis,

hit two forbidden characters at once

As 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.

M23

Edit: Val, thanks for that suggestion.

Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×