Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"if w" strange behavior...
#1
Hi!
Strange behavior detected...

This one works:
 
Code:
Copy      Help
if win("Notepad" "Notepad")
,act win("Notepad" "Notepad")
else
,run "$system$\notepad.exe" "" "" "" 0x200
,rep()
,,0.01
,,if win("Notepad" "Notepad")
,,,mov+ 0.5 0 0.5 1.0 win("Notepad" "Notepad") 4
,,,break


But this one doesn't:
 
Code:
Copy      Help
int w = win("Notepad" "Notepad")
if w
,act w
else
,run "$system$\notepad.exe" "" "" "" 0x200
,rep()
,,0.01
,,if w
,,,mov+ 0.5 0 0.5 1.0 w 4
,,,break

But both macros are actually the same... How is that possible?
Actually, if Notepad is already running, the second macro detects it, and activates the window (act w). But the "else" condition is never met...

And another question, is there more elegant way to wait for the window to appear than this rep()... - construction?

Thank you for your help!
#2
Hi.
This is my QM code used to it could some help.
 
Code:
Copy      Help
;;** Declare
str WindowName = ""
str Notepad = "Notepad"    ;;** CN name?
str RunEXE = "$system$\notepad.exe"

;;** Window Check_and_run Medthod
if win(WindowName Notepad) = 0
    out "Window Is0"
    run RunEXE "" "" "" 0x200    ;;** run file patch
    wait(15 WC win(WindowName Notepad))    ;;** wait Launcher to start (15 sec)

;;** Do something
out "Window IsAlive"
int w = win(WindowName Notepad)    ;;** Get value
act w    ;;** Window Action
mov+ 0.5 0 0.5 1.0 w 4    ;;** Mouse action


Forum Jump:


Users browsing this thread: 1 Guest(s)