Jump to content

kwarizmi

Members
  • Posts

    8
  • Joined

  • Last visited

kwarizmi's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. ReFran, That looks good. I am torn between this method andhe original embedding cmd.exe method. Embedding seems to give a smoother looking scrolling of th output.Embedding gives awkward horizontal scroolling during output. rats. ResNullius, A big improvement. Thanks. On my system (XPSP2) the prompt is the same fatness as i usually see it. Perhaps it has something to do with me always setting the colours to black text on white background. Cheers
  2. I considered that also, but (unless I implemented it incorrectly) it will display the output of a command line program only after the program has finished executing. I need to display the output realtime, as the program is running. This is one of the main reasons I chose to embed cmd.exe into the main window. Cheers!
  3. I thought about doing that but was unable to figure out a way to continuously get the output from the commandline into an edit box. How is that done?
  4. Here is the updated code with the simulated borderless command prompt. #include <GUIConstants.au3> #include <Constants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainWindow = GUICreate("Embed Cmd", 500, 500, 10, 10) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState (@SW_SHOW) GUIRegisterMsg(0xF, "WM_PAINT") ; create a borderless window that is a child to the main window $embedWindow = GUICREATE("", 477, 165, 15, 320, $WS_POPUP, -1, $mainWindow) DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $embedWindow, "hwnd", $mainWindow) ; launch the command prompt (black on white, without the operating system message) $pid = run("cmd.exe /T:F0 /k") ProcessWait ($pid) ; get the handle of the cmd window as i cannot be certain that there will be only one instance of the cmd running with the same window title or class $cmdHandle = _ProcessGetHWnd($pid, 2) $hWndChild = $cmdHandle[1][1] ; make the command prompt window a child to the earlier created borderless child window DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWndChild, "hwnd", $embedWindow) ; resize the command prompt window so that its bolder and title bar are outside the borderless child window ; giving the appearance of a borderless command prompt WinMove($hWndChild, '', -4, -30, 485, 206) WinSetState($hWndChild, '', @SW_SHOW) WinSetState($embedWindow, '', @SW_SHOW) ; inifinite event loop While 1 ; sleep for 100 milliseconds (to not hog the cpu) sleep(100) ; end of event loop WEnd Func CLOSEClicked() ; take care of things to do when exiting Winkill($hWndChild) Exit EndFunc Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) Sleep(100) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $hWnd, "ptr", 0, "int", 0) EndFunc ;==>WM_PAINT ;=============================================================================== ; ; Function Name: _ProcessGetHWnd ; Description: Returns the HWND(s) owned by the specified process (PID only !). ; ; Parameter(s): $iPid - the owner-PID. ; $iOption - Optional : return/search methods : ; 0 - returns the HWND for the first non-titleless window. ; 1 - returns the HWND for the first found window (default). ; 2 - returns all HWNDs for all matches. ; ; $sTitle - Optional : the title to match (see notes). ; $iTimeout - Optional : timeout in msec (see notes) ; ; Return Value(s): On Success - returns the HWND (see below for method 2). ; $array[0][0] - number of HWNDs ; $array[x][0] - title ; $array[x][1] - HWND ; ; On Failure - returns 0 and sets @error to 1. ; ; Note(s): When a title is specified it will then only return the HWND to the titles ; matching that specific string. If no title is specified it will return as ; described by the option used. ; ; When using a timeout it's possible to use WinWaitDelay (Opt) to specify how ; often it should wait before attempting another time to get the HWND. ; ; ; Author(s): Helge ; ;=============================================================================== Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000) Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit() While 1 ; Get list of windows $aWin = WinList($sTitle) ; Searches thru all windows For $i = 1 To $aWin[0][0] ; Found a window owned by the given PID If $iPid = WinGetProcess($aWin[$i][1]) Then ; Option 0 or 1 used If $iOption = 1 OR ($iOption = 0 And $aWin[$i][0] <> "") Then Return $aWin[$i][1] ; Option 2 is used ElseIf $iOption = 2 Then ReDim $aReturn[UBound($aReturn) + 1][2] $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0] = $aWin[$i][0] $aReturn[$aReturn[0][0]][1] = $aWin[$i][1] EndIf EndIf Next ; If option 2 is used and there was matches then the list is returned If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn ; If timed out then give up If TimerDiff($hTimer) > $iTimeout Then ExitLoop ; Waits before new attempt Sleep(Opt("WinWaitDelay")) WEnd ; No matches SetError(1) Return 0 EndFunc ;==>_ProcessGetHWnd In the end, it does what I want, but it seems like a sloppy solution. I wish I could get it so that the command prompt window would not display until it was repositions, but if I hide it on creation, it fails to become a child of the other window. rats. Cheers!
  5. I have created a solution to embedding a borderless command prompt in a window. First I make a child window with $WS_POPUP and embedd the commend prompt in that window. Then I size the command prompt window so that it is just bigger than the child window and the command prompt window's borders and title bar are clipped outside of the child window. Not an elegant solution, but it works. I can post the code if anyone is interested. Cheers!
  6. I am trying to create a program that has cmd.exe embedded into it. However, I would like for the cmd.exe window to be borderless. Here is my code so far. #include <GUIConstants.au3> #include <Constants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainWindow = GUICreate("Embed Cmd", 500, 500, 10, 10) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState (@SW_SHOW) GUIRegisterMsg(0xF, "WM_PAINT") $pid = run("cmd.exe /T:F0 /k") ProcessWait ($pid) ; get the handle of the cmd window as i cannot be certain that there will be only one instance of the cmd running with the same window title or class $cmdHandle = _ProcessGetHWnd($pid, 2) Local $hWndChild = $cmdHandle[1][1] DllCall("user32.dll", "hwnd", "SetParent", "hwnd", $hWndChild, "hwnd", $mainWindow) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $hWndChild, "int", -20, "long", 0x80000000 + 0x40000000 + 0x40000) GuiSetStyle(BitOr($WS_POPUP, $WS_BORDER), '', $hWndChild) WinSetState($hWndChild, '', @SW_SHOW) WinMove($hWndChild, '', 1, 300, 498, 200) ; inifinite event loop While 1 ; sleep for 100 milliseconds (to not hog the cpu) sleep(100) ; end of event loop WEnd Func CLOSEClicked() ; take care of things to do when exiting exitCleanup() Exit EndFunc Func WM_PAINT($hWnd, $Msg, $wParam, $lParam) Sleep(100) DllCall("user32.dll", "int", "InvalidateRect", "hwnd", $hWnd, "ptr", 0, "int", 0) EndFunc ;==>WM_PAINT ;=============================================================================== ; ; Function Name: _ProcessGetHWnd ; Description: Returns the HWND(s) owned by the specified process (PID only !). ; ; Parameter(s): $iPid - the owner-PID. ; $iOption - Optional : return/search methods : ; 0 - returns the HWND for the first non-titleless window. ; 1 - returns the HWND for the first found window (default). ; 2 - returns all HWNDs for all matches. ; ; $sTitle - Optional : the title to match (see notes). ; $iTimeout - Optional : timeout in msec (see notes) ; ; Return Value(s): On Success - returns the HWND (see below for method 2). ; $array[0][0] - number of HWNDs ; $array[x][0] - title ; $array[x][1] - HWND ; ; On Failure - returns 0 and sets @error to 1. ; ; Note(s): When a title is specified it will then only return the HWND to the titles ; matching that specific string. If no title is specified it will return as ; described by the option used. ; ; When using a timeout it's possible to use WinWaitDelay (Opt) to specify how ; often it should wait before attempting another time to get the HWND. ; ; ; Author(s): Helge ; ;=============================================================================== Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000) Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit() While 1 ; Get list of windows $aWin = WinList($sTitle) ; Searches thru all windows For $i = 1 To $aWin[0][0] ; Found a window owned by the given PID If $iPid = WinGetProcess($aWin[$i][1]) Then ; Option 0 or 1 used If $iOption = 1 OR ($iOption = 0 And $aWin[$i][0] <> "") Then Return $aWin[$i][1] ; Option 2 is used ElseIf $iOption = 2 Then ReDim $aReturn[UBound($aReturn) + 1][2] $aReturn[0][0] += 1 $aReturn[$aReturn[0][0]][0] = $aWin[$i][0] $aReturn[$aReturn[0][0]][1] = $aWin[$i][1] EndIf EndIf Next ; If option 2 is used and there was matches then the list is returned If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn ; If timed out then give up If TimerDiff($hTimer) > $iTimeout Then ExitLoop ; Waits before new attempt Sleep(Opt("WinWaitDelay")) WEnd ; No matches SetError(1) Return 0 EndFunc ;==>_ProcessGetHWnd I have included Helge's ProcessGetHWnd inside the code rather than include it just to make it easier to copy and run For the most part, I am happy with how it works, but I really want to get rid of that border. Any ideas? Cheers!
  7. Using Send is an option, but it has undesirable results in that (as far as i can tell) I need to make the mplayer window active before using Send and then make the previously active window active again. This is a problem in that if i happen to be typing in another program at the time the Send command is executed, i sometimes get the keystrokes in the wrong window. I have looked at several threads here in the forum and concluded that there is no way to use send with an unactive window. In other threads ControlSend was suggested, but for me it only works if the mplayer window is active. Mplayer has a slave mode where commands can be sent to it with stdin. So I tried launching mplayer with the $STDIN_CHILD flag and then sending commands to it with StdinWrite. This also does not work as in Windows the stdin does not work with mplayer, but in Java (in Windows), the solution is to use out.print (commands are sent to mplayer without it needing to be the active window). With the $STDIN_CHILD flag set, Send also stops working with mplayer. Any ideas? Cheers!
  8. I am trying to use AutoIt to automate a console program (MPlayer). In Java, commands are sent to the program (MPlayer) using out.print. Does anyone know how to do the equivalent using AutoIt. Cheers!
×
×
  • Create New...