JonathanR Posted January 10, 2010 Share Posted January 10, 2010 My script requires there to be an ampersand (&) within a list, which when selected, the name of the item is then pulled into a label. The issue being, in the list it displays as "Sweat&Sour", but in the label, it displays as "SweatSour" due to the ampersand triggering the Alt-shortcut. Is there anyway to prevent this from happening, besides doubling up the ampersand? As it would then display as "Sweat&&Sour" in the list, but "Sweat&Sour" in the input.#include <GUIConstantsEx.au3> GUICreate("Ampersand Shortcut", 200, 200) $list = GUICtrlCreateList("", 10, 10, 180, 90) GUICtrlSetData(-1, "Sweat&Sour|Sweat&&Sour") $label = GUICtrlCreateLabel("", 25, 125, 150, 20) GUISetState() Do $msg = GUIGetMsg() If $msg = $list Then GUICtrlSetData($label, GUICtrlRead($list)) Until $msg = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
ResNullius Posted January 10, 2010 Share Posted January 10, 2010 Double up the ampersand when you read it from the list: #include <GUIConstantsEx.au3> GUICreate("Ampersand Shortcut", 200, 200) $list = GUICtrlCreateList("", 10, 10, 180, 90) GUICtrlSetData(-1, "Sweet&Sour|Thing|Yes & No") $label = GUICtrlCreateLabel("", 25, 125, 150, 20) GUISetState() Do $msg = GUIGetMsg() If $msg = $list Then GUICtrlSetData($label, StringReplace(GUICtrlRead($list), "&", "&&")) Until $msg = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
ProgAndy Posted January 10, 2010 Share Posted January 10, 2010 There is a style called SS_NOPREFIX to suppress that #include <GUIConstantsEx.au3> #include <StaticConstants.au3> GUICreate("Ampersand Shortcut", 200, 200) $list = GUICtrlCreateList("", 10, 10, 180, 90) GUICtrlSetData(-1, "Sweat&Sour|Sweat&&Sour") $label = GUICtrlCreateLabel("", 25, 125, 150, 20, $SS_NOPREFIX) GUISetState() Do $msg = GUIGetMsg() If $msg = $list Then GUICtrlSetData($label, GUICtrlRead($list)) Until $msg = $GUI_EVENT_CLOSE *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
JonathanR Posted January 11, 2010 Author Share Posted January 11, 2010 Thank you, sirs. Two very good ways of accomplishing this. I don't know how, but I managed to look past the $SS_NOPREFIX style. 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