Curious as to how to make a popup asking to confirm if I want to load the program before it loads. Example:
^g::Run C:\GW2\gw2.exe
Although it does not seem that you have done a lot of homework, I'll provide a solution here.
^g::
MsgBox, 4100, , Would you like to launch GW2?, 5 ; 5-second timeout.
IfMsgBox, No
Return ; User pressed the "No" button.
IfMsgBox, Timeout
Return ; Timed out.
run, C:\GW2\gw2.exe
Return
Related
I am writing a autologin script in Powershell. With main purpose of doing autologon with keystrokes on remote clients in our environment after installation, with the desired AD and password entered.
Works fine on my i9. But most people using Tablets and Elitebooks so using
Thread Sleep
Works bad since i would need to have custom timing on Every hardware, or very high default numbers for lower end clients using my script
Is there any way adding an "wait for row above to completed" Before continuation to next.
I don't have enough on your current code to produce a more accurate answer but the idea, in all cases, remains the same.
You should periodically wake up the thread to check whether or not the machine is in the state you want it in and from there, you either go back to sleep or exit the loop and continue.
The delay is up to you but you want to find a sweet spot to have great performance and reactivity.
Example (based on your description)
$IsLoggedIn = $false
while (! $IsLoggedIn) {
$IsLoggedIn = 'Custom Logic returning $true if the user is logged in'
if ($IsLoggedIn) { break }
Start-Sleep -Milliseconds 100
}
You just need to figure out the thing you want to use as the check to validate the computer is in the correct state you need it in before proceeding further.
I'm trying to detect if ffdshow is currently running on the computer using AutoHotKey.
Someone has suggested that I can achieve this by sending a message to the to the ffdshow window handle. If it succeeds, then ffdshow is running.
According to ffdshow, the window handle is 32786 and, according to the AutoHotKey documentation, I want to use PostMessage and then check ErrorLevel.
However at that point, I'm struggling to understand the documentation. I've got the following:
ControlHwnd := 32786
VarContainingID := 32786
PostMessage, 0x00, , , ,ahk_id %ControlHwnd%, ahk_id %VarContainingID%
MsgBox %ErrorLevel%
but that always reports a 1 indicating that it was unable to connect to the window handle - even though ffdshow is running.
I've also tried changing PostMessage to the blocking SendMessage but that always reports FAIL.
I'm clearly doing something wrong, but I'm not really sure what. Can anyone help?
Thanks to blackholyman and MCL, I found the problem.
After digging around in the sample code found here, it turns out there is a window class for ffdshow called ffdshow_remote_class.
As a result, the following code:
DetectHiddenWindows, On
WinGet, activeid, ID, ahk_class ffdshow_remote_class
MsgBox activeid = %activeid%
will return a hWnd value for ffdshow (stored in activeid) if it is running or nothing if it is not.
I'm trying to collect keyboard data, but I can't get KbWait to work. In the following code, I'm trying to wait for the participant to respond, check if their response is one of two acceptable answers, and then continue. It should only continue when the participant presses 'j' or 'f'.
response = [];
while isempty(response)&&(GetSecs - FlipTimestamp) < 10
[keyIsDown, RTsecs, RTkeyCode, deltaSecs] = KbWait;
if keyIsDown
r=find(RTkeyCode);%this should be the code for the key pressed
response=KbName(r);%Figure out what key was pressed
rt=num2str(RTsecs-time); %subtract off timestamp from when window was flipped
if response == 'f'
match_response= false;
end
if response == 'j'
match_response= true;
end
end
end
However, KbWait never returns. When I try to run it from the command line, it doesn't work either. It just hangs up and refuses to return, and I have to interrupt the program.
It's been nine months since you posted this, so I imagine you've already found some sort of solution. But I was also having this problem, and here's what I discovered:
I went through my entire HID list: devices = PsychHID('Devices')
As I examined each one's 'usageName' property, I found that multiple devices were considered to be 'Keyboard', even though I only have one actual keyboard connected.
I then tried each one's index as an argument for KbWait. When I got to the correct one, KbWait worked.
Hi there I think your problem is the KbWait function.
you used KbWait like ist KbCheck but the output of those functions is different
[secs, keyCode, deltaSecs] = KbWait([deviceNumber][, forWhat=0][, untilTime=inf])
[keyIsDown, secs, keyCode, deltaSecs] = KbCheck([deviceNumber])
Try KbCheck its more exact than KbWait, because KbWait checks the keyboard only every 5 ms
Here is a Function I wrote sometimes ago: working KbCheck
I am using Galasoft MVVMLight. I have a button bound to a command which sends a message to the view to display a messagebox asking for confirmation. If I click either the Yes or No on the messagebox it performs the necessary actions then shows up again. However if I step through the program instead I only get the messagebox once. Is this a bug or is something else going on?
EDIT: I modified the messagebox.show line by adding an Icon and default result and now I can't reproduce this behavior... I'm stumped... if it happens again I'll try a counter like airplaneman19 suggested.
Try tracking the amount of times the MessageBox shows up with an integer, like so:
int counter = 0;
if(counter == 0){
MessageBox.Show();
counter++;
}
else if (counter == 1)
/*Do something that won't alter the program just to escape the if....else statement
like "x++";
I had a similar problem once, I mean, with MessageBox firing twice. It was due to focus changes, and ListView in WinForms fired another selection changed event when running the app; but when debugging - some focus change was missing, and there was no bug :)
I hope this atleast gives you some ideas...
I am Using WaitforComplete() in watiN but it doesnt seems to work well. As it executes the next statement even if you have given longer time to wait. I am using thread.sleep() to stop my application until it gets the desired page or element. But the thing is pages are so much dynamic that sometimes it takes much longer time as specified.
Any better solution. Any thing that will catch the page return dynamically and dont go to execute next statments in application.
Sample of Code
'Show Details page
Assert.AreEqual("Confirmation", _internetExplorer.Title)
If (_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Exists) Then
_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Click()
Else
Assert.Fail("Could not Find Finish Booking Button on Confirmation Page")
End If
System.Threading.Thread.Sleep(100000)
'Show Booking Summary page
Assert.AreEqual("Display Booking", _internetExplorer.Title)
I want something that detect the return of page dynamically. instead of giving some constant value.
WaitForComplete only works well if there is a postback after some action. Otherwise you have to find something else to wait for. Following an example on how to wait for the specified title:
_internetExplorer.Element("title", "Confirmation").WaitUntilExists();
I would always prefer to use one of the WaitXXX methods instead of Thread.Sleep cause the WaitXXX methods do only wait until the contraint is met. Where as Sleep waits for the time you specified. If its to long, time is waisted. If its to short, problems arise.
HTH,
Jeroen
The WaitForComplete method esentially moves on once the browser has set it's readystate to comllete and the busy state to false.
What I typically do is to try and access what you need to, then perform a thread.sleep for say half a second, then try again. I also have a global timeout that quits after say 10 seconds.
int timeout = 20;
bool controlFound = false;
for (int i = 0; i < timeout; i++)
{
if (_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Exists)
{
_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Click();
controlFound = true;
break;
}
else
{
System.Threading.Thread.Sleep(500);
}
}
if (!controlFound)
{
Assert.Fail("Control not found");
}
If it is executing the next statement, it should be finding the corresponding element. I suggest posting a sample of the code you are trying.