#156721 - 2006-02-06 09:30 PM
KBHit() Problem
|
Tark
Fresh Scripter
Registered: 2003-02-25
Posts: 10
Loc: London
|
Hi
Please could someone help me with this, I've tried searching the forums and documentation but can't find anything specific to what I am trying to do.
I know that some functions keys (in this instance CRTL + F10) return 32bit values, for this key combination @ERROR returns 103. However, this little bit of code does not seem to work.
If anyone could point me in the right direction, i would be very grateful.
Thank you.
Code:
;@ERROR 103 = CTRL + F10 Do ? "I am a banana" Sleep 1 Until KBHit() <> 0 And @ERROR = 103
|
|
Top
|
|
|
|
#156722 - 2006-02-06 09:41 PM
Re: KBHit() Problem
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Here's a quick idea ...
Code:
Break on
Do ? "I am a banana" Sleep 1 If KBHit() get $hit $hit = @ERROR Endif Until $hit = 103
Exit 0
|
|
Top
|
|
|
|
#156723 - 2006-02-06 10:03 PM
Re: KBHit() Problem
|
Tark
Fresh Scripter
Registered: 2003-02-25
Posts: 10
Loc: London
|
Hey Shawn, I was going to open a bottle of wine, citing "stress" to the missus.
But now you've gone and spoilt it all!
Ps. Are you the Mr KixForms Shawn ?
Thanks sooo much . .
Thanks geezer
|
|
Top
|
|
|
|
#156725 - 2006-02-06 11:00 PM
Re: KBHit() Problem
|
Benny69
Moderator
   
Registered: 2003-10-29
Posts: 1036
Loc: Lincoln, Ne
|
Shawn, you are too humble.
|
|
Top
|
|
|
|
#156726 - 2006-02-06 11:19 PM
Re: KBHit() Problem
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
for you yes he is: Mr KixForms
To some others he is something else 
a big BASTA
|
|
Top
|
|
|
|
#156728 - 2006-02-07 11:34 AM
Re: KBHit() Problem
|
Tark
Fresh Scripter
Registered: 2003-02-25
Posts: 10
Loc: London
|
Hmm, maybe I shouldn't have opened that bottle of wine last night . . .
This might be by design, but if i change the sleep to 60 seconds, pressing CRTL + F10 won't do anything until those 60 seconds are up, which i guess is obvious. But is there any way around this ? Also, any tips or constructive critisism on how to make this better would be very welcome.
Many thanks guys.
Code:
Break On ;SetConsole("Hide")
;region If @DOS >= "5.0" Goto START Else MessageBox("SetIEPass can only be used on Windows 2000 or above." + Chr(13) + Chr(10) + "" + Chr(13) + Chr(10) + "The version detected on this computer is " + @PRODUCTTYPE, "TungstenBlue LLP", 4112) Exit 0 EndIf ;endregion
:START
Global $100, $200, $NewPass, $IniFolder, $Period01, $Period02, $Period03, $Period04, $Period05, $Period06, $Period07, $Period08, $Period09, $Period10, $User, $UserName, $DomainName
If Exist("%ASEEXEPATH%SetIEPass.ini") $IniFolder = %ASEEXEPATH% + "SetIEPass.ini" Else ; Just for testing $IniFolder = "C:\TechProgs\Scripting\Forms\SetIEPass\SetIEPass.ini" ; $IniFolder = "D:\Supoort\SetIEPass\SetIEPass.ini" ;MessageBox("Cannot find SetIEPass.ini !" + Chr(13) + Chr(10) + "" + Chr(13) + Chr(10) + ;"Please ensure that SetIEPass.ini is in the same folder as SetIEPass.exe.", "TungstenBlue LLP", 16) ;Exit 0 EndIf
$Period01 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period01")) $Period02 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period02")) $Period03 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period03")) $Period04 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period04")) $Period05 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period05")) $Period06 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period06")) $Period07 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period07")) $Period08 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period08")) $Period09 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period09")) $Period10 = Trim(ReadProfileString ($IniFolder,"PeriodStart","Period10"))
Do Select Case Trim(Left(@TIME,5)) = $Period01 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period02 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period03 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period04 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period05 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period06 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period07 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period08 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period09 ChangeUser ("SetIEPass", @DOMAIN) Case Trim(Left(@TIME,5)) = $Period10 ChangeUser ("SetIEPass", @DOMAIN) EndSelect ? "I am a banana" Sleep 60 If KBHit() Get $hit $hit = @ERROR EndIf Until $hit = 103
Exit 0
Function ChangeUser ($uName, $dName) $100 = Rnd(999) $200 = Rnd(999) $NewPass = $200$300 $UserName = $uName $DomainName = $dName $User = GetObject("WinNT://" + $DomainName + "/" + $UserName + ",user") $User.Description = ("IE pwd = " + "'" + $NewPass + "'" + " , changed at " + @TIME + " on " + @DATE) $User.SetPassword ($NewPass) $User.SetInfo Set $User = 0 $WshShell = CreateObject ("WScript.Shell") $WshShell.LogEvent (0, "Internet Password Changed to " + "'" + $NewPass +"'") EndFunction
The INI File Code:
[PeriodStart] Period01=08:30 Period02=09:00 Period03=09:50 Period04=11:00 Period05=12:45 Period06=14:00 Period07=15:10 Period08=16:15 Period09=19:15 Period10=20:15
[edit] LongLine-Police visited this post
Edited by Jooel (2006-02-07 09:43 PM)
|
|
Top
|
|
|
|
#156729 - 2006-02-07 12:12 PM
Re: KBHit() Problem
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
ja, could just build in the "timer" as part of your loop ...
Code:
$i = 0
$sleep = 10
? "Waiting ..."
Do Sleep 1 $i = $i + 1 If KBHit() get $hit $hit = @ERROR Endif Until $i = $sleep Or $hit = 103
?"Done"
|
|
Top
|
|
|
|
#156730 - 2006-02-07 12:54 PM
Re: KBHit() Problem
|
Tark
Fresh Scripter
Registered: 2003-02-25
Posts: 10
Loc: London
|
Thanks Shawn
It needed to be a continual loop, so i've settled on this.
Break on
:RESTART $i = 0 $sleep = 60 $hit = 0 ? "Waiting ..." Do Sleep 1 $i = $i + 1 If KBHit() Get $hit $hit = @ERROR EndIf Until $i = $sleep Or $hit = 103 ?"Done" If $hit = 103 Exit 0 Else Goto RESTART EndIf
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 756 anonymous users online.
|
|
|