Positioning DOS window
Positioning DOS window
I need to position a DOS window.
I tried SETWINDOWPOS_ but I think that is for Windows only, and not DOS type windows.
Obviously I need the handle first and tried GETWINDOW_ but again I think that is not for DOS windows.
Any help welcomed.
Alan
I tried SETWINDOWPOS_ but I think that is for Windows only, and not DOS type windows.
Obviously I need the handle first and tried GETWINDOW_ but again I think that is not for DOS windows.
Any help welcomed.
Alan
PB v3.94 PVXP v2.13 JaPBe v2.5.4.22
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
I was recently experimenting with this... and its weird. The title you see on the console window is not the title of that window you need to use with FindWindow_(). You could try setting the classname it searches for to the console classname (its in the win32 api hlp) with no title but then you have no guarentee that the window returned is the one you want when more than one console is opened. I wish I could help ya further but I can't seem to get it workin right myself. If you find a way be sure to post it here.
This works for me on WinXP with PB 3.93...
Code: Select all
hDosWin = FindWindow_("ConsoleWindowClass", DosWindowTitle$)
SetWindowPos_(hDosWin, 0, x, y, w, h, #SWP_SHOWWINDOW)
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
On win98 pb.3.93
*Edit*
Well in fact, on win98 you can skip the class like this
Henrik
Code: Select all
hDosWin = FindWindow_("tty", "MS-DOS-prompt")
SetWindowPos_(hDosWin, 0, 10, 100, 600,400, #SWP_SHOWWINDOW)
Well in fact, on win98 you can skip the class like this
Code: Select all
hDosWin = FindWindow_(0, "MS-DOS-prompt")
SetWindowPos_(hDosWin, 0, 10, 50, 600,400, #SWP_SHOWWINDOW)
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
#Null for Class name also works for XP. Thanks for pointing that out Henrik
Code: Select all
If OpenWindow(0, 580, 0, 250, 100, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Test") And CreateGadgetList(WindowID(0))
;--> Just to keep our window on top
SetWindowPos_(WindowID(0), #HWND_TOPMOST, -1, -1, -1, -1, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
ButtonGadget(1, 75, 10, 100, 20, "Move Dos Window")
RunProgram("edit.com")
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget And EventGadgetID() = 1
hDosWin = FindWindow_(#Null, "MS-DOS Editor")
SetWindowPos_(hDosWin, 0, 0, 0, 400, 300, #SWP_SHOWWINDOW)
EndIf
Until event = #PB_Event_CloseWindow
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
In all the api samples i have messed with you can write #NULL or 0, no problemo
If you write "command" in w98 you start a dosprompt.
I never used 2003.
But do you have a window-spy program that show you the class and the text ?
In the process of making a program who send a string-part to TotalCommander i needed to make a spy first, you can have the code if you like.
It's a mess cus, the spy was only made to figure out how the heck you pass a part to TotalCmd and i stole code with arms and legs, in that part of the process.
But what the spy does is.
You click the spy buttom and point with the mouse on a window or a controle/gadget,it then show you:
1.The Objects Handler Hex / dec
2. Objects text if anny
3. Objects Class name
4. Objects Rect
Objects Parent Windows
1.The Parent Windows Handler Hex / dec
2. Parent Windows text if anny
3. Parent Windows Class name
4. Parent ProcessID
And if you press F11 it then DubClick where the mouse curser is located and send at string to that object under the mouse curser, that was the way i had to do it to send a string to TotalCmd.
Now you can have the code as is if you like, cus im not cleaning it up, it was only a bumb on the way.
This Forum oh man...
If you write "command" in w98 you start a dosprompt.
I never used 2003.
But do you have a window-spy program that show you the class and the text ?
In the process of making a program who send a string-part to TotalCommander i needed to make a spy first, you can have the code if you like.
It's a mess cus, the spy was only made to figure out how the heck you pass a part to TotalCmd and i stole code with arms and legs, in that part of the process.
But what the spy does is.
You click the spy buttom and point with the mouse on a window or a controle/gadget,it then show you:
1.The Objects Handler Hex / dec
2. Objects text if anny
3. Objects Class name
4. Objects Rect
Objects Parent Windows
1.The Parent Windows Handler Hex / dec
2. Parent Windows text if anny
3. Parent Windows Class name
4. Parent ProcessID
And if you press F11 it then DubClick where the mouse curser is located and send at string to that object under the mouse curser, that was the way i had to do it to send a string to TotalCmd.
Now you can have the code as is if you like, cus im not cleaning it up, it was only a bumb on the way.
This Forum oh man...
Sparkie,
I am using your code to close a dos window but it doesn't seem to work.
Could someone try it and confirm too.
Any solutions welcomed.
Alan
I am using your code to close a dos window but it doesn't seem to work.
Could someone try it and confirm too.
Any solutions welcomed.
Alan
Code: Select all
If OpenWindow(0, 580, 0, 250, 100, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Test") And CreateGadgetList(WindowID(0))
;--> Just to keep our window on top
SetWindowPos_(WindowID(0), #HWND_TOPMOST, -1, -1, -1, -1, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
ButtonGadget(1, 75, 10, 100, 20, "close Dos Window")
RunProgram("edit.com")
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget And EventGadgetID() = 1
hDosWin = FindWindow_(#Null, "edit.com")
DestroyWindow_(hDosWin)
EndIf
Until event = #PB_Event_CloseWindow
EndIf
End
PB v3.94 PVXP v2.13 JaPBe v2.5.4.22
Code: Select all
If OpenWindow(0, 580, 0, 250, 100, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Test") And CreateGadgetList(WindowID(0))
;--> Just to keep our window on top
SetWindowPos_(WindowID(0), #HWND_TOPMOST, -1, -1, -1, -1, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
ButtonGadget(1, 75, 10, 100, 20, "close Dos Window")
RunProgram("cmd.exe")
Repeat
event = WaitWindowEvent()
If event = #PB_EventGadget And EventGadgetID() = 1
hDosWin = FindWindow_(#Null, "C:\WINDOWS\system32\cmd.exe")
SendMessage_(hDosWin, #WM_CLOSE, 0, 0)
; DestroyWindow_(hDosWin)
EndIf
Until event = #PB_Event_CloseWindow
EndIf
End
El_Choni
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
This works under XP:
Code: Select all
Declare.l MyMain()
MyMain()
End
Procedure.l crp( sFileName.s )
CommandLine.s = sFileName
StartupInfo.STARTUPINFO
StartupInfo\cb = SizeOf(STARTUPINFO)
; StartupInfo\dwFlags = #STARTF_USESHOWWINDOW
; StartupInfo\wShowWindow = #SW_SHOW
ProcessInfo.PROCESS_INFORMATION
If CreateProcess_(0, @CommandLine, 0, 0, 0, 0, 0, 0, @StartupInfo, @ProcessInfo) = 0
; CreateProcess FAILED !
Else
ProcessExitCode.l
Repeat
; DoEvents() or anything you like ...
GetExitCodeProcess_(ProcessInfo\hProcess, @ProcessExitCode)
Until ProcessExitCode <> 259
; Delay(250)
If ProcessExitCode > 0
; Do what you have to do with Exit Code
EndIf
EndIf
EndProcedure
Procedure.l MyMain()
Protected nTmr.l
Protected sTmr.s
Protected hWndConsole.l
OpenConsole()
nTmr = GetCurrentThreadId_()
sTmr = Trim( Str( nTmr ) )
ConsoleTitle( sTmr )
hWndConsole = FindWindow_( #NULL, sTmr )
If hWndConsole
SetWindowPos_( hWndConsole, 0, 10, 10, 0, 0, #SWP_NOSIZE + #SWP_NOZORDER )
EndIf
; Do a RunProgram() to EDIT.COM here..
crp( "EDIT.COM")
EndProcedure