I tried writing my own with limited success. I first tried using the ChooseColor function from comdlg32.dll. The only parameter is "a pointer to a ChooseColor structure". I can never make pointers to structures work so I looked for a VBScript example. I found this HTA on the Microsoft "Scripting Guy" site. Put this in an .HTA file and it will open a dialog that has a "Run Script" button. Whatever color you choose becomes the new background color for the dialog.
Code: Select all
<SCRIPT LANGUAGE="VBScript">
Sub TestSub
intColor=dlgHelper.ChooseColorDlg
If intColor <> 0 then
document.body.bgColor=intColor
End If
End Sub
</SCRIPT>
<body>
<OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>
<input id=runbutton type="button" value="Run Script" name="run_button" onClick="TestSub">
</body>
The script below is displaying two numbers. The first is the number that comes from the HTA file and the second is one that comes from the GetPixelColor> function. Of course the GetPixelColor> selection is always correct for Macro Scheduler.
I'm hoping that "someone" can do two things based on this script.
1- Write the VBScript version that could eliminate all the Mickey Mouse file writing and window manipulation that my script is performing.
2- Have the vbscript color number be the correct format to use in Macro Scheduler. I've not yet figured out how to convert the HTA script's color output to be correct for Macro Scheduler.
Code: Select all
IfWindowOpen>Color,EOF
OnEvent>KEY_DOWN,VK1,0,CheckColor
OnEvent>KEY_DOWN,VK13,0,CheckColor
SRT>CheckColor
GetActiveWindow>title,WinX,WinY
If>title=Color
Add>WinX,260
Add>WinY,240
GetPixelColor>WinX,WinY,color2
EndIf
END>CheckColor
Let>file1=%temp_dir%color_picker.hta
Let>file2=%temp_dir%color.txt
Let>file3=%temp_dir%Color.scp
IfFileExists>file1
DeleteFile>file1
EndIf
IfFileExists>file2
DeleteFile>file2
EndIf
IfFileExists>file3
DeleteFile>file3
EndIf
Let>filedata=<SCRIPT LANGUAGE="VBScript">%CRLF%
Concat>filedata, Sub TestSub%CRLF%
Concat>filedata, Dim fso, ThisFile%CRLF%
Concat>filedata, Set fso = CreateObject("Scripting.FileSystemObject")%CRLF%
Concat>filedata, Set ThisFile = fso.CreateTextFile("%file2%", True)%CRLF%
Concat>filedata, intColor=dlgHelper.ChooseColorDlg%CRLF%
Concat>filedata, If intColor <> 0 then%CRLF%
Concat>filedata, ' document.body.bgColor=intColor%CRLF%
Concat>filedata, ThisFile.Write intColor%CRLF%
Concat>filedata, End If%CRLF%
Concat>filedata, End Sub%CRLF%
Concat>filedata,</SCRIPT>%CRLF%
Concat>filedata,<body>%CRLF%
Concat>filedata, <OBJECT id=dlgHelper CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT>%CRLF%
Concat>filedata, <input id=runbutton type="button" value="Run Script" name="run_button" onClick="TestSub">%CRLF%
Concat>filedata,</body>%CRLF%
WriteLn>file1,wres,filedata
BlockInput>1
ExecuteFile>file1
WaitWindowOpen>%file1%*
SetFocus>%file1%*
GetCursorPos>CurX,CurY
MouseMoveRel>60,55
Lclick
GoSub>WinRemove
WaitWindowOpen>Color
SetFocus>Color
MouseMoveRel>30,275
LClick
MouseMove>CurX,CurY
BlockInput>0
DeleteFile>file1
//ExecuteFile>File3
OnEvent>WINDOW_NOTOPEN,Color,1,Finish
Label>Loop
Wait>0.01
Goto>Loop
SRT>Finish
CloseWindow>%file1%*
ReadFile>file2,color1
DeleteFile>file2
Dialog>Dialog3
Caption=Chosen Color
Width=330
Height=100
Top=CENTER
Left=CENTER
Label=msLabel1,10,8
Label=msLabel2,10,28
Label=(In Clipboard),10,48
EndDialog>Dialog3
Show>dialog3
Let>dialog3.mslabel1=%color1% From HTA
Let>dialog3.mslabel2=%color2% From GetPixelColor>
SetDialogObjectFont>Dialog3,msLabel1,Arial,15,1,%Color1%
SetDialogObjectFont>Dialog3,msLabel2,Arial,15,1,%Color2%
PutClipBoard>%Color2%
Label>Loop2
GetDialogAction>dialog3,res3
If>res3=2,EOF
Wait>0.01
Goto>Loop2
SRT>Finish
Label>EOF
SRT>WinRemove
GetWindowHandle>%file1%*,winhndl
//constants
Let>GWL_EXSTYLE=-20
Let>WS_EX_LAYERED=524288
Let>LWA_ALPHA=2
Let>ByteOpacity=0
//get style attributes of dialog1 window
LibFunc>user32,GetWindowLongA,attribs,winhndl,GWL_EXSTYLE
Let>attribs={%attribs% OR %WS_EX_LAYERED%}
//make dialog1 transparent
LibFunc>user32,SetWindowLongA,swl,winhndl,GWL_EXSTYLE,attribs
LibFunc>user32,SetLayeredWindowAttributes,res,winhndl,0,ByteOpacity,LWA_ALPHA
END>WinRemove
Hope this all makes sense,
Dick