Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Crazy Scripting : List of Win32 CONSTANTS


  • Please log in to reply
14 replies to this topic
SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Newer Version

Posted Image

[*:1eq7vhl2]Large database with 52927 constants ( thanks to corrupt )
[*:1eq7vhl2]Data stored in INI file. Easy to add missing Constants.
[*:1eq7vhl2]Constant dependencies are resolved automatically.

Usage:
Search your constants in ComboBox and select them with {Enter} key or using 'Select constant' button
Constants will be added to ListView, along with dependencies, if any.
Once done, use 'Copy List to Clipboard' button and do a paste into your script.

[color=#225599]/*  

 'List of Win32 CONSTANTS' by SKAN - Suresh Kumar A N, [email protected]  
  Topic      : www.autohotkey.com/forum/viewtopic.php?t=19766
  Dependency : www.autohotkey.net/~Skan/Utils/List_of_WIN32_CONSTANTS/Constants.W32.ini
  Screenshot : www.autohotkey.net/~Skan/Utils/List_of_WIN32_CONSTANTS/Constants.W32.png

*/ ;[/color]                                  [color=#808080]Created: 05-Oct-2010 / Last Modified: 18-Oct-2010[/color]

#SingleInstance, Force
Menu, Tray,UseErrorLevel
Menu, Tray, Icon, shell32.dll, 44
SetBatchLines -1
SetWorkingDir, %A_ScriptDir%

IfNotExist, Constants.W32.ini, URLDownloadToFile
 , https://ahknet.autohotkey.com/~Skan/Utils/List_of_WIN32_CONSTANTS/Constants.W32.ini
 , Constants.W32.ini
 
If ! LoadConstants( "Constants.W32.ini", Data, Cons )
  ExitApp
  
Gui, Margin, 5, 10
Gui, +LastFound 
Gui, Font, s9 Normal, Arial
Gui, Add,  ComboBox, w480 R10 Simple 0x2000 vConstant gComboBoxRoutine, % SubStr( Cons,2 )
Gui, Font, s10 Bold
Gui, Add,  Edit, y+0 wp h23 0x200 vValue c003046
Gui, Font, s9 Normal
Gui, Add,  ListView, wp r10 +Grid -Multi NoSortHdr Checked AltSubmit gListViewRoutine
        ,  Constant|Value
LV_ModifyCol( 1,"200" ), LV_ModifyCol( 2,"2000" ), Array:="|"
Gui, Add,  Button, w115 h25 +Default gSelectConstant, &Select Constant
Gui, Add,  Button, x+116 w80 hp  gClearList, Cle&ar List
Gui, Add,  Button, x+10 w160 hp gCopyToClipboard, &Copy List to Clipboard
Gui, Font, s8 Normal
Gui, Show,,List of WIN32 Constants ( 52927 )
Return

ComboBoxRoutine:
 GuiControlGet, Constant
 GuiControl,, Value,  % Value := pIniGetValue( Data,Constant )
Return

ListViewRoutine:
 IfNotEqual, A_GuiEvent, Normal, Return
 Row := LV_GetNext( 0,"Focused" ), LV_GetText( String,Row,1 )
 GuiControl, ChooseString, Constant, %String%
Return

SelectConstant:
 GuiControlGet, Constant
 If ( InStr( Array, "|" Constant "|" ) && DllCall( "Beep", UInt,400, UInt,200 ) )
   Return
 If ( ( Constants := ResolveDependencies( Constant, Data ) ) = "" )
   Return
 Loop, Parse, Constants, |
   If !InStr( Array, "|" ( Cons := A_LoopField ) "|" )
   && ( ( Val := pIniGetValue( Data, Cons := A_LoopField  ) ) <> "" )
      LV_Add( "Check Select", Cons, RegExReplace( Val, "\sOr\s", " | " ) )
    , LV_Modify( LV_GetCount(), "Vis" ), Array .= Cons "|"
 GuiControl, Focus, Constant
Return

ClearList:
 Array := "|", LV_Delete()
 GuiControl, Focus, Constant
Return

CopyToClipboard:
 While ( ( Row := LV_GetNext( Row, "Checked" ) ) && LV_Modify( Row, "-Check" ) )
   LV_GetText( Con,Row,1 ), LV_GetText( Val,Row,2 ), List .= Con " := " Val "`n"
 List ? ( Row:=0, Clipboard := List, List:="", DllCall( "Beep", UInt,1000, UInt,50 ) ) :
Return

GuiEscape:
GuiClose:
 ExitApp


LoadConstants( INI, ByRef Data, ByRef Cons ) {
 FileRead, Data, %INI%
 IfNotEqual,ErrorLevel,0, Return 0
 StringTrimLeft, Data, Data, 13
 Loop, Read, Constants.w32.ini
    Cons .= SubStr(A_LoopReadLine,1, InStr( A_LoopReadLine,"=" )-1 ) "|"
 StringTrimLeft, Cons, Cons, 11
 Sort, Cons, D|
Return 1
}

ResolveDependencies( Constant, ByRef Data ) {
 Static Rec := 0
 If ( ( Value := pIniGetValue( Data, Constant ) ) = "" || ( Rec := Rec + 1 ) > 20 )
    Return SubStr( Rec := 0, 0, 0  )
 If ( ( SubStr(Value,1,1) = """" && SubStr(Value,0) = """" ) || ( (Value+0) <> "" ) )
    Return Constant ; because value is either a string or a numerical value
 StringReplace, Value,Value, % " Or ",% " | ", All
 Constants := Constant
 Loop, Parse, Value, |+^/-, %A_Space%%A_Tab%()
    If ( ( Constant  := %A_ThisFunc%( A_LoopField, Data, Array ) ) <> "" )
       Constants := Constant "|" Constants
Return Constants
}

pIniGetValue( ByRef I,Key ) { ; www.autohotkey.com/forum/viewtopic.php?p=382194#382194
Return ( SubStr( ( Val := ( F := InStr(I,"`r`n" key "=")) ? SubStr(I, S := F+StrLen(Key)+3
    ,(C := InStr(I,"`r`n",0,S)) ? C-S : StrLen(I)-F ) : "" ),1,1) = """" || SubStr(Val,0 )
    = """" ) ? SubStr(Val,2,StrLen(Val)-2) : Val                             ; By SKAN
}


SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Bump: * Newer Version posted! *

Previous version was moved: Crazy Scripting : A handy tool to lookup Win32 Constants

jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Thanks for the update. Excellent as usual. :)

funclf
  • Guests
  • Last active:
  • Joined: --
The scripts are really helpful.
Always your scripts are amazing.

If click Edit2(vValue), the ability to copy the contents..
Gui, Add,  Edit, y+0 wp h23 0x200 gCopy vValue c003046
~~~

Copy:
GuiControlGet, Value
Clipboard := Value
ToolTip, copied to the clipboard
Return
Fast speed search and Readability
Thanks for sharing. :D

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Missing constants!

INTERNET_STATUS_COOKIE_SENT=320
INTERNET_STATUS_COOKIE_RECEIVED=321
INTERNET_STATUS_PRIVACY_IMPACTED=324
INTERNET_STATUS_P3P_HEADER=325
INTERNET_STATUS_P3P_POLICYREF=326
INTERNET_STATUS_COOKIE_HISTORY=327
CF_HTML=("HTML Format")


Just append it to the tail of Constants.W32.ini.
Make sure an empty line ( extra CRLF ) follows CF_HTML=("HTML Format").

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Code updated for quick loading in AHK_Lw.. In a faster machine, the data loading should not consume more than a couple seconds.

for Lexikos:
The previous version using RegExReplace: Constants.W32.ahk
Please look into LoadConstants() specifically.

Drugwash
  • Members
  • 1078 posts
  • Last active: May 24 2016 04:20 PM
  • Joined: 07 Sep 2008
Oh well... me again with 9x issues. Just for letting others know: there's a limitation in ListBox at about 32736 items (I'm not at home now, number may not be accurate) and another one in ListView at little over million items. I've made some changes to the original script to use a ListView and an Edit instead of the ComboBox, but it's much slower and sometimes inaccurate. If you can think of anything else to get over this limitation, I'd be glad to hear about it.

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

Oh well... me again with 9x issues. Just for letting others know: there's a limitation in ListBox at about 32736 items (I'm not at home now, number may not be accurate) and another one in ListView at little over million items. I've made some changes to the original script to use a ListView and an Edit instead of the ComboBox, but it's much slower and sometimes inaccurate. If you can think of anything else to get over this limitation, I'd be glad to hear about it.

Out of curiosity, why are you still using Win9x?

jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006
Does this list subsume (include) everything in Windows Constants? If so, a note should be posted there.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
I do not know.
This list was derived from API Viewer's DB ( updated 19.Dec.2008 ) and available from the following link:
<!-- m -->http://www.activevb.... ... ereng.html<!-- m -->

  • Guests
  • Last active:
  • Joined: --

Out of curiosity, why are you still using Win9x?

Because that is what we have and/or the boxes are too limited to run xp effectively.

Guest#2
  • Guests
  • Last active:
  • Joined: --

If you can think of anything else to get over this limitation, I'd be glad to hear about it.


Not ideal but maybe use two listboxes, and search half the list at a time, and only search the second if the first result negative then the second listbox/ half of the list? You could put the listboxes in the same position and guicontrol, hide/show them.

Drugwash
  • Members
  • 1078 posts
  • Last active: May 24 2016 04:20 PM
  • Joined: 07 Sep 2008
Usage of Win9x is a moot point already.

I'm currently using the modified ListView version and it's acceptable if I don't type too fast. Needs optimization but I'm too busy with many other things now. When I get some spare time I may try to improve it and if succesful, share with the community.

Two separate listboxes may be confusing but thanks for the idea.

TLM
  • Administrators
  • 3864 posts
  • Last active:
  • Joined: 21 Aug 2006
Bump
There must be some new ones missing from x64? hrmm..

Posted Image

don't duplicate, iterate!


TodWulff
  • Members
  • 142 posts
  • Last active: Sep 15 2013 04:16 PM
  • Joined: 29 Dec 2007
Mod'd Skan's fine script to add support for double-click selection of constants...

/* 

 'List of Win32 CONSTANTS' by SKAN - Suresh Kumar A N, [email protected] 
  Topic      : www.autohotkey.com/forum/viewtopic.php?t=19766
  Dependency : www.autohotkey.net/~Skan/Utils/List_of_WIN32_CONSTANTS/Constants.W32.ini
  Screenshot : www.autohotkey.net/~Skan/Utils/List_of_WIN32_CONSTANTS/Constants.W32.png

*/ ;                                  Created: 05-Oct-2010 / Last Modified: 18-Oct-2010

; mod'd 25Mar12 to add support for double-click selection of constants

#SingleInstance, Force
Menu, Tray,UseErrorLevel
Menu, Tray, Icon, shell32.dll, 44
SetBatchLines -1
SetWorkingDir, %A_ScriptDir%

IfNotExist, Constants.W32.ini, URLDownloadToFile
 , https://ahknet.autohotkey.com/~Skan/Utils/List_of_WIN32_CONSTANTS/Constants.W32.ini
 , Constants.W32.ini
 
If ! LoadConstants( "Constants.W32.ini", Data, Cons )
  ExitApp
 
Gui, Margin, 5, 10
Gui, +LastFound
Gui, Font, s9 Normal, Arial
Gui, Add,  ComboBox, w480 R10 Simple 0x2000 vConstant gComboBoxRoutine, % SubStr( Cons,2 )	;%
Gui, Font, s10 Bold
Gui, Add,  Edit, y+0 wp h23 0x200 vValue c003046
Gui, Font, s9 Normal
Gui, Add,  ListView, wp r10 +Grid -Multi NoSortHdr Checked AltSubmit gListViewRoutine
        ,  Constant|Value
LV_ModifyCol( 1,"200" ), LV_ModifyCol( 2,"2000" ), Array:="|"
Gui, Add,  Button, w115 h25 +Default gSelectConstant, &Select Constant
Gui, Add,  Button, x+116 w80 hp  gClearList, Cle&ar List
Gui, Add,  Button, x+10 w160 hp gCopyToClipboard, &Copy List to Clipboard
Gui, Font, s8 Normal
Gui, Show,,List of WIN32 Constants ( 52927 )
Return

ComboBoxRoutine:
 GuiControlGet, Constant
 GuiControl,, Value,  % Value := pIniGetValue( Data,Constant )	;%
Return

ListViewRoutine:
 IfNotEqual, A_GuiEvent, Normal, Return
 Row := LV_GetNext( 0,"Focused" ), LV_GetText( String,Row,1 )
 GuiControl, ChooseString, Constant, %String%
Return

SelectConstant:
	Select_Constant()
Return

ClearList:
 Array := "|", LV_Delete()
 GuiControl, Focus, Constant
Return

CopyToClipboard:
 While ( ( Row := LV_GetNext( Row, "Checked" ) ) && LV_Modify( Row, "-Check" ) )
   LV_GetText( Con,Row,1 ), LV_GetText( Val,Row,2 ), List .= Con " := " Val "`n"
 List ? ( Row:=0, Clipboard := List, List:="", DllCall( "Beep", UInt,1000, UInt,50 ) ) :
Return

GuiEscape:
GuiClose:
 ExitApp

#IfWinActive List of WIN32 Constants
 
~LButton:: 
	; from http://www.autohotkey.com/forum/viewtopic.php?p=158892#158892
    KeyWait, LButton         ; wait for Ctrl to be released 
    KeyWait, LButton, D T0.1   ; and pressed again within 0.1 seconds 
    if ErrorLevel ; timed-out (only a single press) 
        click
    else 
        Select_Constant()
return


LoadConstants( INI, ByRef Data, ByRef Cons ) {
 FileRead, Data, %INI%
 IfNotEqual,ErrorLevel,0, Return 0
 StringTrimLeft, Data, Data, 13
 Loop, Read, Constants.w32.ini
    Cons .= SubStr(A_LoopReadLine,1, InStr( A_LoopReadLine,"=" )-1 ) "|"
 StringTrimLeft, Cons, Cons, 11
 Sort, Cons, D|
Return 1
}

ResolveDependencies( Constant, ByRef Data ) {
 Static Rec := 0
 If ( ( Value := pIniGetValue( Data, Constant ) ) = "" || ( Rec := Rec + 1 ) > 20 )
    Return SubStr( Rec := 0, 0, 0  )
 If ( ( SubStr(Value,1,1) = """" && SubStr(Value,0) = """" ) || ( (Value+0) <> "" ) )
    Return Constant ; because value is either a string or a numerical value
 StringReplace, Value,Value, % " Or ",% " | ", All
 Constants := Constant
 Loop, Parse, Value, |+^/-, %A_Space%%A_Tab%()
    If ( ( Constant  := %A_ThisFunc%( A_LoopField, Data, Array ) ) <> "" )
       Constants := Constant "|" Constants
Return Constants
}

pIniGetValue( ByRef I,Key ) { ; www.autohotkey.com/forum/viewtopic.php?p=382194#382194
Return ( SubStr( ( Val := ( F := InStr(I,"`r`n" key "=")) ? SubStr(I, S := F+StrLen(Key)+3
    ,(C := InStr(I,"`r`n",0,S)) ? C-S : StrLen(I)-F ) : "" ),1,1) = """" || SubStr(Val,0 )
    = """" ) ? SubStr(Val,2,StrLen(Val)-2) : Val                             ; By SKAN
}

Select_Constant() {
	global
	GuiControlGet, Constant
	If ( InStr( Array, "|" Constant "|" ) && DllCall( "Beep", UInt,400, UInt,200 ) )
	   Return
	 If ( ( Constants := ResolveDependencies( Constant, Data ) ) = "" )
	   Return
	 Loop, Parse, Constants, |
	   If !InStr( Array, "|" ( Cons := A_LoopField ) "|" )
	   && ( ( Val := pIniGetValue( Data, Cons := A_LoopField  ) ) <> "" )
		  LV_Add( "Check Select", Cons, RegExReplace( Val, "\sOr\s", " | " ) )
		, LV_Modify( LV_GetCount(), "Vis" ), Array .= Cons "|"
	 GuiControl, Focus, Constant
	 return
	 	}

When replying, please feel free to address me as Tod. My AHK.net site...