AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Solved] Animated GUI Windows Causing Clipboard Set Error

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Conquer



Joined: 27 Jun 2006
Posts: 385
Location: Canada

PostPosted: Sun Apr 06, 2008 2:49 pm    Post subject: [Solved] Animated GUI Windows Causing Clipboard Set Error Reply with quote

Hey, this is my script.

Code:
#SingleInstance,Force

Gui, Add, Edit, w400 h400 vEditWp, This is a test.
Gui, Add, Button,y+5 gCopyText, Copy Text

Gui, +LastFound ; (For the line below)

If A_OsVersion = Win_XP
{
CallWndProcHook := DllCall("SetWindowsHookEx"
    ,"int",0x4  ; WH_CALLWNDPROC
    ,"uint",RegisterCallback("CallWndProc")
    ,"uint",0
    ,"uint",DllCall("GetCurrentThreadId"))
}
Gui,Show
return

CopyText:
Gui,Submit,Nohide
Clipboard := EditWp
return

CallWndProc(nCode, wParam, lParam)
{
    global CallWndProcHook
    global AntiCrash
    static Duration:=200
    static Animating:=false
    Critical
    msg := NumGet(lParam+8)
   
    if !Animating && (msg = 0x46) ; WM_WINDOWPOSCHANGING
    {
        hwnd := NumGet(lParam+12)
        DetectHiddenWindows, On
        WinGet, Style, Style, ahk_id %hwnd%
        if (Style & 0x80000000) ; WS_POPUP
        {
            flags := NumGet(NumGet(lParam+0)+24)
            if (flags & 0xC0) ; SWP_SHOWWINDOW | SWP_HIDEWINDOW
            {
                Animating := true ; Prevent recursion.
                DllCall("AnimateWindow", "uint", hwnd, "uint", Duration
                    , "uint", (flags&0x40) ? 0x80000 : 0x90000)
                Animating := false
            }
        }
    }
      return DllCall("CallNextHookEx","uint",CallWndProcHook,"int",nCode,"uint",wParam,"uint",lParam)
}

As you can see, all dialogs GUI created are animated to fade in/out.
The problem is, whenever the script uses "Clipboard = x", the script errors.



This is the error I get when I use the "Copy Text" button. The error occurs about 50% of the time.
Code:
---------------------------
ErroredScript.ahk
---------------------------
Error: SetClipboardData

   Line#
   050: }
--->   051: Return,DllCall("CallNextHookEx","uint",CallWndProcHook,"int",nCode,"uint",wParam,"uint",lParam)
   052: }
   052: Exit

---------------------------
OK   
---------------------------


Anyone have any idea how to fix this?

Ideas/Code/Suggestions/Random Comments/Spam welcome.

Wink
Thanks in advance.

ALSO: fading windows part of the script was provided by Lexikos http://www.autohotkey.com/forum/viewtopic.php?t=29900

_________________


Last edited by Conquer on Tue Apr 08, 2008 8:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
NLI-Conquer
Guest





PostPosted: Mon Apr 07, 2008 12:47 am    Post subject: Reply with quote

bump. Wink
Back to top
NLI-Conquer
Guest





PostPosted: Tue Apr 08, 2008 12:55 am    Post subject: Reply with quote

Bump x2. :/
Back to top
Guest






PostPosted: Tue Apr 08, 2008 6:17 am    Post subject: Reply with quote

Add
Code:
DllCall("OpenClipboard", uint, 0)
DllCall("EmptyClipboard")
DllCall("CloseClipboard")
before
Code:
Clipboard := EditWp
Back to top
Guest






PostPosted: Tue Apr 08, 2008 8:19 pm    Post subject: Reply with quote

Thx, mister mysterious guest! Very Happy
Back to top
NLI-Conquer
Guest





PostPosted: Tue Apr 08, 2008 8:19 pm    Post subject: Reply with quote

Solved, btw. Very Happy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group