Code: Select all
If OpenConsole()
Print("<> ")
ikey$ = Input()
End
EndIf
I don't know what to do and I need the generated .exe files to work correctly.
Thanks in advance for your help.
// Code-Tags added (Kiffi)
Code: Select all
If OpenConsole()
Print("<> ")
ikey$ = Input()
End
EndIf
Rule #1 in red -> viewtopic.php?t=4701jessedavis wrote: ↑Sun Feb 05, 2023 9:14 pmI can't explain why it runs on your machine but not mine except that your version of PureBasic is slightly newer.
That's what I see, too. When I run the program from File Explorer it opens but the focus remains on the File Explorer with the highlighted line. Pressing enter just re-runs the program again. If you click on the open console window it then behaves as expected.jessedavis wrote:
OK, I think I know the answer....
Code: Select all
If OpenConsole()
Print("<> ")
Repeat
Key$ = Inkey()
If Key$ <> ""
PrintN(Key$)
Else
Delay(20) ;time for breathing
EndIf
Until Key$ = Chr(27) ;escape
ikey$ = Inkey()
Print( ikey$)
Delay (1000) ;pause to collect thoughts & watch what happens
CloseConsole()
End
EndIf
Hello Jesse, I have also found that the console window displays behind the explorer window. I'm not sure of the reason, but the below resolves it and allows you to position the window.jessedavis wrote: ↑Mon Feb 06, 2023 4:09 pm Further info to help with confusion. Steps in procedure:
Code: Select all
; **
; ** Code courtesy of Mijikai, please see thread :
; ** https://www.purebasic.fr/english/viewtopic.php?p=590749#p590749
; **
Procedure Set_Up_Console()
Define librno.i
Define handle.i
Define hwnd.i
Define csbi.CONSOLE_SCREEN_BUFFER_INFO
Define conoffset.i
Define conlength.i
Define cx, cy
OpenConsole()
librno.i=OpenLibrary(#PB_Any,"kernel32.dll")
hwnd.i=CallFunction(librno.i,"GetConsoleWindow")
CloseLibrary(librno.i)
handle = GetStdHandle_(#STD_OUTPUT_HANDLE)
If handle <> #INVALID_HANDLE_VALUE
If GetConsoleScreenBufferInfo_(handle,@csbi)
If SetConsoleTextAttribute_(handle,#BACKGROUND_BLUE|#BACKGROUND_GREEN|#BACKGROUND_RED)
FillConsoleOutputAttribute_(handle,#BACKGROUND_BLUE|#BACKGROUND_GREEN|#BACKGROUND_RED,csbi\dwSize\x * csbi\dwSize\y,conoffset,@conlength)
EndIf
EndIf
EndIf
cx = GetSystemMetrics_(#SM_CXSCREEN);
cy = GetSystemMetrics_(#SM_CYSCREEN);
SetWindowPos_(hwnd,#Null,-5, 100,#Null,#Null,#SWP_NOSIZE|#SWP_NOZORDER)
EndProcedure
If OpenConsole()
Set_Up_Console()
Print("<> ")
ikey$ = Input()
End
EndIf
That's what the forum is here for Jesse. Probably others more enlightened than I am will be able to explain it, but I'm not sure why the console is invoked as a background window, or even if this only happens in certain cases. I'm sure we'll find out what's going on.jessedavis wrote: ↑Mon Feb 06, 2023 7:15 pm Thanks a lot. This appears to work as expected. I am not really sure how I would have figured this out from the docs without your help.