Well, Im making a windows gadget that will show a few of my steam games which will let me have all the icons in one spot.
How I'm doing it is: The gadget settings page will show a few drop-down boxes (the amound of max icons showable). In those drop down boxes will be the name of the game icon I want to show. The names are in an array. When the name is selected in the drop down menu, it will correspond to the name of the png icon for that game.
Upon clicking OK in the settings, it writes the name of the icon png to the gadget settings file.
The actual gadget then reads the same of the files shown in the gadget settings file and then adds them to the gadget using background.AddImageObject png name
The thing im having trouble with is that once the icon is shown, I want that icon to then launch the game when clicked (i have a static gadget where the icons arent changeable and I just used a system.shell.execute in a fucntion and onClick of the png would call that function).
The codes im using:
Settings.html
Gamemonitor.html
Hoping that it makes sense to someone. I know the code is messy but im a bit of a noob when it comes to coding. If need be, I can pack the code into the '.gadget' file so that you can run it on your own computer ('.gadget' file is just a zip file with a different extension).
Thanks,
How I'm doing it is: The gadget settings page will show a few drop-down boxes (the amound of max icons showable). In those drop down boxes will be the name of the game icon I want to show. The names are in an array. When the name is selected in the drop down menu, it will correspond to the name of the png icon for that game.
Upon clicking OK in the settings, it writes the name of the icon png to the gadget settings file.
The actual gadget then reads the same of the files shown in the gadget settings file and then adds them to the gadget using background.AddImageObject png name
The thing im having trouble with is that once the icon is shown, I want that icon to then launch the game when clicked (i have a static gadget where the icons arent changeable and I just used a system.shell.execute in a fucntion and onClick of the png would call that function).
The codes im using:
Settings.html
Code:
<html>
<head>
<style>body{width: 250px; height: 350px; font-family: Tahoma; font-size: 10px;}p{top-margin: .5em;}</style>
<script>
var serverType = new Array(["CoD:BO - Singleplayer", "codbosp"],["CoD:BO - Multiplayer", "codbomp"],["Counter Strike: Source", "css"],["Day of Defeat Source", "dods"],["Killing Floor", "kf"],["Left 4 Dead", "l4d"],["Left 4 Dead 2", "l4d2"],["Magicka", "magicka"],["Portal", "portal"],["Portal 2", "portal2"],["Team Fortress 2", "tf2"],["Terraria", "terr"]);
System.Gadget.onSettingsClosing = settingsClosing;
function loadSettings(){
for(var i=0;i<serverType.length;i++){
server1.options[i]=new Option(serverType[i][0], serverType[i][1]);
server1.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server2.options[i]=new Option(serverType[i][0], serverType[i][1]);
server2.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server3.options[i]=new Option(serverType[i][0], serverType[i][1]);
server3.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server4.options[i]=new Option(serverType[i][0], serverType[i][1]);
server4.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server5.options[i]=new Option(serverType[i][0], serverType[i][1]);
server5.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server6.options[i]=new Option(serverType[i][0], serverType[i][1]);
server6.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server7.options[i]=new Option(serverType[i][0], serverType[i][1]);
server7.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server8.options[i]=new Option(serverType[i][0], serverType[i][1]);
server8.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server9.options[i]=new Option(serverType[i][0], serverType[i][1]);
server9.options[i].title=serverType[i][0];}
for(var i=0;i<serverType.length;i++){
server10.options[i]=new Option(serverType[i][0], serverType[i][1]);
server10.options[i].title=serverType[i][0];}
if (System.Gadget.Settings.read("SettingsExist")){
with (server1){
value = System.Gadget.Settings.read("savedServer1Type");}
with (server2){
value = System.Gadget.Settings.read("savedServer2Type");}
with (server3){
value = System.Gadget.Settings.read("savedServer3Type");}
with (server4){
value = System.Gadget.Settings.read("savedServer4Type");}
with (server5){
value = System.Gadget.Settings.read("savedServer5Type");}
with (server6){
value = System.Gadget.Settings.read("savedServer6Type");}
with (server7){
value = System.Gadget.Settings.read("savedServer7Type");}
with (server8){
value = System.Gadget.Settings.read("savedServer8Type");}
with (server9){
value = System.Gadget.Settings.read("savedServer9Type");}
with (server10){
value = System.Gadget.Settings.read("savedServer10Type");}
}
}
function settingsClosing(event)
{
if (event.closeAction == event.Action.commit)
{
System.Gadget.Settings.write("savedServer1Type", server1.value);
System.Gadget.Settings.write("savedServer2Type", server2.value);
System.Gadget.Settings.write("savedServer3Type", server3.value);
System.Gadget.Settings.write("savedServer4Type", server4.value);
System.Gadget.Settings.write("savedServer5Type", server5.value);
System.Gadget.Settings.write("savedServer6Type", server6.value);
System.Gadget.Settings.write("savedServer7Type", server7.value);
System.Gadget.Settings.write("savedServer8Type", server8.value);
System.Gadget.Settings.write("savedServer9Type", server9.value);
System.Gadget.Settings.write("savedServer10Type", server10.value);
System.Gadget.Settings.write("SettingsExist", true);
}
}
</script>
</head>
<body onload="loadSettings()">
<label id="server1TypeLabel" for="server1">Server Type:</label>
<select id="server1" style="width:150px;font-size:12px;"></select><br />
<p>
<label id="server2TypeLabel" for="server2">Server Type:</label>
<select id="server2" style="width:150px;font-size:12px;"></select><br />
<p>
<p>
<label id="server3TypeLabel" for="server3">Server Type:</label>
<select id="server3" style="width:150px;font-size:12px;"></select><br />
<p>
<label id="server4TypeLabel" for="server4">Server Type:</label>
<select id="server4" style="width:150px;font-size:12px;"></select><br />
<p>
<label id="server5TypeLabel" for="server5">Server Type:</label>
<select id="server5" style="width:150px;font-size:12px;"></select><br />
<p>
<label id="server6TypeLabel" for="server6">Server Type:</label>
<select id="server6" style="width:150px;font-size:12px;"></select><br />
<p>
<label id="server7TypeLabel" for="server7">Server Type:</label>
<select id="server7" style="width:150px;font-size:12px;"></select><br />
<p>
<label id="server8TypeLabel" for="server8">Server Type:</label>
<select id="server8" style="width:150px;font-size:12px;"></select><br />
<p>
<label id="server9TypeLabel" for="server9">Server Type:</label>
<select id="server9" style="width:150px;font-size:12px;"></select><br />
<p>
<label id="server10TypeLabel" for="server10">Server Type:</label>
<select id="server10" style="width:150px;font-size:12px;"></select><br />
<p>
</body>
</html>
Gamemonitor.html
Code:
<html>
<head>
<meta http-equiv="MSThemeCompatible" CONTENT="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=Unicode" />
<title>Game Monitor</title>
<style>
body { margin: 0; padding: 0; width: 130px; height: 67px; color: #ffffff; font-family: 'Segoe UI'; }
</style>
</head>
<script language="VBScript">
On Error Resume Next
Sub Window_Onload
Call checkUpdates()
RunBat
End Sub
Sub RunBat
Call onLoad()
End Sub
</script>
<script language="javascript" type="text/javascript">
System.Gadget.settingsUI = "settings.html";
System.Gadget.onSettingsClosed = settingsClosed;
function settingsClosed(event)
{
if (event.closeAction == event.Action.commit)
RunBat();
}
function checkUpdates()
{
}
function onLoad()
{
canvas.removeObjects();
canvas.addImageObject('images/back8.png', 0, 0);
canvas.style.height = 1000;
document.body.style.posHeight = 1000;
serverType1 = System.Gadget.Settings.read("savedServer1Type");
serverType2 = System.Gadget.Settings.read("savedServer2Type");
serverType3 = System.Gadget.Settings.read("savedServer3Type");
serverType4 = System.Gadget.Settings.read("savedServer4Type");
serverType5 = System.Gadget.Settings.read("savedServer5Type");
serverType6 = System.Gadget.Settings.read("savedServer6Type");
serverType7 = System.Gadget.Settings.read("savedServer7Type");
serverType8 = System.Gadget.Settings.read("savedServer8Type");
serverType9 = System.Gadget.Settings.read("savedServer9Type");
serverType10 = System.Gadget.Settings.read("savedServer10Type");
canvas.addImageObject('images/icons/' + serverType1 + '.png', 7, 5);
canvas.addImageObject('images/icons/' + serverType2 + '.png', 7, 105);
canvas.addImageObject('images/icons/' + serverType3 + '.png', 7, 210);
canvas.addImageObject('images/icons/' + serverType4 + '.png', 7, 315);
canvas.addImageObject('images/icons/' + serverType5 + '.png', 7, 420);
canvas.addImageObject('images/icons/' + serverType6 + '.png', 7, 525);
canvas.addImageObject('images/icons/' + serverType7 + '.png', 7, 630);
canvas.addImageObject('images/icons/' + serverType8 + '.png', 7, 735);
canvas.addImageObject('images/icons/' + serverType9 + '.png', 7, 840);
canvas.addImageObject('images/icons/' + serverType10 + '.png', 7, 945);
}
</script>
<body>
<div id="targets"></div>
<g:background id="canvas" src="images/canvas.png" style="position: absolute; top: 0; left: 0; z-index: -999;" opacity="0" />
</body>
</html>
Hoping that it makes sense to someone. I know the code is messy but im a bit of a noob when it comes to coding. If need be, I can pack the code into the '.gadget' file so that you can run it on your own computer ('.gadget' file is just a zip file with a different extension).
Thanks,