import time print("Hello, World!") time.sleep(5) # pause 10 seconds wait = input("PRESS ENTER TO CONTINUE")
Notes
Download Python from here: https://www.python.org/downloads/
Load Script into IDLE
Execute — Run Module
Lab Core | The Lab of MrNetTek
A blog about IT, technical solutions, and code.
import time print("Hello, World!") time.sleep(5) # pause 10 seconds wait = input("PRESS ENTER TO CONTINUE")
Notes
Download Python from here: https://www.python.org/downloads/
Load Script into IDLE
Execute — Run Module
// Setup Information Lines static void returnHelp() { system("Color 1A"); //add some color system("CLS"); // clears the screen printf ("\n"); // add carriage return printf ("Program Information\n"); printf ("\n"); printf ("Example: Add Example Here\n"); printf ("\n"); printf ("Author: Eddie Jackson\n"); printf ("Contact: mrnettek@yahoo.com\n"); printf ("Website: http://eddiejackson.net\n"); printf ("License: Freeware\n"); }
How to write C++ console applications that print colored text?
Method 1
#include <iostream> #include <windows.h> int main() { const WORD colors[] = { 0x1A, 0x2B, 0x3C, 0x4D, 0x5E, 0x6F, 0xA1, 0xB2, 0xC3, 0xD4, 0xE5, 0xF6 }; HANDLE hstdin = GetStdHandle( STD_INPUT_HANDLE ); HANDLE hstdout = GetStdHandle( STD_OUTPUT_HANDLE ); WORD index = 0; // Remember how things were when we started CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo( hstdout, &csbi ); // Tell the user how to stop SetConsoleTextAttribute( hstdout, 0xEC ); std::cout << "Press any key to quit.\n"; // Draw pretty colors until the user presses any key while (WaitForSingleObject( hstdin, 100 ) == WAIT_TIMEOUT) { SetConsoleTextAttribute( hstdout, colors[ index ] ); std::cout << "\t\t\t\t Hello World \t\t\t\t" << std::endl; if (++index > sizeof(colors)/sizeof(colors[0])) index = 0; } FlushConsoleInputBuffer( hstdin ); // Keep users happy SetConsoleTextAttribute( hstdout, csbi.wAttributes ); return 0; } //bit 0 - foreground blue //bit 1 - foreground green //bit 2 - foreground red //bit 3 - foreground intensity //bit 4 - background blue //bit 5 - background green //bit 6 - background red //bit 7 - background intensity
Method 2
#include <iostream> int main() { while(true) { system("Color 1A"); std::cout << "\t\t\t Hello World" << std::endl; system("Color 2B"); std::cout << "\t\t\t Hello World" << std::endl; system("Color 3C"); std::cout << "\t\t\t Hello World" << std::endl; system("Color 4D"); std::cout << "\t\t\t Hello World" << std::endl; system("Color 5E"); std::cout << "\t\t\t Hello World" << std::endl; system("Color 6F"); std::cout << "\t\t\t Hello World" << std::endl; system("Color A1"); std::cout << "\t\t\t Hello World" << std::endl; system("Color B2"); std::cout << "\t\t\t Hello World" << std::endl; system("Color C3"); std::cout << "\t\t\t Hello World" << std::endl; system("Color D4"); std::cout << "\t\t\t Hello World" << std::endl; system("Color E5"); std::cout << "\t\t\t Hello World" << std::endl; system("Color F6"); std::cout << "\t\t\t Hello World" << std::endl; } return 0; }
Redirection: command > filename Redirect command output to a file command >> filename APPEND into a file command < filename Type a text file and pass the text to command commandA | commandB Pipe the output from commandA into commandB commandA & commandB Run commandA and then run commandB commandA && commandB Run commandA, if it succeeds then run commandB commandA || commandB Run commandA, if it fails then run commandB commandA && commandB || commandC If commandA succeeds run commandB, if it fails commandC Numeric handles: STDIN = 0 Keyboard input STDOUT = 1 Text output STDERR = 2 Error text output UNDEFINED = 3-9 command 2> filename Redirect any error message into a file command 2>> filename Append any error message into a file (command)2> filename Redirect any CMD.exe error into a file command > file 2>&1 Redirect errors and output to one file command > fileA 2> fileB Redirect output and errors to separate files command 2>&1 >filename This will fail! Redirect to NUL (hide errors) command 2> nul Redirect error messages to NUL command >nul 2>&1 Redirect error and output to NUL command >filename 2> nul Redirect output to file but suppress error (command)>filename 2> nul Redirect output to file but suppress CMD.exe errors
Notes
reg Query “HKLM\Hardware\Description\System\CentralProcessor\0” | find /i “x86” > NUL && set OS=32BIT || set OS=64BIT
if %OS%==32BIT goto 32Bit
if %OS%==64BIT goto 64Bit
Loading and Running EXEs
@ECHO OFF
FOR /f “tokens=*” %%A IN (‘dir /b *.exe’) DO (
ECHO Filename: “%%A”
::”%%A” /SILENTINSTALLOPTIONS
)
pause
Func _ProcessKill($iPID) Local $iTimeOut = 5, $iTimer $iTimeOut *= 1000 $iTimer = TimerInit() While ProcessExists($iPID) If TimerDiff($iTimer) > $iTimeOut Then ExitLoop EndIf RunWait('TASKKILL /F /PID ' & $iPID, @SystemDir & "\", @SW_HIDE) Sleep(20) WEnd Return Number(ProcessExists($iPID) > 0) EndFunc ;==>_ProcessKill
; _KillWindow Func _KillWindow($title) Local $Script = 'WinWait("' & $title & '", "")' & @CRLF & 'WinKill("' & $title & '", "")' Local $file_loc = @ScriptDir & "\Killer.au3" FileDelete($file_loc) FileWrite($file_loc, $Script) If @Compiled = 1 Then $file_exe = FileGetShortName(@AutoItExe & ' /AutoIt3ExecuteScript "' & $file_loc & '"') Run($file_exe) Else $file_au3 = FileGetShortName($file_loc) Run(@AutoItExe & " " & $file_au3, "", @SW_HIDE) EndIf EndFunc ;==>_KillWindow
; Notify and Name of any new process started Global $aProcessList_1 = ProcessList() AdlibRegister("_CheckProcess") While 1 Sleep(20) WEnd Func _CheckProcess() Local $aProcessList_2 = ProcessList() If $aProcessList_2[0][0] > $aProcessList_1[0][0] Then MsgBox(4096, '', 'New process: ' & $aProcessList_2[$aProcessList_2[0][0]][0]) $aProcessList_1[0][0] = $aProcessList_2[0][0] Else $aProcessList_1[0][0] = $aProcessList_2[0][0] ; If you close processes this resets the list.s EndIf EndFunc ;==>_CheckProcess
_ChangeWallpaper("c:\Documents and Settings\Pictures\MyImage.bmp",1) ; only a simple cut & paste Func _ChangeWallpaper($sFile,$iType) ; Changes the wallpaper to $sFilename using $iType as: ; 1 Tiled ; 2 Centered ; 3 Stretched ; any other value (usually 0) unchanged ; ; Returns ; 0 if everything is alright. ; -1 if $sFile does not exist. @error is set to 1 ; -2 if £sFile is not a .bmp file. @error is set to 2 If Not FileExists($sFile) Then SetError(1) Return -1 EndIf If StringTrimLeft($sFile,StringInStr($sFile,'.',0,-1)) <> 'bmp' Then SetError(2) Return -2 EndIf Select Case $iType = 1 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','1') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0') Case $iType = 2 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','0') Case $iType = 3 RegWrite('HKCU\Control Panel\Desktop','TileWallpaper','reg_sz','0') RegWrite('HKCU\Control Panel\Desktop','WallpaperStyle','reg_sz','2') Case Else EndSelect RegWrite('HKCU\Control Panel\Desktop','Wallpaper','reg_sz',$sFile) DllCall("User32.dll","int","SystemParametersInfo","int",20,"int",0,"str",$sFile,"int",0) Return 0 EndFunc
$click = _IEclickSound() ;<= off _IEclickSound($click);<== restore original state Func _IEclickSound($sound = "") If $sound <> "" Then If Not FileExists($sound) Then Return SetError(1, 0, 0) EndIf Local $rc = RegRead("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\Explorer\Navigating\.Current", "") If @error Then Return SetError(2, 0, 0) RegWrite("HKEY_CURRENT_USER\AppEvents\Schemes\Apps\Explorer\Navigating\.Current", "", "REG_EXPAND_SZ", $sound) Return $rc EndFunc ;==>_IEclickSound