StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Gilers  
#1 Posted : Friday, June 9, 2023 10:04:16 PM(UTC)
Gilers

Rank: Member

Reputation:

Groups: Approved
Joined: 4/27/2020(UTC)
Posts: 18
Korea, Republic Of

When the window is opened, I save its handle to a TXT document. When I need to invoke the window, I retrieve the string from the document and open it.

Here is my code. When I run it, there are no errors, but there is no response either. Can someone help me identify where the problem might be?

var groups = readtogroup('C:\\Temp\\list.txt');
var mark = 0;
var currHandle = sp.ForegroundWindow().Process.Handle.ToString();
for (var i=0,lens = groups.Length; i < lens;i++){
if(currHandle == groups[i]){
if (i<groups.length-1){
switchToHandle(groups[i+1]);
mark = 1;
}else{
switchToHandle(groups[0]);
mark = 1;
}
break;
}
}

if(mark == 0){
switchToHandle(groups[0]);
}


// Switch to a window with a specified handle value.
function switchToHandle (handle){
var wnds = sp.AllApplications();
for (var i = 0, len = wnds.Length; i < len; i++) {
if (wnds[i].Process.Handle.ToString() == handle ){
wnds[i].Activate();
break;
}
}
}






//Read the contents of a specified document into an array, with each line stored as an element。


function readtogroup (path){

var sr = clr.System.IO.File.OpenText(path);
//stores current line
var line;
//stores current line number
var lineNumber = 0;
//tracks whether keyword is found or not
var content = new Array();

try{
//traverse the file
while ((line = sr.ReadLine()) != null ){
//increment line counter
lineNumber += 1;
//check for a keyword match in line
content.push(String(line));
}
}catch{
sp.MessageBox( "Error","biaoti");
}
//close file
sr.Close();
sr.Dispose();
//sp.MessageBox(content[2],"biaoti");

return content;
}

Edited by user Saturday, June 10, 2023 4:09:04 PM(UTC)  | Reason: Not specified

Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.