AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Make a batch command window transparent

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
MrShortcut



Joined: 21 Jul 2009
Posts: 112

PostPosted: Sun Mar 14, 2010 10:26 pm    Post subject: Make a batch command window transparent Reply with quote

I have a batch file called pingprompt so that I don't have type ping each time I want to check a connection.

I'd like to be able to make the window Always on top, but transparent so that if I am waiting for a connection to establish I will be able to see it. I have other items in the Lead01Window but they do not relate to the attempted task.

So Far I can make the window always on Top, but I cannot make the CMD window transparent. If I bring up the properties window for the CMD window the properties window is transparent but I cannot make the actual CMD window transparent. Can this be done?

Code:

#Persistent
SetTimer, Lead01window, 300
return

Lead01window:
IfWinExist, Shortcut to pingprompt
{
WinSet, Transparent, 100
WinSet, AlwaysOnTop, On
}
return
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 2213
Location: switzerland

PostPosted: Mon Mar 15, 2010 5:42 pm    Post subject: Reply with quote

Quote:
...but I cannot make the CMD window transparent

http://www.autohotkey.com/forum/post-278986.html#278986

Code:
;-------------- DOS embedded transparent ------------
;-- http://www.autohotkey.com/forum/post-278986.html#278986

Transparent=100
wcolor = Black

; Styles we want to remove from the console window:
WS_POPUP := 0x80000000
WS_CAPTION := 0xC00000
WS_THICKFRAME := 0x40000
WS_EX_CLIENTEDGE := 0x200

; Styles we want to add to the console window:
WS_CHILD := 0x40000000

; Styles we want to add to the Gui:
WS_CLIPCHILDREN := 0x2000000

; Flags for SetWindowPos:
SWP_NOACTIVATE := 0x10
SWP_SHOWWINDOW := 0x40
SWP_NOSENDCHANGING := 0x400

; Create Gui and get window ID.
Gui, +LastFound +%WS_CLIPCHILDREN%
GuiWindow := WinExist()
WinSet, TransColor, %wcolor% %transparent%

; Launch hidden cmd.exe and store process ID in pid.
Run, %ComSpec%,, Hide, pid

; Wait for console window to be created, store its ID.
DetectHiddenWindows, On
WinWait, ahk_pid %pid%
ConsoleWindow := WinExist()

; Get size of console window, excluding caption and borders:
VarSetCapacity(ConsoleRect, 16)
DllCall("GetClientRect", "uint", ConsoleWindow, "uint", &ConsoleRect)
ConsoleWidth := NumGet(ConsoleRect, 8)
ConsoleHeight:= NumGet(ConsoleRect, 12)

; Apply necessary style changes.
WinSet, Style, % -(WS_POPUP|WS_CAPTION|WS_THICKFRAME)
WinSet, Style, +%WS_CHILD%
WinSet, ExStyle, -%WS_EX_CLIENTEDGE%

; Put the console into the Gui.
DllCall("SetParent", "uint", ConsoleWindow, "uint", GuiWindow)

; Move and resize console window. Note that if SWP_NOSENDCHANGING
; is omitted, it incorrectly readjusts the size of its client area.
DllCall("SetWindowPos", "uint", ConsoleWindow, "uint", 0
    , "int", 10, "int", 10, "int", ConsoleWidth, "int", ConsoleHeight
    , "uint", SWP_NOACTIVATE|SWP_SHOWWINDOW|SWP_NOSENDCHANGING)

; Add a button below the console.
Gui, Add, Button, % "y" ConsoleHeight+20, OK

; Show the Gui. Specify width since auto-sizing won't account for the console.
;Gui, Show, % "W" ConsoleWidth+20
W1:=(ConsoleWidth+20)
Gui, Show,x0 y0 w%W1%

; Be sure to close cmd.exe later.
OnExit, Exiting

; If cmd.exe exits prematurely, fall through to ExitApp below.
Process, WaitClose, %pid%

GuiEscape:
GuiClose:
ButtonOK:
Exiting:
OnExit
Process, Close, %pid% ; May be a bit forceful? No effect if it already closed.
ExitApp
Back to top
View user's profile Send private message
MrShortcut



Joined: 21 Jul 2009
Posts: 112

PostPosted: Mon Mar 15, 2010 7:21 pm    Post subject: Reply with quote

I tried running it but if I try and move the window it locks up and wont let me type in any command. (running XP) Do I have another option?
Back to top
View user's profile Send private message
garry



Joined: 19 Apr 2005
Posts: 2213
Location: switzerland

PostPosted: Mon Mar 15, 2010 8:14 pm    Post subject: Reply with quote

It works, must activate the DOS window to type in ( click on DOS window border )
experiment also with variables
to move use ahk gui
when see nothing press escape button to quit
ask Lexikos for details (see link)
Code:
Transparent=175
wcolor = Black
;wcolor = Red
;................
;-- last command -
esc::exitapp
Back to top
View user's profile Send private message
MrShortcut



Joined: 21 Jul 2009
Posts: 112

PostPosted: Mon Mar 15, 2010 8:48 pm    Post subject: Reply with quote

I am able to run the script but it still locks up on me after a couple of minutes. Unfortunately the reliability and match for my needs (being able to move and resize the window) isn't there with my limited knowledge. I appreciate the the help.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group