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 

Tips N Tricks
Goto page Previous  1, 2, 3 ... 23, 24, 25, 26, 27  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Precise



Joined: 30 Dec 2007
Posts: 25
Location: East Coast

PostPosted: Wed Mar 26, 2008 5:24 am    Post subject: Reply with quote

Looks like if you have previously set a transcolor in the gui the animation dll calls do not work. I tested several versions of code posted in this topic. All samples work fine until you try to winset, transcolor, somecolor and then dllcall to animate. Is there a way around this that I'm unaware of?
Back to top
View user's profile Send private message
jk7800



Joined: 06 Jan 2008
Posts: 39
Location: Gdi+ v1.1

PostPosted: Wed Mar 26, 2008 2:01 pm    Post subject: Reply with quote

The gui animation (from dll) doesn't work for transparent windows. Try using a loop and a transparency/transcolor function, like this:

Code:
Loop 255
    WinSet, TransColor, FFFFFF %A_Index%, Title
Back to top
View user's profile Send private message
Precise



Joined: 30 Dec 2007
Posts: 25
Location: East Coast

PostPosted: Wed Mar 26, 2008 9:16 pm    Post subject: Reply with quote

jk7800 wrote:
The gui animation (from dll) doesn't work for transparent windows. Try using a loop and a transparency/transcolor function, like this:

Code:
Loop 255
    WinSet, TransColor, FFFFFF %A_Index%, Title


Try using ^ for what? The above code makes no sense to me logically. The window is not transparent, part of it is. I have set a transcolor and made a certain part of a gui transparent. It's obvious the dll animation doesnt work for a window with a transcolor set, that was the point in my first post.

What I'm trying to do is show the window from left to right, not fade it. To fade it there's no reason to use dllcall. The above code may be refering to fade I'm not sure. Fade in and out can easily be accomplished with winset transparent, no need to make all colors within the window transparent.
Back to top
View user's profile Send private message
jk7800



Joined: 06 Jan 2008
Posts: 39
Location: Gdi+ v1.1

PostPosted: Thu Mar 27, 2008 7:23 pm    Post subject: Reply with quote

precisewitit wrote:
Is there a way around (...)

You asked for a workaround, so I wrote it. You didn't mention what type of animation you wanted, so I wrote a workaround for fading in the gui. If you know that it won't work, than why are posting?... My script makes sense, because it works and it simply uses the transparency to fade the window (I see nothing "illogical" here). You should post a better question next time and don't criticize attempts of help...


Last edited by jk7800 on Fri Aug 01, 2008 6:36 pm; edited 1 time in total
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Apr 30, 2008 8:44 pm    Post subject: Reply with quote

i don't know how inserting own menu to system context menu would be done.
but it would be good if we can see that tutorial on this superb tutorial list
whatever many thanks SKAN!
Back to top
netboom



Joined: 06 Jul 2008
Posts: 14

PostPosted: Sat Aug 16, 2008 2:19 pm    Post subject: Reply with quote

Hi thanks for the code it was just what i'm looking for.. although i'm having trouble adapting it.

I want to switch between two windows every time i press "a" how would i change the script to release the focus and then reapply it? heres what i have so far but i'm not sure how to let the focus go.

Code:

WinGet, myarray, List, ahk_class ATL:00420130,,gamers

a::

SetBatchLines -1
Process, Priority,, High
DetectHiddenWindows, On                         ; Since Notepad is launched hidden

IfWinActive, ahk_id %myarray1%
{
   
   
   ;WinSet, AlwaysOnTop, Off, ahk_id %myarray1%
   ;WinSet, AlwaysOnTop, On, ahk_id %myarray2%
   ;WinActivate, ahk_id %myarray2%
   
   ;current = ahk_id %myarray2%
   current = %myarray2%
   goto, nextwin
}
IfWinActive, ahk_id %myarray2%
{
   
   ;WinSet, AlwaysOnTop, Off, ahk_id %myarray2%
   ;WinSet, AlwaysOnTop, On, ahk_id %myarray1%
   ;WinActivate, ahk_id %myarray0%
   ;current = ahk_id %myarray1%
   current = %myarray1%
   goto, nextwin
}

MsgBox, %current%
nextwin:



hnp := WinExist(ahk_id %current%)                ; Obtain hwnd
WinSetUnMovable( hnp )                          ; Make the window unmovable
;WinSet, AlwaysOnTop, On, ahk_id %hnp%           ; Flag it Always-On-Top
 
; SHELLHOOK method to detect active window -----------------------------------------------
; Refer Tips N Tricks : http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323

Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )

; ----------------------------------------------------------------------------------------

OnExit, QuitScript
WinActivate, ahk_id %hnp%
Return ;                                                 // End of Auto-Execute Section //

ShellMessage( wParam,lParam ) {
  global hnp
  If ( wParam=4 && lParam<>hnp ) ; any window other than notepad is activated
       WinActivate, ahk_id %hnp%
  If ( wParam=2 && lParam=hnp ) ; if Notepad window is closed/destroyed
       ExitApp
}

WinSetUnMovable( hwnd ) {
  hSysMenu:=DllCall("GetSystemMenu","Int",hWnd,"Int",FALSE)
  nCnt:=DllCall("GetMenuItemCount","Int",hSysMenu)
  DllCall("RemoveMenu","Int",hSysMenu,"UInt",nCnt-6,"Uint","0x400")
  DllCall("DrawMenuBar","Int",hWnd)
}   

QuitScript:
 ;PostMessage, 0x112, 0xF060,,, ahk_id %hnp%
 ExitApp
Return
Back to top
View user's profile Send private message
helper
Guest





PostPosted: Sun Aug 17, 2008 1:27 pm    Post subject: Reply with quote

netboom wrote:
Hi thanks for the code it was just what i'm looking for.. although i'm having trouble adapting it.

I want to switch between two windows every time i press "a" how would i change the script to release the focus and then reapply it?


Here is the (untested) code with most commented lines removed, and with
important re-arrangement of the code blocks/functions.

It may still not work, but the re-arrangement should increase your chance of success.
Code:
SetBatchLines -1
Process, Priority,, High
WinGet, myarray, List, ahk_class ATL:00420130,,gamers ; <---- gets list of window handles

OnExit, QuitScript

Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )

Return ;                                                 // End of Auto-Execute Section //
; ----------------------------------------------------------------------------------------
a::
IfWinActive, ahk_id %myarray1%
{
   current = %myarray2%
   goto, nextwin
}
IfWinActive, ahk_id %myarray2%
{
   current = %myarray1%
   goto, nextwin
}
return
; ---------------------------------------------------------------------------------------
nextwin:
  if ( lastCurrent = current)                 ; if current window was last processed, return
    return
  lastCurrent := current                      ; update last processed window
; MsgBox, %current%
;  hnp := WinExist(ahk_id %current%)               ; Obtain hwnd
  hnp := current                  ; <----- current already has window handle
  WinActivate, ahk_id %hnp%
  WinSetUnMovable( hnp )                          ; Make the window unmovable
  WinSet, AlwaysOnTop, On, ahk_id %hnp%           ; Flag it Always-On-Top
  return
; ----------------------------------------------------------------------------------------

; SHELLHOOK method to detect active window -----------------------------------------------
; Refer Tips N Tricks : http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323

ShellMessage( wParam,lParam ) {
  global hnp
  If ( wParam=4 && lParam<>hnp ) ; any window other than ahk_id %hnp%  is activated
       WinActivate, ahk_id %hnp%
  If ( wParam=2 && lParam=hnp ) ; if ahk_id %hnp%  window is closed/destroyed
       ExitApp
}
; -----------------------------
WinSetUnMovable( hwnd ) {
  hSysMenu:=DllCall("GetSystemMenu","Int",hWnd,"Int",FALSE)
  nCnt:=DllCall("GetMenuItemCount","Int",hSysMenu)
  DllCall("RemoveMenu","Int",hSysMenu,"UInt",nCnt-6,"Uint","0x400")
  DllCall("DrawMenuBar","Int",hWnd)
}   
; -----------------------------
QuitScript:
 ;PostMessage, 0x112, 0xF060,,, ahk_id %hnp%
 ExitApp
Return
Back to top
helper
Guest





PostPosted: Sun Aug 17, 2008 1:41 pm    Post subject: Reply with quote

helper wrote:
Code:
a::
IfWinActive, ahk_id %myarray1%
{
   current = %myarray2%
   goto, nextwin
}
IfWinActive, ahk_id %myarray2%
{
   current = %myarray1%
   goto, nextwin
}
return

On re-examining the code, if the main body of the previously posted code does what you want, this code will have to be re-written to suit your needs. Once one of the windows has been tagged as "always on top and in focus", your a:: hotkey will not work because the tagged window will always be active. Wink
Back to top
Serenity



Joined: 08 Nov 2004
Posts: 1272

PostPosted: Wed Sep 03, 2008 11:15 pm    Post subject: Reply with quote

Some really nice tips here, thanks Skan. Smile

The two screenshots of Calculator are the same image.

Re: How to enable Drag for a GUI without a Titlebar?, I thought I'd mention you can also use OnMessage to capture LButton anywhere in the gui. I used this method for a moveable "tooltip", like the download bar in uTorrent:

Code:
Gui, -Caption +Border +ToolWindow +AlwaysOnTop
Gui, Show, w200 h13
OnMessage( 0x200, "WM_MOUSEMOVE" )
return

WM_MOUSEMOVE( wparam, lparam, msg, hwnd )
{
   if wparam = 1 ; LButton
      PostMessage, 0xA1, 2,,, A ; WM_NCLBUTTONDOWN
}

_________________
"Anything worth doing is worth doing slowly." - Mae West
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 7185

PostPosted: Wed Sep 03, 2008 11:20 pm    Post subject: Reply with quote

Serenity wrote:
Some really nice tips here, thanks Skan. Smile


Thanks! Smile

Quote:
The two screenshots of Calculator are the same image.


Many thanks. Shocked I must have messed it up when I rectified all of the http://www.autohotkey.net links which were not working.

Also, thanks for the WM_MouseMove tip.

Smile
_________________
Suresh Kumar A N
Back to top
View user's profile Send private message
shajul



Joined: 15 Sep 2006
Posts: 99

PostPosted: Sun Sep 14, 2008 6:56 am    Post subject: Help!! Reply with quote

I would greatly appreciate help on these two functions..

The first one gives the same result on using any of the given flags.

The second one makes my program unresponsive till the function returns, but otherwise works well.

Could you tell me how to ?? isolate that thread (or do something better Wink )

Thanks for your response.





SKAN wrote:
Quote:
How to find Internet Connection Status ?
http://www.autohotkey.com/forum/viewtopic.php?p=60892#60892

Function ConnectedToInternet( Flag )

Quote:

ConnectedToInternet() should work with all Windows OS.


    0x40 INTERNET_CONNECTION_CONFIGURED - Local system has a valid connection to the Internet, but not be currently connected.
    0x02 INTERNET_CONNECTION_LAN - Local system uses a local area network to connect to the Internet.
    0x01 INTERNET_CONNECTION_MODEM - Local system uses a modem to connect to the Internet.
    0x08 INTERNET_CONNECTION_MODEM_BUSY - No longer used.
    0x20 INTERNET_CONNECTION_OFFLINE - Local system is in offline mode.
    0x04 INTERNET_CONNECTION_PROXY - Local system uses a proxy server to connect to the Internet

    MSDN Reference: List of WinINet Functions

    The Function:
Code:
ConnectedToInternet(flag=0x40) {
Return DllCall("Wininet.dll\InternetGetConnectedState", "Str", flag,"Int",0)
}

    Copy-Paste-Try Example:
Code:
If ConnectedToInternet()
   Msgbox, 64, WinInet.dll, ONLINE!
else
   Msgbox, 48, WinInet.dll, OFFLINE!
Return

ConnectedToInternet(flag=0x40) {
Return DllCall("Wininet.dll\InternetGetConnectedState", "Str", flag,"Int",0)
}


Credits:
Thanks to Jon for his Post @ How to deal with dllcall returning boolean TRUE/FALSE? ( jordi )
Thanks to Chris for his Post @ the same topic suggesting corrections.



Quote:
Edit : 07-Oct-2006

Here is an another method using an URL to ascertain Internet Connected Status :


Code:
URL := "http://www.autohotkey.com"

If InternetCheckConnection(URL)
   Msgbox, 64, WinInet.dll  [%URL%], Connection Success!
else
   Msgbox, 48, WinInet.dll  [%URL%], Connection Failed!

Return

; The Function

InternetCheckConnection(Url="",FIFC=1) {
Return DllCall("Wininet.dll\InternetCheckConnectionA", Str,Url, Int,FIFC, Int,0)
}


Reference: Request by meter @ Help with Wininet.dll\InternetCheckConnection

Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
SKAN



Joined: 26 Dec 2005
Posts: 7185

PostPosted: Sun Sep 14, 2008 7:44 am    Post subject: Reply with quote

There are two more options for you to try: IsDestinationReachable() and Ping Smile
Back to top
View user's profile Send private message
shajul



Joined: 15 Sep 2006
Posts: 99

PostPosted: Sun Sep 14, 2008 8:11 am    Post subject: Thanks Reply with quote

SKAN wrote:
There are two more options for you to try: IsDestinationReachable() and Ping Smile


Thanks SKAN very much!!
But the first one has the same problem i stated ( it makes my script unresponsive for the time of the call), please try to right click the taskbar icon while the call is in progress (upto 19 secs sometimes)

The second option just gives me unreachable inspite of being online! Am i doing something wrong (i even changed the URL to google.com)

Thanks again!
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
SKAN



Joined: 26 Dec 2005
Posts: 7185

PostPosted: Sun Sep 14, 2008 8:21 am    Post subject: Re: Thanks Reply with quote

shajul wrote:
The second option just gives me unreachable inspite of being online! Am i doing something wrong (i even changed the URL to google.com)


Code:
url=www.google.com
RunWait, ping.exe %url% -n 1,, Hide UseErrorlevel
If Errorlevel
     MsgBox,16,%url%, Destination Unreachable
Else MsgBox,64,%url%, Destination Reachable


For me, the above has been the most reliable and works for me in all OS.
Are you sure your firewall is not blocking ping.exe ? BTW, What is your OS ?

Smile
Back to top
View user's profile Send private message
shajul



Joined: 15 Sep 2006
Posts: 99

PostPosted: Sun Sep 14, 2008 8:48 am    Post subject: Thanks again! Reply with quote

Sorry SKAN, now it works..
i checked it on the command line, the problem is the response is slow, so it times out before the response and returns an Errorlevel..
It is totally cause i am using BSNL EVDO!! It is supposed to be wireless broadband, but it is slower than dial-up Embarassed

I have a broadband at my home, so will test it when i get back..

Thanks again!
_________________
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 23, 24, 25, 26, 27  Next
Page 24 of 27

 
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