problem with Waitcursorchanged

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

problem with Waitcursorchanged

Post by pantik » Fri Mar 05, 2010 4:56 pm

The next code compiled works fine in all my pcs with the exception of one of them. All have the same version of s.o. The only difference is than the s.o. have just been installed but it has all drivers and it is well configured. The code is very simple and i have no idea which is the problem.

Any idea is appreciate, please. I already desisted of use this script in a virtualmachine but now i am using a typical pc with winxp.
I am causing to go crazy.

The code is the next:

Code: Select all

Onevent>KEY_DOWN,VK65,3,jointable
label>loop
Wait>0.1
goto>loop

srt>jointable
Blockinput>1
GetCursorPos>Xpos,Ypos
MouseMoveRel>594,545
WaitCursorChanged>1.5
IF>WCC_RESULT=TRUE
....
ELSE
messagemodal>error
LibFunc>kernel32,beep,r,200,50
ENDIF
MouseMove>Xpos,Ypos
Blockinput>0

end>jointable
The compiled script moves the cursor but there it hangs. it does not begin the IF command. It occurs in any window and in the desktop :? :? :?

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Fri Mar 05, 2010 7:33 pm

Hi Panik,


Try changing the MessageModal> to Message>.
You have input blocked so you can't clear the message if there is an error.

When I ran the script the OnEvent triggered when I clicked alt-a and displayed the error message. Then in continually retriggered with my hands off the keyboard. I found this out by putting a coutner in the loop and displaying the counter in the message.

For some reason OnEvent is not recognizing that the key was released.


I ran the script on XP, uncompiled from the Editor.


Gale

pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

Post by pantik » Fri Mar 05, 2010 7:57 pm

The line "messagemodal>error" only was used to debug , it is not part of the code. When i run the script in my pc i never see the message, therefore i thought the problem was in "waitcursorchanged".

The question is that this script (without "message") run fine in all my computers with the exception the one(really same computer, different partion) and i dont know why. it uses the same s.o.
I am so confused... Any idea is wellcome.

Thanks.

P.S. About reinterations you say:

This is really my code:

Code: Select all


OnEvent>KEY_DOWN,VK65,3,generica,65,jointable
label>loop
Wait>0.1
goto>loop

srt>generica
    Let>flags={1 OR 2}
    LibFunc>user32.dll,keybd_event,r,generica_var_1,0,flags,0
    Release ALT
    gosub>generica_var_2
end>generica

srt>jointable
Blockinput>1
GetCursorPos>Xpos,Ypos
MouseMoveRel>594,545
WaitCursorChanged>1.5
IF>WCC_RESULT=TRUE

....[HERE ONLY THERE ARE CURSOR MOVES AND CLIKS]

ELSE
LibFunc>kernel32,beep,r,200,50
ENDIF
MouseMove>Xpos,Ypos
Blockinput>0

end>jointable

gdyvig wrote:
For some reason OnEvent is not recognizing that the key was released.
The reason is "blockinput" and is the reason i use subroutine "generica" to avoid Onevent continually retriggered

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Fri Mar 05, 2010 9:12 pm

For me WWC_RESULT is always FALSE no matter how much I move the cursor around (when it lets me), even if the cursor icon changes.

The documentation is not clear on what WaitCursorChange is checking:
Change of cursor location?
Change of cursor icon?
Disappearance of cursor?
Cursor replaced with totally different cursor?

If it is cursor location you are interested in, maybe you should do GetCursorPos in a loop until Xpos or Ypos change.


Gale

pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

Post by pantik » Fri Mar 05, 2010 10:42 pm

You can try changue coordinates to a location where the cursor change, for examle, a internet explorer link. In any case, waitcursorchanged must be continue with WCC_RESULT false or true.

The question is the script works perfectly for me in 2 pcs but it does not work in my other s.o. in other partition. The script does not execute the "if" sentence. As i said, same s.o. and same machine. I dont understand why. I have tried a hundred of things.

I wonder if i need enable any service of windows or install any stuff.

:idea: :idea: :idea: This is very weird.

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Fri Mar 05, 2010 11:49 pm

You will probably need someone other than me at this point. Check your Windows install on the partition where the script is not working correctly. Is it installed differently there? Different drive letters? Different OS?

Gale

pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

Post by pantik » Sat Mar 06, 2010 12:22 am

gdyvig wrote: Is it installed differently there? Different drive letters? Different OS?

Gale
No,No,No :)

Thank you very much anyway. I hope marcus or other one can help me. The key is in "waitcursorchanged". I can run correctly others script which does not use this command.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Mar 06, 2010 4:39 am

I don't know why WaitCursorChanged is failing. It fails for me also. Try this instead. Uses the GetCursor API function to create our own version of WaitCursorChanged. A little more complicated but it works for me. I remarked out your blockinputs. I find the function irritating and it doesn't seem to be needed for testing. Waiting to a count of 200 takes about 3 seconds on my computer. You could either play with the number until you get a timeout you like or you could create a more fancy timing scheme using VBScript.

Hope this is helpful.

Code: Select all

OnEvent>KEY_DOWN,VK65,3,generica,65,jointable
label>loop
Wait>0.1
goto>loop

srt>generica
    Let>flags={1 OR 2}
    LibFunc>user32.dll,keybd_event,r,generica_var_1,0,flags,0
    Release ALT
    gosub>generica_var_2
end>generica

srt>jointable
//Blockinput>1
GetCursorPos>Xpos,Ypos
MouseMoveRel>594,545
LibFunc>user32,GetCursor,CursorState
Let>WaitFlag=0
Label>WaitForChange
Wait>0.01
Add>WaitFlag,1

If>WaitFlag>200
  Let>WCC_RESULT=FALSE
  Goto>StopWaiting
EndIf

LibFunc>user32,GetCursor,NewCursorState
If>%NewCursorState%<>%CursorState%
  Let>WCC_RESULT=TRUE
  Goto>StopWaiting
EndIf

Goto>WaitForChange
Label>StopWaiting
IF>WCC_RESULT=TRUE
MDL>ok
....[HERE ONLY THERE ARE CURSOR MOVES AND CLIKS]

ELSE
MDL>fail
LibFunc>kernel32,beep,r,200,50
ENDIF
MouseMove>Xpos,Ypos
//Blockinput>0

end>jointable

pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

Post by pantik » Sat Mar 06, 2010 1:08 pm

Interesting. Although the script doesn't hung, it still doesn't work for me.

I have created this code for testing and always i get 65553 in the modal message when i compiled it, placing my mouse in any place.

Code: Select all


Onevent>KEY_DOWN,VK67,3,Cursor
label>loop
Wait>0.01
goto>loop

srt>Cursor
   LibFunc>user32,GetCursor,CursorState
   mdl>CursorState
end>Cursor

On the other hand, All of my script works correctly with "waitcursorchanged" in my other partition (same o.s., drivers version, etc).

I am sure that if marcus say us as waitcursorchanged works, i will find the solution. i guess i need install something or activate any service or anything in my other hard disk partition. If I finally find the solution i would not have to changed all my code since almost all my code uses "waitcursorchanged" a lot of times.

I know my english is not too good. If you dont understand something let me know and i will try explain it with others words :)

Thanks.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sat Mar 06, 2010 4:57 pm

GetCursor is a function written by Microsoft to detect the cursor state. If the Microsoft API GetCursor is not reporting cursor differences, then there is something about the computer that is not normal. I have no clue what that might be.

I'd search the Microsoft website for "GetCursor" and "fails".

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Mar 08, 2010 9:37 am

What Dick says. WaitCursorChanged basically does exactly what Dick's home brew function does - keeps doing a GetCursor unilt it's different. In your case it seems the cursor never changes. If GetCursor - a system function built into Windows never reports a change then nor will WaitCursorChanged.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

Post by pantik » Mon Mar 08, 2010 10:52 am

Why does "waitcursorchanged" work fine in a o.s. and not in others one ?
Any idea ? Both of them are in same machine, same o.s. (win xp) and same drivers, only differents partition.

Please, i need some idea to continue trying things. i am with this for 3 days and i have no idea since this is very weird. Please help.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Mar 08, 2010 11:14 am

I have no idea. I can tell you how WaitCursorChanged works that's all.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

pantik
Junior Coder
Posts: 45
Joined: Sun Dec 13, 2009 5:52 pm

Post by pantik » Tue Mar 09, 2010 12:04 pm

I alreadly know why WaitCursorChanged does not work correctly in my scripts. After multiple attempt modifying here and there i have discovered that WaitCursorChanged works fine in all my machines when i use integer values as argument and it fails when using decimal numbers.

Maybe this give you a clue about why it fails in some machines and works correctly in anothers. I need use values above 1 like 0.5 or 0.1, so i still need your help, please.

Thanks by advance for any comment.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Mar 09, 2010 12:24 pm

WaitCursorChanged already supports decimal values. Which version of Macro Scheduler are you using?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts