Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get Current Focus
There are several dialog boxes where I would like to toggle and get the Window names. How is this possible?

I would like to use clo command to close the Windows I dont need. I just cant get it to work.

What means "toggle"?

Copy      Help
[color=blue]int [/color]hwnd=[color=blue]win [/color][color=green];;get currently active window[/color]
[color=blue]if wintest[/color](hwnd "Dialog1") [color=green];;if it is Dialog1[/color]
,[color=blue]clo [/color]hwnd [color=green];;close[/color]
[color=blue]else if wintest[/color](hwnd "Dialog2") [color=green];;if it is Dialog2[/color]
[color=blue]str [/color]s.getwintext(hwnd)
[color=blue]sel [/color]s
,[color=blue]case [/color]"Dialog1"
,[color=blue]clo [/color]hwnd
,[color=blue]case [/color]"Dialog2"

[color=blue]if find[/color](s "Dialog1")>=0
,[color=blue]clo [/color]hwnd
[color=blue]else if find[/color](s "Dialog2")>=0


Copy      Help
[color=blue]int [/color]hwnd=[color=blue]win[/color]("Dialog1") [color=green];;get handle of window Dialog1[/color]
[color=blue]if[/color](hwnd) [color=blue]clo [/color]hwnd [color=green];;if this window exists, close it[/color]

hwnd=[color=blue]win[/color]("Dialog2") [color=green];;get handle of window Dialog2[/color]
[color=blue]if[/color](hwnd) [color=blue]act [/color]hwnd [color=green];;if this window exists, activate it
Great thanks so much.

How about getting current selected list item from a listbox with a style of SysListView32 id is 100?
What you will do with it?

You cannot get listview item handle, because it is not a window. But you can get it as accessible object. You can capture it with "Find accessible object" dialog. Also, you can get list view item text with GetListViewItemText function.
Great, Ill try GetListViewItemText instead.

Here's another scenario. I have 2 macros. First one is played on a normal fashion using a HotKey. The second one is triggered by a specific window.

When the first macro plays, it enables the Window and the second macro starts playing.

Is this how it's suppose to work? Can two macros actually run simultaneously? Which one would have more preference?

Oh and BTW, it crashed my 98 machine Smile)
Two items of type Macro (green triangle icon) cannot run simultaneously. By default, second macro does not start if one is already running. Items of type Function (light blue brick icon) don't have such restriction, and run simultaneously, with equal priority.

If you can provide more info about the crash, email me.
Well, both were regular macros, not functions and somehow both run at the same time making Win 98 crash.

I also tried making the trigger window into a function. So while the regular macro is running and the speicifc window pops up, the function will close it. But I can't get it to work. After the function runs, it does not return the control back to the macro, even after adding RET at the end of the function.

Am I doing something wrong? This feature is going to be helpful. It will eliminate the need of adding the checking of the window in the regular macro.

Please export both macros and email me as attachments. Or post here as attachments.
The trigger functions are now working, I was doing it all wrong. TYVM

I tried using GetListViewItemText command to get 3rd column value which is numeric. When I do an if statement, it doesnt seem to recognize it as numeric. Code below:

Copy      Help
str vCounter
GetListViewItemText(hlv -1 &vCounter 2 2)
if vCounter<5
    mes "5 or less"
    mes "5 or more"

What is it I'm doing wrong? I keep on getting "5 or more" even if its "2"
For numbers, always use variables of type int or other numeric types. For text, use variables of type str. To convert a string, that begins with a number, to number, use function val. Conversion number-to-string is automatic.

str s="5 cows"
int i=val(s) ;;now i is 5
s=i ;;now s is "5"

Copy      Help
str s; int vCounter
GetListViewItemText(hlv -1 s 2 2)
if vCounter<5
,mes "5 or less"
,mes "5 or more"
Do you also have a function for SETLISTVIEWITEM? :lol: or something similar that will select an item from a listbox?

Thanks you so much!
No, but you can use accessible object functions. Example:

Copy      Help
run "C:\WINDOWS"
Acc a=acc("Fonts" "LISTITEM" "WINDOWS" "SysListView32" "" 0x1001)
Do you happen to have a function already built in to get item count from a listbox or combobox?

Copy      Help
n=SendMessage(hwndCb CB_GETCOUNT 0 0)
n=SendMessage(hwndLb LB_GETCOUNT 0 0)

Forum Jump:

Users browsing this thread: 1 Guest(s)