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 ... 19, 20, 21 ... 28, 29, 30  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
AngieX



Joined: 26 Nov 2006
Posts: 77

PostPosted: Mon Jan 29, 2007 7:17 pm    Post subject: Reply with quote

I hope you had a very very good rest! We as humans do need them most frequently! Smile I try to go to Spa once a month to relax my nerves and calm my spirit!

so..... Maybe, what I was asking was way to in-depth at this forum --- but it would be interesting to see if this beautiful jewel of gradients in some more advanced 'liquid' or fluid movements & motions. Do you have any ideas to start me off tinkering?? Remember, I am a bit of a novice hand at this, but can soak this in like a sponge, and work with parts -- if I see enough examples and explanations. Maybe I can turn something into a flower and re-post it here. A lot of people I have met on other software dev. sites would just kick you to the street for asking questions about graphics! It almost seems like a little friendly island out here called AHK-Land. Laughing
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7609

PostPosted: Wed Jan 31, 2007 6:25 pm    Post subject: Reply with quote

Dear AngieX, Smile

Quote:
it would be interesting to see if this beautiful jewel of gradients in some more advanced 'liquid' or fluid movements & motions. Do you have any ideas to start me off tinkering??


I am not sure and do not have much idea on image manipulation. But, I guess that - one can manipulate Bitmap directly in memory with GDI+
Take a look at PhiLho's topic: Image conversions and capturing with GDI

I do not have any expertise in that area Sad. Maybe you can request PhiLho in that topic.

Regards, Smile
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7609

PostPosted: Thu Feb 01, 2007 8:05 pm    Post subject: Reply with quote

Skan http://www.autohotkey.com/forum/viewtopic.php?p=97605#97605 wrote:


Dear Laszlo & Titan Smile

Laszlo wrote:
This is the shortest code I know of


Very Happy I have two versions now. One takes 5 lines and damn slow.
The other one is a 6 liner, but somewhat faster ..

toHexing a 190kb file in my 1.4Ghz Sempron takes:

Laszlo version: 730ms
Titan version: 710ms

My 6 Liner: 1320ms
My 5 Liner: 1930ms

Shortest code need not be the fastest .... I am learning

Sad Sad Sad


Here is my version:

Code:
toHex( ByRef V, ByRef H, dataSz=0 )  {
P := ( &V-1 ), VarSetCapacity( H,(dataSz*2) ), Hex := "123456789ABCDEF0"
Loop, % dataSz ? dataSz : VarSetCapacity( V )
     H  .=  SubStr(Hex, (*++P >> 4), 1) . SubStr(Hex, (*P & 15), 1)
}


Takes more than twice the time than Titans fastest version, but the technique used has been helpful for me in my ChooseColor function.

Smile

Edit: It requires an additional VarSetCapacity !
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4668
Location: Boulder, CO

PostPosted: Thu Feb 01, 2007 9:49 pm    Post subject: Reply with quote

Since AHK allows multiple commands in the same line, the number of lines are not the best measure of the code size. One could count the number of instructions, but that is misleading, too. For example func1(func2(func3,x),y),z) is a single instruction, but it performs 3 function calls.

Skan, your code has the dangerous expression SubStr(Hex, (*++P >> 4), 1) . SubStr(Hex, (*P & 15), 1). There is no guaranty that a future version of AHK will execute ++P before the reference to P in the second SubStr call. It is unlikely, that it will ever be the other way, but you are relying on an undocumented feature of AHK, which might change without a warning. (Documented features change, too, but they are always listed in the change log.)

If you plan to do large hex conversions, you can go one step further, and setup a full byte substitution table outside of the hex conversion function. It could give a little speedup.

Yet another idea was to use the dynamic variable references of AHK, instead of SubStr. It would be interesting to know, which is faster.
Code:
SetFormat Integer, Hex
Loop 256
   Hex .= SubStr(A_Index+255,4,2)           ; byte table
SetFormat Integer, Dec
Loop 255
   H_%A_Index% := SubStr(Hex,2*A_Index+1,2) ; H_0, H_1,...H_255 = 00, 01,...ff
H_0 = 00

toHex1(s:="@AB" chr(1), h, 5)
MsgBox %h%
toHex2(s:="@AB" chr(1), h, 5)
MsgBox %h%
toHex3(s:="@AB" chr(1), h, 5)
MsgBox %h%

toHex0(ByRef b, l = 0) {                    ; Titan'
   f := A_FormatInteger
   p := &b
   SetFormat, Integer, h
   Loop % l ? l : VarSetCapacity(b)
      h .= *p++
   SetFormat Integer, %f%
   Return RegExReplace(RegExReplace(h, "0x(.)(?=0x|$)", "0$1"), "0x")
}

toHex1( ByRef V, ByRef H, dataSz=0)  {      ; Skan'
   P := &V
   VarSetCapacity( H, dataSz*2 )
   Hex = 123456789ABCDEF0
   Loop % dataSz ? dataSz : VarSetCapacity(V)
      H .=  SubStr(Hex, *P >> 4, 1) . SubStr(Hex, *P++ & 15, 1) ; Danger!
}

toHex2( ByRef V, ByRef H, dataSz=0)  {      ; Skan**2
   Global Hex
   P := &V
   VarSetCapacity( H, dataSz*2 )
   Loop % dataSz ? dataSz : VarSetCapacity(V)
      H .=  SubStr(Hex, *P++*2+1, 2)
}

toHex3( ByRef V, ByRef H, dataSz=0)  {      ; Dynamic vars
   P := &V
   VarSetCapacity( H, dataSz*2 )
   Loop % dataSz ? dataSz : VarSetCapacity(V)
      i := *P++, H .=  H_%i%
}

Most of the running time is spent in the loop, so the fastest algorithm will always be with the simplest instruction in the body of the loop. It is Titan's "h .= *p++", or "h .= *(p+A_Index)" with a prior "p := &V-1". This later version could be slightly faster, because it does not store the incremented value of p.
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7609

PostPosted: Fri Feb 02, 2007 7:16 pm    Post subject: Reply with quote

Laszlo wrote:
Since AHK allows multiple commands in the same line, the number of lines are not the best measure of the code size. One could count the number of instructions, but that is misleading, too. For example func1(func2(func3,x),y),z) is a single instruction, but it performs 3 function calls.


True .. I do not claim my code is shorter.

Laszlo wrote:
Skan, your code has the dangerous expression SubStr(Hex, (*++P >> 4), 1) . SubStr(Hex, (*P & 15), 1). There is no guaranty that a future version of AHK will execute ++P before the reference to P in the second SubStr call . It is unlikely, that it will ever be the other way, but you are relying on an undocumented feature of AHK, which might change without a warning. (Documented features change, too, but they are always listed in the change log.)


Yes Sir! .. I am aware of it after reading your informative posts in the topic Lite Decimal to Binary (and vice versa) Conversion Functions. But I had written toHex() and ChooseColor() prior to it ( for a tutorial - which I have dropped ). My version of the toHex() is pretty slower for large hex conversions and I would happily use Titans' version. But ChooseColor() has been written for my ColorPicker GENIE, and I will be quick enough to change it if the code breaks with a future AHK version.

Thanks for showing the right way and for rectifying my version of toHex().

Laszlo wrote:
Most of the running time is spent in the loop, so the fastest algorithm will always be with the simplest instruction in the body of the loop. It is Titan's "h .= *p++", or "h .= *(p+A_Index)" with a prior "p := &V-1". This later version could be slightly faster, because it does not store the incremented value of p.


Yes Sir .. I am learning. Many Thanks again.

Regards, Smile
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Fri Feb 02, 2007 7:25 pm    Post subject: Reply with quote

Quote:
func1(func2(func3,x),y),z) is a single instruction, but it performs 3 function calls


Actually it is 2 function calls and a syntax error... Shocked
I would expect more from you.. Wink
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4668
Location: Boulder, CO

PostPosted: Fri Feb 02, 2007 7:45 pm    Post subject: Reply with quote

ahklerner wrote:
I would expect more from you.
There was an old professor in my university, who said when confronted with a typo, that it was intentional. Checking if you pay attention. I am glad you did! Wink
Back to top
View user's profile Send private message
ahklerner



Joined: 26 Jun 2006
Posts: 1317
Location: USA

PostPosted: Fri Feb 02, 2007 7:55 pm    Post subject: Reply with quote

Very Happy
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7609

PostPosted: Fri Feb 02, 2007 7:58 pm    Post subject: Reply with quote

@Laszlo: I did not notice it.. Sad I have the habit of taking your code as granted. Very Happy
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7609

PostPosted: Tue May 22, 2007 9:17 am    Post subject: How to Hook on to Shell to receive its messages ? Reply with quote

Quote:
How to Hook on to Shell to receive its messages?
http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323

Quote:
Foreword: The shell receives messages whenever a Window is being Created/Activated/Detroyed etc. This topic discusses on hooking Shell messages and the possible uses.


RegisterShellHookWindow Function :
The difference with RegisterShellHookWindow is that the messages are received through the specified window's WindowProc and not through a call back procedure.

A basic template would look like:

Code:
Gui +LastFound
hWnd := WinExist()

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

Return ;                                                 // End of Auto-Execute Section //

ShellMessage( wParam,lParam ) {
; Execute a command based on wParam and lParam
}


The documented values for wParam are:


  1. HSHELL_WINDOWCREATED
  2. HSHELL_WINDOWDESTROYED
  3. HSHELL_ACTIVATESHELLWINDOW
  4. HSHELL_WINDOWACTIVATED
  5. HSHELL_GETMINRECT
  6. HSHELL_REDRAW
  7. HSHELL_TASKMAN
  8. HSHELL_LANGUAGE
  9. HSHELL_SYSMENU
  10. HSHELL_ENDTASK
  11. HSHELL_ACCESSIBILITYSTATE
  12. HSHELL_APPCOMMAND
  13. HSHELL_WINDOWREPLACED
  14. HSHELL_WINDOWREPLACING
  15. HSHELL_HIGHBIT
  16. HSHELL_FLASH
  17. HSHELL_RUDEAPPACTIVATED

lParam differs in type according to the value of wParam received. For most of the wParam values, the lParam is a handle to a window that can be used as ahk_id %lParam% in AHK's Window commands.

Some ideas:
The shell receives HSHELL_GETMINRECT ( with a shellhook structure ) whenever a window is being Minimised/Maximised. A script may monitor it to Minimize a window to the tray.
The shell receives HSHELL_REDRAW when a window is being Redrawn. A script may monitor it to activate a window whenever its contents are changed.

I tried experimenting and here are some examples:

Experiment 1:

In Windows XP, CTRL+ALT+DEL brings the Task Manager. The forum has seen some posts requesting a way to deny the access to Task Manager.
The following scripts detects and closes Windows Task Manager almost instantly when created.

Code:
#Persistent
SetBatchLines, -1
Process, Priority,, High

Gui +LastFound
hWnd := WinExist()

DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam ) {
  If ( wParam = 1 ) ;  HSHELL_WINDOWCREATED := 1
     {
       WinGetTitle, Title, ahk_id %lParam%
       If  ( Title = "Windows Task Manager" )
         {
           WinClose, ahk_id %lParam%
         ; Run, Calc.exe              ; instead
         }
     }
}


Experiment 2:

Hooking Shell messages provides a sure shot way of keeping a track on Last Active Window.
See: How to retrieve LAST active window? by r0lZ
The following script toggles the TopMost/TopLevel styles ( Always on Top On/OFF ) of the active window.

Code:
#Persistent
Menu, Tray, NoStandard
Menu, Tray, Add, Toggle AOT, ToggleAOT
Menu, Tray, Add,
Menu, Tray, Add, Reload, ExitScript
Menu, Tray, Add, Exit  , ExitScript
Menu, Tray, Tip, Toggle AOT
Menu, Tray, Default, Toggle AOT

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

Return ;                                          // End of Auto-Execute Section //

ShellMessage( wParam, lParam )  {
  Global LastActiveWindowID
  If ( wParam = 4 And WinExist( "ahk_id " lParam ) ) { ; HSHELL_WINDOWACTIVATED = 4
       LastActiveWindowID := lParam
  }
}

ToggleAOT:
  WinSet, AlwaysOnTop, Toggle, ahk_id %LastActiveWindowID%
Return

ExitScript:
  DllCall( "DeregisterShellHookWindow", UInt,hWnd ) ; Redundant, I guess!
  IfEqual, A_ThisMenuItem, Reload, Reload
  ExitApp
Return


Run the script.
Click on the target window to focus it.
Double click on the scripts tray icon.
The target window will be toggled between TopMost and TopLevel styles.

Experiment 3:

I have a Logitech multimedia Keyboard and have not installed the software that came with it. I was using my own OSD script which used VOLUME_UP /DN/MUTE keys as hotkeys to trigger adjustment with SoundGet / SoundSet commands.

Now I have found that, the Shell is notified ( HSHELL_APPCOMMAND ) whenever I press a mulitmedia key. The HiWord of lParam contains the value of the MM key pressed. So I have altered my Volume Change OSD script to work without HotKeys or SoundSet command.

Code:
Gui, Color, FFFFFF
Gui, -Caption +Border +AlwaysOnTop +ToolWindow +LastFound

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

Gui, Add, Picture, x5 y5 w32 h32 Icon4 vIcon1, SndVol32.exe
Gui, Add, Picture, x5 y5 w32 h32 Icon5 vIcon2, SndVol32.exe
Loop,25
  Gui, Add, Text, x+3 w5 h32 Hidden Border vText%A_Index% 0x4 ;

Return ;                                        // End of Auto-Exexute Section //

ShellMessage( wParam,lParam )   {
  If ( wParam = 12 AND ( (lParam>>16) >= 8 OR (lParam>>16) <= 10) )    {
     Gui, Show
     SoundGet, Volume, MASTER, VOLUME
     SoundGet, Mute  ,       , MUTE

     Loop, 25
       IfLessOrEqual, A_Index, % Round(Volume/4), GuiControl, Show, Text%A_Index%
       Else                                       GuiControl, Hide, Text%A_Index%

     IfEqual, Mute, On, GuiControl, Hide, Icon2
     Else               GuiControl, Show, Icon2

     SetTimer, GuiEscape, 1234
                                }                                      }
GuiEscape:
  SetTimer, GuiEscape, OFF
  Gui, Hide


Simply put, when wParam is 12 ( HSHELL_APPCOMMAND ), the HiWord of lParam contains one of the following constants:

    APPCOMMAND_BROWSER_BACKWARD = 1
    APPCOMMAND_BROWSER_FORWARD = 2
    APPCOMMAND_BROWSER_REFRESH = 3
    APPCOMMAND_BROWSER_STOP = 4
    APPCOMMAND_BROWSER_SEARCH = 5
    APPCOMMAND_BROWSER_FAVORITES = 6
    APPCOMMAND_BROWSER_HOME = 7
    APPCOMMAND_VOLUME_MUTE = 8
    APPCOMMAND_VOLUME_DOWN = 9
    APPCOMMAND_VOLUME_UP = 10
    APPCOMMAND_MEDIA_NEXTTRACK = 11
    APPCOMMAND_MEDIA_PREVIOUSTRACK = 12
    APPCOMMAND_MEDIA_STOP = 13
    APPCOMMAND_MEDIA_PLAY_PAUSE = 14
    APPCOMMAND_LAUNCH_MAIL = 15
    APPCOMMAND_LAUNCH_MEDIA_SELECT = 16
    APPCOMMAND_LAUNCH_APP1 = 17
    APPCOMMAND_LAUNCH_APP2 = 18
    APPCOMMAND_BASS_DOWN = 19
    APPCOMMAND_BASS_BOOST = 20
    APPCOMMAND_BASS_UP = 21
    APPCOMMAND_TREBLE_DOWN = 22
    APPCOMMAND_TREBLE_UP = 23
    APPCOMMAND_MICROPHONE_VOLUME_MUTE = 24
    APPCOMMAND_MICROPHONE_VOLUME_DOWN = 25
    APPCOMMAND_MICROPHONE_VOLUME_UP = 26
    APPCOMMAND_HELP = 27
    APPCOMMAND_FIND = 28
    APPCOMMAND_NEW = 29
    APPCOMMAND_OPEN = 30
    APPCOMMAND_CLOSE = 31
    APPCOMMAND_SAVE = 32
    APPCOMMAND_PRINT = 33
    APPCOMMAND_UNDO = 34
    APPCOMMAND_REDO = 35
    APPCOMMAND_COPY = 36
    APPCOMMAND_CUT = 37
    APPCOMMAND_PASTE = 38
    APPCOMMAND_REPLY_TO_MAIL = 39
    APPCOMMAND_FORWARD_MAIL = 40
    APPCOMMAND_SEND_MAIL = 41
    APPCOMMAND_SPELL_CHECK = 42
    APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE = 43
    APPCOMMAND_MIC_ON_OFF_TOGGLE = 44
    APPCOMMAND_CORRECTION_LIST = 45


Experiment 4:

While trying to study and understand the messages I wrote this crude Shell spy to monitor the messages being received by the Shell :

Code:
#Persistent
Menu,Tray,Add
Menu,Tray,Add, &Show, GuiShow
Menu,Tray,Default, &Show
Gui, Font, s9, Courier New

Gui +ToolWindow +AlwaysOnTop +Resize +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessages" )

Gui, Add, Edit, w512 h512 vMsgs hwndEditC +ReadOnly
Gui, Show, x10 y10, Shell Spy

MsgNames =
(
HSHELL_WINDOWCREATED
HSHELL_WINDOWDESTROYED
HSHELL_ACTIVATESHELLWINDOW
HSHELL_WINDOWACTIVATED
HSHELL_GETMINRECT
HSHELL_REDRAW
HSHELL_TASKMAN
HSHELL_LANGUAGE
HSHELL_SYSMENU
HSHELL_ENDTASK
HSHELL_ACCESSIBILITYSTATE
HSHELL_APPCOMMAND
HSHELL_WINDOWREPLACED
HSHELL_WINDOWREPLACING
HSHELL_HIGHBIT
HSHELL_FLASH
HSHELL_RUDEAPPACTIVATED
)

AppCommands =
(
APPCOMMAND_BROWSER_BACKWARD = 1
APPCOMMAND_BROWSER_FORWARD = 2
APPCOMMAND_BROWSER_REFRESH = 3
APPCOMMAND_BROWSER_STOP = 4
APPCOMMAND_BROWSER_SEARCH = 5
APPCOMMAND_BROWSER_FAVORITES = 6
APPCOMMAND_BROWSER_HOME = 7
APPCOMMAND_VOLUME_MUTE = 8
APPCOMMAND_VOLUME_DOWN = 9
APPCOMMAND_VOLUME_UP = 10
APPCOMMAND_MEDIA_NEXTTRACK = 11
APPCOMMAND_MEDIA_PREVIOUSTRACK = 12
APPCOMMAND_MEDIA_STOP = 13
APPCOMMAND_MEDIA_PLAY_PAUSE = 14
APPCOMMAND_LAUNCH_MAIL = 15
APPCOMMAND_LAUNCH_MEDIA_SELECT = 16
APPCOMMAND_LAUNCH_APP1 = 17
APPCOMMAND_LAUNCH_APP2 = 18
APPCOMMAND_BASS_DOWN = 19
APPCOMMAND_BASS_BOOST = 20
APPCOMMAND_BASS_UP = 21
APPCOMMAND_TREBLE_DOWN = 22
APPCOMMAND_TREBLE_UP = 23
APPCOMMAND_MICROPHONE_VOLUME_MUTE = 24
APPCOMMAND_MICROPHONE_VOLUME_DOWN = 25
APPCOMMAND_MICROPHONE_VOLUME_UP = 26
APPCOMMAND_HELP = 27
APPCOMMAND_FIND = 28
APPCOMMAND_NEW = 29
APPCOMMAND_OPEN = 30
APPCOMMAND_CLOSE = 31
APPCOMMAND_SAVE = 32
APPCOMMAND_PRINT = 33
APPCOMMAND_UNDO = 34
APPCOMMAND_REDO = 35
APPCOMMAND_COPY = 36
APPCOMMAND_CUT = 37
APPCOMMAND_PASTE = 38
APPCOMMAND_REPLY_TO_MAIL = 39
APPCOMMAND_FORWARD_MAIL = 40
APPCOMMAND_SEND_MAIL = 41
APPCOMMAND_SPELL_CHECK = 42
APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE = 43
APPCOMMAND_MIC_ON_OFF_TOGGLE = 44
APPCOMMAND_CORRECTION_LIST = 45
)
Return


ShellMessages( wP,lP ) {
  Global EditC
  Global mVal := lP
  GuiControlGet, Msgs
  Routine := GetMessageName( wP )
  IfEqual,Routine,, SetEnv, Routine, UNKNOWN
  GuiControl,, Msgs, % Msgs "`n`n" Routine "  [" wP "]"
  If IsLabel(Routine)
     GoSub, %Routine%
  ControlSend,, ^{End}, ahk_id %EditC%
}


GetMessageName( FieldN=0 ) {
  Global MsgNames
  Loop, Parse, MsgNames, `n
        IfEqual, A_Index, %FieldN%, Return, A_LoopField
}

GetAppCommand( FieldN=0 ) {
  Global AppCommands
  Loop, Parse, AppCommands, `n
        IfEqual, A_Index, %FieldN%, Return, A_LoopField
}

UNKNOWN:
HSHELL_WINDOWCREATED:
HSHELL_WINDOWACTIVATED:
HSHELL_WINDOWDESTROYED:
HSHELL_REDRAW:
HSHELL_FLASH:
HSHELL_ENDTASK:
HSHELL_WINDOWREPLACING:
HSHELL_WINDOWREPLACED:   
HSHELL_RUDEAPPACTIVATED:   

 WinGetTitle, Title, ahk_id %mVal%
 WinGetClass, Class, ahk_id %mVal%
 GuiControlGet, Msgs
 GuiControl,, Msgs
   , % Msgs "`n`nhWnd`t: " WinExist("ahk_id" mVal) "`nTitle`t: " Title "`nClass`t: " Class

Return

HSHELL_GETMINRECT:
Return

HSHELL_APPCOMMAND:
 GuiControlGet, Msgs
 GuiControl,, Msgs, % Msgs " // " GetAppCommand( mVal >> 16 )
Return

GuiClose:
 Gui, Show, Hide
Return
   
GuiShow:
 Gui, Show,
Return


It is not exhaustive, but useful to understand how the stuff works.

With the above code running, Run Calculator and change it from Standard to Scientific mode.
One will find that the Calculator window is destroyed and created again resulting in the change of handle. ( I did not know it Sad )

Interestingly I found that an undocumented ( AFAIK ) value of 0x8006 ( 32774 ) is received by the Shell whenever a Window is Flashing its Titlebar/Taskbar button. The following code activates a window that is flashing: ( not sure whether it will work for everyone ) :

Code:
Gui +LastFound

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

Return ;                                                 // End of Auto-Execute Section //

ShellMessage( wParam,lParam ) {
  If ( wParam = 0x8006 ) ;  0x8006 is 32774 as shown in Spy!
    {
      WinActivate, ahk_id %lParam%
    }
}


Case: problems activating windows by frenchSteve
If you want to contain/restrict the WinActivation to a particular class of Window, then set a condition using WinGetClass command.


Will try to post more examples when I find them Wink
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 2296

PostPosted: Tue May 22, 2007 9:52 am    Post subject: Reply with quote

Superb! I'm speechless atm. Wink
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 4250
Location: Belgrade

PostPosted: Tue May 22, 2007 10:21 am    Post subject: Reply with quote

Now, this is a real trick! Idea

Thx Skan, amazing work.
_________________
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6786
Location: France (near Paris)

PostPosted: Tue May 22, 2007 11:33 am    Post subject: Reply with quote

Wow, this answer lot of recurrent requests at once, superb!
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Thalon



Joined: 12 Jul 2005
Posts: 632

PostPosted: Tue May 22, 2007 12:19 pm    Post subject: Reply with quote

Page saved Very Happy

Thx a lot!
Thalon
_________________
AHK-Icon-Changer
AHK-IRC
deutsches Forum
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 7609

PostPosted: Tue May 22, 2007 6:08 pm    Post subject: Reply with quote

Thanks to everybody! Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 19, 20, 21 ... 28, 29, 30  Next
Page 20 of 30

 
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