Skip to content

Commit

Permalink
Merge pull request #2 from Dominig12/fast-stable
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
Dominig12 authored Oct 3, 2022
2 parents 17a5e53 + da62221 commit 39ce6fd
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 37 deletions.
10 changes: 9 additions & 1 deletion Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 61 additions & 28 deletions Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ public Form1()
setPow.SelectedIndex = 6;
refreshProcess();
refreshCoords();
using var watching = new FileSystemWatcher();
watching.Changed += OpenWormholeFromMap;
watching.Filter = "openwormhole.txt";
}

[DllImport("user32.dll")]
Expand Down Expand Up @@ -348,31 +345,47 @@ private IntPtr FindWindow(string name)
return IntPtr.Zero;
}

// -2 54
// -2 64
// 100 100 2
private IntPtr GetLastWindow()
{
return EnumerateProcessWindowHandles(Process.GetProcessesByName("dreamseeker")[0].Id).First<IntPtr>();

}

private IEnumerable<IntPtr> GetAllWindows()
{
return EnumerateProcessWindowHandles(Process.GetProcessesByName("dreamseeker")[0].Id);
}

private bool TurnCommand(string command, string data = "", string searchWindow = "")
{
IntPtr targetWindow = IntPtr.Zero;
IEnumerable<IntPtr> before_windows = GetAllWindows();
IntPtr targetWindow = IntPtr.Zero;
WebRequest reqGET = WebRequest.Create(command);
WebResponse resp = reqGET.GetResponse();
try
{
if (searchWindow == "")
return true;
while(targetWindow == IntPtr.Zero)
targetWindow = FindWindow(searchWindow);
while (GetForegroundWindow() != targetWindow && targetWindow != IntPtr.Zero)
{
SetForegroundWindow(targetWindow);
targetWindow = FindWindow(searchWindow);
}
Thread.Sleep(150);
IEnumerable<IntPtr> after_windows = GetAllWindows();
foreach(IntPtr window in after_windows)
{
if (before_windows.Contains(window))
continue;
targetWindow = window;
}
try
{
//targetWindow = GetLastWindow();
SetForegroundWindow(targetWindow);
SendKeys.Send(data);
Thread.Sleep(300);
return true;
Thread.Sleep(100);
return true;
}
catch
{
return false;
}
}
{
}
return false;
}

private string GetAdress()
{
Expand Down Expand Up @@ -436,18 +449,38 @@ private void OpenWormhole()
TurnCommand(adress + "open_teleport=1");
}
}
private void OpenWormholeFromMap(object sender, FileSystemEventArgs e)

private void OpenWormholeFromMap(object sender, EventArgs e)
{
StreamReader reader = new StreamReader("openwormhole.txt");
StreamReader reader;

try
{
reader = new StreamReader("open_wormhole.txt");
} catch
{
return;
}
string line = "";
if ((line = reader.ReadLine()) == null)
{
reader.Close();
return;
string[] coords = line.Split(' ');
} else
{
reader.Close();
}

StreamWriter writer = new StreamWriter("open_wormhole.txt");
writer.Flush();
writer.Close();

string[] coords = line.Split(' ');
rxb.Text = coords[0];
ryb.Text = coords[1];
StreamWriter writer = new StreamWriter("openwormhole.txt");
writer.Flush();
OpenWormhole();

TurnCommand(GetAdress() + "setz=1", coords[2] + "{ENTER}");
OpenWormhole();
}

private void button3_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -504,5 +537,5 @@ private void button7_Click(object sender, EventArgs e)
TurnCommand(adress + "setz=1", coords[2] + "{ENTER}", searchWindow);
OpenWormhole();
}
}
}
}
3 changes: 3 additions & 0 deletions Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
7 changes: 7 additions & 0 deletions TelepadGuru.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,16 @@
</PropertyGroup>

<ItemGroup>
<None Remove="open_wormhole.txt" />
<None Remove="user32.dll" />
</ItemGroup>

<ItemGroup>
<Content Include="open_wormhole.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down
8 changes: 0 additions & 8 deletions coordinates.txt
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
Scan results show the following points of interest:
�Unknown shuttle: x = 110, y = 228, z = 3
�Unknown huge object: x = 198, y = 182, z = 4
�Unknown object: x = 154, y = 91, z = 3
�Unknown object: x = 149, y = 206, z = unknown
�Debris of an unknown shuttle: x = 199, y = 204, z = unknown
�Unknown small object: x = 130, y = 233, z = unknown
�Unknown huge object: x = 108, y = 80, z = 3
Empty file added open_wormhole.txt
Empty file.

0 comments on commit 39ce6fd

Please sign in to comment.