Jump to content

WinGetTitle gives different results after compilation.


Mucho
 Share

Recommended Posts

If I run the following code in SciTE, I get the first seven characters of the title. But if I run its executable, I got a "0" in the msgbox. What am I missing?

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",2)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",1)

Opt("TrayIconHide", 0)

Opt("TrayIconDebug", 1)

#include <GUIConstants.au3>

#include <GUIConstantsEx.au3>

#Include <GuiEdit.au3>

#include <Date.au3>

#include <File.au3>

#include <Array.au3>

#include <Misc.au3>

Dim $hWinActive, $WinTitle

$hWinActive = WinGetHandle("[ACTIVE]")

$WinTitle = StringLeft(WinGetTitle($hWinActive),7)

MsgBox(4096, "", $WinTitle)

Link to comment
Share on other sites

  • Moderators

Mucho,

It works for me - both in SciTE and compiled. However, I did put in a short delay so I could activate different windows to test.

When you run from SciTE the active window is obvious. Are you sure the active window is the one you think should be active when you run the executable? :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23,

Absolutely. I tested it with only one program running. When I had only Firefox running, I got the same result like the attachment.(I have a problem attaching the jpeg file. Will upload again.)

I need to get the title of the active window so that I can write a script to act on it.

Edited by Mucho
Link to comment
Share on other sites

  • Moderators

Mucho,

How are you running the compiled exe file? If you run it from Explorer (or something similar) that might make the wrong window active.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

m23,

I could get the following code to work for me, but with imperfection. It cycles through all minimized windows and I need to add an "EXIT" to prevent it from executing more than one. Please help to clean up for me or help me with a better alternative.

$ChartList = WinList ("", "Processing data")
For $Chart = 1 to UBound ($ChartList) - 2
   $Winstate = WinGetState($ChartList[$Chart][1], "")
   If BitAnd($Winstate, 16) Then
       .
       .
       .
   Else
       .
       .
       .
   Endif
   Exit
Next
Link to comment
Share on other sites

  • Moderators

Mucho,

Why not go for simplicity and add a short Sleep to your original script as I suggested earlier? :D

Then you can start your exe, reactivate the correct window by clicking on it while the script is Sleeping, and then when it awakes again it will correctly detect the active window and get to work. :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

×
×
  • Create New...