Jump to content

Need Some Help


Recommended Posts

Hey guys, I used to be fairly versed in autoit. Anyways, I just thought of something that would be very helpful for me in work, and I'm pretty sure it's possible, I just need some push in the right direction. Basically, I need to make a program that will allow me to do this:

1. I need a window open that is in focus (This is the window that I will be interacting with through shortcut keys and through the mouse)

2. I need a window overlayed on top of it, that is transparent, and that I'm not actually interacting with, but still viewable. (This window is so I can keep what I'm doing in the first window in perspective.)

3. Ideally I'd be able to toggle not being able to interact with the 2nd window on and off.

Anyways, so I basically just need a push in the right direction as far as A. Having a window on top of a window but keeping focus on the window that is below so that I can interact with it while still keeping the transparent window on top. B. Making the top window transparent. Any information would be very useful. Thanks in advance!

Edited by spierce7
Link to comment
Share on other sites

WinSetTrans for the transparent thing

Right. I just found WinSetOnTop, and WinSetTrans. Both very applicable for what I need. I also tried accompanying that with WinSetState with the option @SW_DISABLE, but sw_disable isn't exactly what I need. It doesn't allow me to properly interact with the window below it. What else could I do?

Edited by spierce7
Link to comment
Share on other sites

There's a freeware program I think called DoubleVision which does something kida similar... check it out and see if it does what you mean :D

I need to make the app myself, since there are some specific functions I need to have available. The entire point of this is to draw something in perspective and relation with another picture. Complicated to understand why, but basically when I zoom in, I need to be able to zoom in on both, and keep them in perspective and such. It would be a lot nicer if I could make this and create some unique customizations for myself.

Link to comment
Share on other sites

I need to make the app myself, since there are some specific functions I need to have available. The entire point of this is to draw something in perspective and relation with another picture. Complicated to understand why, but basically when I zoom in, I need to be able to zoom in on both, and keep them in perspective and such. It would be a lot nicer if I could make this and create some unique customizations for myself.

bump. I need some help on this. >.< It's for work.

Link to comment
Share on other sites

bump. I need some help on this. >.< It's for work.

Whatever it's for maybe part of the answer was provided by trancexx here.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Whatever it's for maybe part of the answer was provided by trancexx here.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


Global $hGui = GUICreate("Click-through topmost GUI", -1, -1, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TRANSPARENT, $WS_EX_LAYERED)); you can omit WS_EX_LAYERED
WinSetTrans($hGui, 0, 170)
GUISetState()


While 1
    If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop; yeah right tongue.gif
WEnd

This code produces a GUI window that does exactly what I want it to! Is there a way that I can take what this window is doing, and get it to happen with a window that wasn't created by autoit, or perhaps get the autoit window to display jpg images (or another type) in such a way that I could zoom in and what not on the image?? Thanks!

Link to comment
Share on other sites

thoughts?

Look up _WinAPi_GetWindowLong and _WINAPI_SetWindowLong. Then you can change the style of a window to be like the example from trancexx.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 2 weeks later...

Look up _WinAPi_GetWindowLong and _WINAPI_SetWindowLong. Then you can change the style of a window to be like the example from trancexx.

I've looked it up, but AutoIt doesn't give very much information on it.

#Include <WinAPI.au3>

_WinAPI_SetWindowLong($hWnd, $iIndex, $iValue)

where $iIndex can be any of the following:

$GWL_EXSTYLE - Sets the extended window styles

$GWL_STYLE - Sets the window styles

$GWL_WNDPROC - Sets the address of the window procedure

$GWL_HINSTANCE - Sets the handle of the application instance

$GWL_HWNDPARENT - Sets the handle of the parent window, if any

$GWL_ID - Sets the identifier of the window

$GWL_USERDATA - Sets the 32-bit value associated with the window

I don't know what which $iIndex to choose, and I don't know what value to change it to. Anyone care to give me a little explanation? :-)

Link to comment
Share on other sites

I've looked it up, but AutoIt doesn't give very much information on it.

where $iIndex can be any of the following:

$GWL_EXSTYLE - Sets the extended window styles

$GWL_STYLE - Sets the window styles

$GWL_WNDPROC - Sets the address of the window procedure

$GWL_HINSTANCE - Sets the handle of the application instance

$GWL_HWNDPARENT - Sets the handle of the parent window, if any

$GWL_ID - Sets the identifier of the window

$GWL_USERDATA - Sets the 32-bit value associated with the window

I don't know what which $iIndex to choose, and I don't know what value to change it to. Anyone care to give me a little explanation? :-)

Well since you want to set the extended styles I think it should be fairly clear. You first find the extended style of a window then add the styles you want then set the styles.

Assuming you have Notepad started-

#include <winapi.au3>
 #include <windowsconstants.au3>
 #include <constants.au3>
 $hWnd = WInGetHandle("Untitled - Notepad")
 $CurrentXStyle = _WinAPI_GetWIndowLong($hWnd,$GWL_EXSTYLE)
;then make sure the extra styles you want are included
 $NewXStyle = BitOr($CurrentXStyle,$WS_EX_TOPMOST, $WS_EX_TRANSPARENT)
 $OldXStyle = _WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,$NewXStyle)
;$OldXStyle should be same as $CurrentXStyle 
 WinSetTrans($hWnd, 0, 170)

Seems to work.

EDIT: Corrected error; WingetHandle was WingetTitle by mistake.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Well since you want to set the extended styles I think it should be fairly clear. You first find the extended style of a window then add the styles you want then set the styles.

Assuming you have Notepad started-

#include <winapi.au3>
#include <windowsconstants.au3>
#include <constants.au3>
$hWnd = WinGetTitle("Untitled - Notepad")
$CurrentXStyle = _WinAPI_GetWIndowLong($hWnd,$GWL_EXSTYLE)
;then make sure the extra styles you want are included
$NewXStyle = BitOr($CurrentXStyle,$WS_EX_TOPMOST, $WS_EX_TRANSPARENT)
$OldXStyle = _WinAPI_SetWindowLong($hWnd,$GWL_EXSTYLE,$NewXStyle)
;$OldXStyle should be same as $CurrentXStyle 
WinSetTrans($hWnd, 0, 170)

Seems to work.

I've been running the code over and over with an untitled notepad document open, and I don't see it doing anything. What is it supposed to be doing?

Just made sure I've got the latest version of autoit, and all. I understand the code for the most part. I've never dealt with a bitor function. I just looked it up, and understand the concept of what it does, but I don't understand why what it's doing is effective unless _WinAPI_SetWindowLong is designed to read functions with styles that are combined that way.

Yeah, it's not working at all for me. I had to even change the 2nd parameter on the WinSetTrans function to get the window to go transparent at all. Had to change it from 0 to "" to make it do something. Why would it work for you and not me? What else do I need to change about the code to make it work for me? Only thing that I can think of is that maybe $hWnd is supposed to be the window handle, instead of just a title. Thoughts?

Link to comment
Share on other sites

I've been running the code over and over with an untitled notepad document open, and I don't see it doing anything. What is it supposed to be doing?

Just made sure I've got the latest version of autoit, and all. I understand the code for the most part. I've never dealt with a bitor function. I just looked it up, and understand the concept of what it does, but I don't understand why what it's doing is effective unless _WinAPI_SetWindowLong is designed to read functions with styles that are combined that way.

Yeah, it's not working at all for me. I had to even change the 2nd parameter on the WinSetTrans function to get the window to go transparent at all. Had to change it from 0 to "" to make it do something. Why would it work for you and not me? What else do I need to change about the code to make it work for me? Only thing that I can think of is that maybe $hWnd is supposed to be the window handle, instead of just a title. Thoughts?

Sorry to waste your time but somehow WingetTitle should be WinGetHandle. I've now tested it again and for good measure I've tested it in Vista and I was surprised to find it still worked!

Note that, as I said in me previous post, you must have started Notepad before running the script.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Sorry to waste your time but somehow WingetTitle should be WinGetHandle. I've now tested it again and for good measure I've tested it in Vista and I was surprised to find it still worked!

Note that, as I said in me previous post, you must have started Notepad before running the script.

Haha, perfect! Exactly what I wanted. I'm a little confused though. All we're doing is adding 2 styles to the current style. $WS_EX_TRANSPARENT, and $WS_EX_TOPMOST.

$WS_EX_TRANSPARENT = "The window appears transparent because the bits of underlying sibling windows have already been painted."

$WS_EX_TOPMOST = "Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated."

Both of these styles seem like they should edit the window in the same way that WinSetTrans, and WinSetOnTop would, but obviously something is happening that works to my advantage, but it doesn't seem like its supposed to be happening. Is this a bug or something? I guess I'm not all too sure what a window style is. Maybe that's the problem. Either way, I'm REALLY thankful for all your help so far.

Link to comment
Share on other sites

Haha, perfect! Exactly what I wanted. I'm a little confused though. All we're doing is adding 2 styles to the current style. $WS_EX_TRANSPARENT, and $WS_EX_TOPMOST.

$WS_EX_TRANSPARENT = "The window appears transparent because the bits of underlying sibling windows have already been painted."

$WS_EX_TOPMOST = "Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated."

Both of these styles seem like they should edit the window in the same way that WinSetTrans, and WinSetOnTop would, but obviously something is happening that works to my advantage, but it doesn't seem like its supposed to be happening. Is this a bug or something? I guess I'm not all too sure what a window style is. Maybe that's the problem. Either way, I'm REALLY thankful for all your help so far.

The important styles for making the window "click through" are $WS_EX_LAYERED and $WS_EX_TRANSPARENT and then making the transparency something less than 255. The style $WS_EX_TOPMOST is just to keep the window on top of others.

The reason you don't need to add the style $WS_EX_LAYERED is that the function WinSetTrans forces that style itself.

I can understand why you are surprised that the 2 styles $WS_EX_LAYERED and $WS_EX_TRANSPARENT cause this effect because I was too and I don't understand why either. I only knew by reading a post by trancexx but there is also something about it here, although I can't find the origin of the quote.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

The article that Martin posted makes a short mention of the WS_EX_NOACTIVATE style, which allows you to click or interact with the GUI without activating it, leaving the previous GUI active. (with minor exceptions)

It's not useful for "click-through" but it does keep the previous window active when clicking the inactive one.

I'm not sure how useful it will be in THIS context though, if at all.

For reference,

I actually am using this style in my Iris/Circular OSK Project (see my signature) and it seems to work great to allow the GUI to stay inactive and it to interact with the already-active window.

The only drawback is (and I'm not sure if it's AutoIt-related or not) is that moving notifications and some other messages aren't received while dragging the caption bar or other operations.

(I can perceive workarounds though - use a fake caption bar, a child window, or etc.)

Edited by crashdemons

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...