charvi Posted May 28, 2009 Posted May 28, 2009 How do I toggle keyboard Insert and Overwrite modes? I tried the below code with no success. It always inserts characters. Send ("{Ins}") The Help seems not to provide an {Overwrite} option.... ?
Developers Jos Posted May 28, 2009 Developers Posted May 28, 2009 This will depend on the program having the forum supporting the Insert/Overwrite toggle, but when I run this script from SciTE I do see the INS go to OVR in the left bottom corner send("{INS}") sleep(2000) send("{INS}") SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
charvi Posted May 28, 2009 Author Posted May 28, 2009 This will depend on the program having the forum supporting the Insert/Overwrite toggle, but when I run this script from SciTE I do see the INS go to OVR in the left bottom corner send("{INS}") sleep(2000) send("{INS}") Jos, Indeed, your example works fine, but it does not work in my script, where I would like to place the caret at the fifth position, then prompt for a number that will replace the 123-456 in the example below. Even manually hitting the Insert key seems to have no effect! (strange...) #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> $hWnd = GUICreate("Input with caret at desired position", 350, 130) GUISetFont(14, 400, 1, "DOSLike") $btnOK = GUICtrlCreateButton("&OK", 218, 70, 80, 30, 0) GUICtrlCreateLabel("Number: ", 20, 24, 200, 20) $input1 = GUICtrlCreateInput("555-123-456", 100, 22, 200, 24) GUISetState() GUICtrlSetState($input1, $GUI_FOCUS) Send("{Home}{Right}{Right}{Right}{Right}{Ins}") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3, $GUI_EVENT_CLOSE, $btnOK Exit EndSwitch WEnd
charvi Posted May 28, 2009 Author Posted May 28, 2009 Why not set the hyphens (-) as labels and use three separate input boxes for each set of digits? Text in the input boxes should highlight when they are selected and be automatically overwritten by user input.Also, keep in mind that "DOSLike" is not a standard Windows font.Thanubis,Your idea is excellent (and approved!), but my code was just an imagined example for the Toggle Insert/Overwrite problem.That's right, DOSLike is not a standard font, and I forgot to remove it when I posted it here. Anyway, if you do not have that font, it will be ignored and I believe that "MS Sans Serif" will be used instead, which does not affect the Toggle problem (which is at this time not yet solved...).
charvi Posted May 28, 2009 Author Posted May 28, 2009 Oh yeah, I forgot to mention that as far as I know, Insert/Overwrite will not work for input boxes, no matter how they are made.I did a brief test with various programs and the "Ins" key did nothing for input boxes created with AutoIt, Delphi, or C++.There may be some code you can add to a program to allow toggling of the insert key in an input box, but that's far beyond my current abilities, assuming it's even possible.Fascinating... You are right, I could not toggle in any program except in Word, Excel, the Command Prompt and.... the SciTE Editor!!!Perhaps this might be possible with a DLL call, but this is beyond my knowledge too.Tomorrow I will post in this forum an input editor I was trying to write in January, but gave up because of typing speed problems. If anyone is interested, please watch for the title 'DOS alike Input Editor'
MrCreatoR Posted May 29, 2009 Posted May 29, 2009 Well, i think it's window's limitation, but we always(?) can work it around expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> ; Global $iIns_Is_ON = False $hWnd = GUICreate("Input with caret at desired position", 350, 130) GUISetFont(14, 400, 1, "DOSLike") GUICtrlCreateLabel("Number: ", 20, 25, 70, 20) $Input1 = GUICtrlCreateInput("555-123-456", 100, 20, 200, 25) $btnOK = GUICtrlCreateButton("&OK", 220, 70, 80, 30, 0) $btnToggleIns = GUICtrlCreateButton("Toggle INS", 100, 70, 100, 30, 0) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $btnOK Exit Case $btnToggleIns $iIns_Is_ON = Not $iIns_Is_ON GUICtrlSetState($Input1, $GUI_FOCUS) _GUICtrlEdit_SetSel($Input1, 0, 0) EndSwitch WEnd Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0xFFFF) Local $hCtrl = $lParam Switch $nID Case $Input1 Switch $nNotifyCode Case $EN_CHANGE;, $EN_UPDATE If Not $iIns_Is_ON Then Return $GUI_RUNDEFMSG Local $aSelection = _GUICtrlEdit_GetSel($Input1) Local $sInput_Data = GUICtrlRead($Input1) If $aSelection[0] <> $aSelection[1] Then Return $GUI_RUNDEFMSG GUICtrlSetData($Input1, StringLeft($sInput_Data, $aSelection[0]) & StringMid($sInput_Data, $aSelection[0]+2)) _GUICtrlEdit_SetSel($Input1, $aSelection[0], $aSelection[0]) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
MrCreatoR Posted May 29, 2009 Posted May 29, 2009 (edited) Ok, and here is a version with caret insert-like setup: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> #include <WinAPI.au3> ; ;[0] - Caret Width ;[1] - Caret Height ;[2] - Caret X pos ;[3] - Caret Y pos ;[4] - Caret speed (-1 for static) ;Use this to set blinking solid block caret: [10, 18, 0, 0, 500] Global $aCaret_Opts[5] = [10, 2, 0, 18, 500] Global $hBitmap = _WinAPI_CreateSolidBitmap(0, 0xFFFFFF, $aCaret_Opts[0], $aCaret_Opts[1]) Global $iIns_Is_ON = False $hWnd = GUICreate("Input with caret at desired position", 350, 130) GUISetFont(14, 400, 1, "DOSLike") GUICtrlCreateLabel("Number: ", 20, 25, 70, 20) $Input1 = GUICtrlCreateInput("555-123-456", 100, 20, 200, 25) $btnOK = GUICtrlCreateButton("&OK", 220, 70, 80, 30, 0) $btnToggleIns = GUICtrlCreateButton("Toggle INS", 100, 70, 100, 30, 0) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $btnOK Exit Case $btnToggleIns $iIns_Is_ON = Not $iIns_Is_ON GUICtrlSetState($Input1, $GUI_FOCUS) _GUICtrlEdit_SetSel($Input1, 0, 0) EndSwitch WEnd Func WM_COMMAND($hWnd, $msg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0xFFFF) Local $hCtrl = $lParam Switch $nID Case $Input1 Switch $nNotifyCode Case $EN_CHANGE;, $EN_UPDATE ; Edit (Input) control has been changed If Not $iIns_Is_ON Then Return $GUI_RUNDEFMSG Local $aSelection = _GUICtrlEdit_GetSel($Input1) Local $sInput_Data = GUICtrlRead($Input1) If $aSelection[0] <> $aSelection[1] Then Return $GUI_RUNDEFMSG GUICtrlSetData($Input1, StringLeft($sInput_Data, $aSelection[0]) & StringMid($sInput_Data, $aSelection[0]+2)) _GUICtrlEdit_SetSel($Input1, $aSelection[0], $aSelection[0]) Case $EN_SETFOCUS ; Edit (Input) control has focus If Not $iIns_Is_ON Then Return $GUI_RUNDEFMSG DllCall('user32.dll', 'int', 'CreateCaret', 'hwnd', $lParam, 'ptr', $hBitmap, 'int', 0, 'int', 0) Sleep(10) DllCall("User32.dll", 'int', 'SetCaretPos', 'int', $aCaret_Opts[2], 'int', $aCaret_Opts[3]) DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', $aCaret_Opts[4]) DllCall('user32.dll', 'int', 'ShowCaret', 'hwnd', $lParam) Case $EN_KILLFOCUS ; Edit (Input) control lost focus If Not $iIns_Is_ON Then Return $GUI_RUNDEFMSG DllCall('user32.dll', 'int', 'HideCaret', 'hwnd', $lParam) DllCall('user32.dll', 'int', 'DestroyCaret') EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Edited May 29, 2009 by MrCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
charvi Posted May 29, 2009 Author Posted May 29, 2009 Fascinating... These are those small things put together that make AutoIt so powerful. I also appreciate the caret change when toggling the Insert mode. However, the underscore's caret is an "upperscore"... I have no clue how to put it lower at this time. Perhaps like Yashied demonstrated a while ago, with a (blinking) bitmap? It must be possible anyway, because the SciTE itself does it... I'm almost ready for the 'DOS alike Input Editor'. It will be a very long code, and rather primitive, that's why I'm asking all those questions...
MrCreatoR Posted May 29, 2009 Posted May 29, 2009 But why underscore? «Blinking solid block caret» imho looks better . Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
charvi Posted May 29, 2009 Author Posted May 29, 2009 But why underscore? «Blinking solid block caret» imho looks better .I agree 100%! But it's just for nostalgia reasons... Ah, there we see the good old DOS prompt!
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