PDA

View Full Version : Window Find bug ?


Derek
10-09-2002, 09:38 PM
Can someone confirm this please:

<font color=blue>On Application Close
%hWnd% = Window.Find "Untitled - Notepad"
Result = Dialog.MessageBox "%hWnd%"
%PreventApplicationClose% = TRUE</font color=blue>

Test this without Notepad open and get Result = %hWnd%
Open notepad and Result = 6422722 etc.
Close notepad and Result still = 6422722

For your convenience:<font color=green>
<IR_ACTIONS_LIST>
<Action name="Find">
<Type>127</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>0</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<FindText>Untitled - Notepad</FindText>
<Variable>%hWnd%</Variable>
</Action>
<Action name="Message Box">
<Type>5</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<DialogTitle>Title</DialogTitle>
<DialogMessage>%hWnd%</DialogMessage>
<Icon>3</Icon>
<Variable>%Result%</Variable>
<DialogType>0</DialogType>
<DefaultButton>0</DefaultButton>
</Action>
<Action name="Set Value">
<Type>6</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%PreventApplicationClose%</Variable>
<Value>TRUE</Value>
<Evaluate>0</Evaluate>
</Action>
</IR_ACTIONS_LIST></font color=green>

Derek
10-10-2002, 02:35 PM
Hello?? Anyone??

Is this a bug or by design?
[would be a bit strange if it was by design]

TJ_Tigger
10-10-2002, 02:46 PM
When I tried this, without Notepad open, is listed the variable as %hwnd%, but with it open it returns a value of 5384088. When I close notepad, %hwnd% is still set to 5384088. don't know what to tell ya.

Lorne
10-10-2002, 02:55 PM
The second time around, the Window.Find action fails, since no window with "Untitled - Notepad" in the title bar can be found.

When an action fails, the variable is left alone.

All you're seeing is %hWnd% still having the same value it used to.

Add a line like %hWnd% = "FOO" above those actions (to set a default value for %hWnd% first), and you'll see what I mean.

TJ_Tigger
10-10-2002, 03:16 PM
I just remembered. A variable will not change if the item is not found. So once the value from Window.Find was set to the %%hWnd% it remains that way until set differently. try this one.

<IR_ACTIONS_LIST>
<Action name="Set Value">
<Type>6</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%hWnd%</Variable>
<Value>Default</Value>
<Evaluate>0</Evaluate>
</Action>
<Action name="Find">
<Type>127</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>0</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<FindText>Untitled - Notepad</FindText>
<Variable>%hWnd%</Variable>
</Action>
<Action name="IF">
<Type>200</Type>
<Function>1</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Condition>%hWnd% != "Default"</Condition>
</Action>
<Action name="Message Box">
<Type>5</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<DialogTitle>Title</DialogTitle>
<DialogMessage>%hWnd%</DialogMessage>
<Icon>3</Icon>
<Variable>%Result%</Variable>
<DialogType>0</DialogType>
<DefaultButton>0</DefaultButton>
</Action>
<Action name="Set Value">
<Type>6</Type>
<Function>0</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
<Variable>%PreventApplicationClose%</Variable>
<Value>TRUE</Value>
<Evaluate>0</Evaluate>
</Action>
<Action name="END IF">
<Type>201</Type>
<Function>1</Function>
<DTIndentLevel>0</DTIndentLevel>
<Enabled>1</Enabled>
<ErrorHandling>
<UserNotificationMode>2</UserNotificationMode>
<CustomErrorMessage/>
<OnErrorAction>0</OnErrorAction>
<JumpToLabel/>
</ErrorHandling>
</Action>
</IR_ACTIONS_LIST>

TJ_Tigger
10-10-2002, 03:17 PM
ya beat me to it

Derek
10-10-2002, 03:40 PM
I must be having a 'Writers Block' period in life and having a hard time with this one:

Actions follow the logic:

On Application Close -
%hWnd% = FOO
%hWnd% = Window.Find "Untitled - Notepad"
<font color=blue>IF [%hWnd% != FOO]</font color=blue>
%PreventApplicationClose% = TRUE
<font color=blue>ELSE</font color=blue>
Application.Exit
<font color=blue>END IF </font color=blue>

This works fine until I open Notepad. when I close Notepad, the runtime will not exit. Dropping in a msgbox tells me %hWnd% is now stuck on FOO after it showing as 3663373 [etc] when Notepad was open. Something isnt working right! /ubbthreads/images/icons/frown.gif
I also tried the other way around [for the sake of it]:

<font color=blue>IF [%hWnd% = FOO]</font color=blue>
Application.Exit
<font color=blue>ELSE</font color=blue>
%PreventApplicationClose% = TRUE
<font color=blue>END IF </font color=blue>

... the runtime will not close.

Lorne
10-10-2002, 04:31 PM
/ubbthreads/images/icons/smile.gif

Once %PreventApplicationClose% is set to TRUE, your application won't close until you set it back to FALSE. The Application.Exit is probably happening, but it's having no effect...

Derek
10-10-2002, 05:16 PM
Oh! Shux - yes, i forgot that. Thanx, Lorne. /ubbthreads/images/icons/smile.gif