charvi Posted May 4, 2009 Author Share Posted May 4, 2009 Thanks Yashied. So the GUIRegisterMsg need to be located before the GUISetState... And the GUICtrlSetState(-1, $GUI_FOCUS) is preventing the working... That last one I don't understand why. Anyway many thanks for the solution. And yes, hiding the mouse cursor is a nice idea! See closely. ... $input = GUICtrlCreateInput("", 10, 30, 500, 21, -1, 0) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0x00ff00) ;GUICtrlSetState(-1, $GUI_FOCUS) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND"); Set the Function GUISetState() ... EDIT: Use GUISetCursor(16) for better DOS emulation. Link to comment Share on other sites More sharing options...
Yashied Posted May 4, 2009 Share Posted May 4, 2009 (edited) Thanks Yashied.So the GUIRegisterMsg need to be located before the GUISetState...And the GUICtrlSetState(-1, $GUI_FOCUS) is preventing the working...That last one I don't understand why. Anyway many thanks for the solution.And yes, hiding the mouse cursor is a nice idea! GUICtrlSetState(-1, $ GUI_FOCUS) generates a WM_COMMAND message before calling GUIRegisterMsg(). Then in your script, change of focus does not happen, and everything remains the same. Edited May 4, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
charvi Posted May 6, 2009 Author Share Posted May 6, 2009 There is just one thing I am unable to obtain, it is the position of the carret: DllCall("User32.dll", 'int', 'SetCaretPos', 'int', $iCaretX, 'int', $iCaretY) seems not willing to work. How to create an underscore instead of an upperscore? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <Constants.au3> Global $hBitmap, $h_WinMain, $hiddenbutton, $input, $iCaretW = 10, $iCaretH = 2, $iCaretX = 100, $iCaretY = 100 $h_WinMain = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) GUISetBkColor(0x000000, $h_WinMain) GUISetFont(14, 400, 0, "DOSLike") GUICtrlCreateLabel("AUTOIT-DOS 2009", 0, 0, 500, 20) GUICtrlSetColor(-1, 0xffffff) GUICtrlCreateLabel(">", 0, 30, 20, 20) GUICtrlSetColor(-1, 0xffffff) $hiddenbutton = GUICtrlCreateButton("OK", 260, 90, 100, 30, $BS_DEFPUSHBUTTON) GUICtrlSetState(-1, $GUI_HIDE) $input = GUICtrlCreateInput("", 10, 30, 500, 21, -1, 0) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0xffffff) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND"); Set the Function GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3, $GUI_EVENT_CLOSE Exit Case $hiddenbutton GUICtrlSetState($hiddenbutton, $GUI_FOCUS) GUICtrlCreateLabel("BAD COMMAND OR FILE NAME", 0, 60, 500, 20) GUICtrlSetColor(-1, 0xff0000) Sleep(1000) Exit EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If $hBitmap = "" Then $hBitmap = _WinAPI_CreateSolidBitmap(0, 0xffffff, $iCaretW, $iCaretH); color ori was 0x66FFFF Local $nNotifyCode = BitShift($wParam, 16) Switch $nNotifyCode; Edit control event messages only Case $EN_SETFOCUS; Edit (Input) control has focus DllCall('user32.dll', 'int', 'CreateCaret', 'hwnd', $lParam, 'ptr', $hBitmap, 'int', 0, 'int', 0) DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', -1); change the last value to -1 for immobile caret or to another value in milliseconds to change the blink rate (f.ex. 200) DllCall("User32.dll", 'int', 'SetCaretPos', 'int', $iCaretX, 'int', $iCaretY) DllCall('user32.dll', 'int', 'ShowCaret', 'hwnd', $lParam) Case $EN_KILLFOCUS; Edit (Input) control lost focus DllCall('user32.dll', 'int', 'HideCaret', 'hwnd', $lParam) DllCall('user32.dll', 'int', 'DestroyCaret') EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Link to comment Share on other sites More sharing options...
lordicast Posted May 6, 2009 Share Posted May 6, 2009 here's a command prompt simulation you could probably make look nicer expandcollapse popup#include <GuiConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <GuiTab.au3> #include <GuiStatusBar.au3> #include <array.au3> #include <Misc.au3> #include <GDIPlusConstants.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> #include <ie.au3> Global $Pau Global $sav HotKeySet('{del}',"back") HotKeySet('{backspace}',"back") HotKeySet('{enter}',"cmds") $Form1 = GUICreate("Test Cmd", 600, 600,@DesktopWidth/2, @DesktopHeight/2) $Edit1 = GUICtrlCreateEdit("", 0, 0, 599, 599) GUICtrlSetData(-1, 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'&@CRLF& _ 'Simulated Command Prompt'&@CRLF&'Copyright (c) blah blah'& _ 'tes test All Rights Reserved.'&@CRLF&'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'&@CRLF&@CRLF&@CRLF&'MyPrompt>') GUICtrlSetFont(-1, 10, 400, 0, "Lucida Console") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) WinSetTrans($Form1,"",185) GUISetState(@SW_SHOW) Global $sLastLine = _GUICtrlEdit_GetTextLen($Edit1) While 1 Sleep(10) _GUICTrlEdit_SetSel($Edit1, _GUICtrlEdit_GetTextLen($Edit1)+1, _GUICtrlEdit_GetTextLen($Edit1)+1) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func close() _GUICtrlEdit_AppendText($Edit1,@CRLF&"Bye Bye "&@UserName&" "&@HOUR&":"&@MIN) timeout() for $p = 125 to 0 step -5 sleep(10) WinSetTrans($form1,'',$p) Next exit EndFunc Func back() Local $sSel = _GUICtrlEdit_GetSel($Edit1) If $sSel[0] <= $sLastLine Then Return If $sSel[1] - $sSel[0] = 0 Then GUICtrlSetData($Edit1, StringTrimRight(GUICtrlRead($Edit1), 1)) Else _GUICtrlEdit_ReplaceSel($Edit1, "") EndIf EndFunc Func cmds () Local $sCmd = StringMid(GUICtrlRead($Edit1), $sLastLine+1) _GUICtrlEdit_BeginUpdate($Edit1) _GUICtrlEdit_EndUpdate($Edit1) Global $sLastLine = _GUICtrlEdit_GetTextLen($Edit1) if $sCmd = "hello" then hello() ElseIf $sCmd = "note" then run('Notepad.exe') ElseIf $sCmd = "co" then exit 0 ElseIf $sCmd = "?" then help() Else NoCom() EndIf EndFunc Func Hello() _GUICtrlEdit_AppendText($Edit1,@CRLF&"Hello World!") _GUICtrlEdit_AppendText($Edit1,@CRLF&"MyPrompt>") Global $sLastLine = _GUICtrlEdit_GetTextLen($Edit1) EndFunc Func NoCom() _GUICtrlEdit_AppendText($Edit1,@CRLF&"You didnt enter a proper command, Enter a ? to see a list off commands!") _GUICtrlEdit_AppendText($Edit1,@CRLF&"MyPrompt>") Global $sLastLine = _GUICtrlEdit_GetTextLen($Edit1) EndFunc Func help() _GUICtrlEdit_AppendText($Edit1,@CRLF&"Commands"&@CRLF&"Note - For Notepad"&@CRLF&"Hello - Flip Hellow World"&@CRLF&"Co - To close the program") _GUICtrlEdit_AppendText($Edit1,@CRLF&"MyPrompt>") Global $sLastLine = _GUICtrlEdit_GetTextLen($Edit1) EndFunc [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
charvi Posted May 6, 2009 Author Share Posted May 6, 2009 LOL, that's very nice Lordicast, I will keep your code as it can be useful... Thank you. But it does not solve my problem about the $iCaretX and $iCaretY ............ Link to comment Share on other sites More sharing options...
picaxe Posted May 7, 2009 Share Posted May 7, 2009 But it does not solve my problem about the $iCaretX and $iCaretY ............Looks like a timing issue, substituting with this version of func wm_command works for meFunc WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) If $hBitmap = "" Then $hBitmap = _WinAPI_CreateSolidBitmap(0, 0xffffff, $iCaretW, $iCaretH); color ori was 0x66FFFF Local $nNotifyCode = BitShift($wParam, 16) Switch $nNotifyCode; Edit control event messages only Case $EN_SETFOCUS; Edit (Input) control has focus DllCall('user32.dll', 'int', 'CreateCaret', 'hwnd', $lParam, 'ptr', $hBitmap, 'int', 0, 'int', 0) DllCall('user32.dll', 'int', 'SetCaretBlinkTime', 'uint', 500); change the last value to -1 for immobile caret or to another value in milliseconds to change the blink rate (f.ex. 200) Sleep(10) DllCall("User32.dll", 'int', 'SetCaretPos', 'int', $iCaretX, 'int', $iCaretY) DllCall('user32.dll', 'int', 'ShowCaret', 'hwnd', $lParam) Case $EN_KILLFOCUS; Edit (Input) control lost focus DllCall('user32.dll', 'int', 'HideCaret', 'hwnd', $lParam) DllCall('user32.dll', 'int', 'DestroyCaret') EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Link to comment Share on other sites More sharing options...
charvi Posted May 9, 2009 Author Share Posted May 9, 2009 You got the point Picaxe! But... why is this reset after the first key is pressed? 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