Jump to content

Solitaire Denier


Kurt
 Share

Recommended Posts

Well, here's the first script I wrote with AutoIT. Mostly as a proof of concept that AutoIT could be used to do useful things.

Opt("TrayIconHide", 1) 
 
NoSolitaire()

Func NoSolitaire()
    WinWaitActive("Solitaire")
    WinKill("Solitaire")
    NoSolitaire()
EndFunc

That's it. It's great fun to put on the PC of someone who's been seen constantly playing Solitaire. Although it is hard not to laugh when you're in the next cube over and you KNOW they want to ask you, but don't want it known that there's a problem with Solitaire....

I wrote another script that writes this executable to the Registry, but that's on my other laptop.

True, it's nothing like the Run! program or some of the other scripts I've seen, but it's good for a laugh, and it's my first. Pardon me for not uploading it (haven't poked into that yet), but it's not exactly hard to cut 'n paste that into Scite. (And by the by, whoever customized Scite4AutoIT did a brilliiant piece of work. )

Link to comment
Share on other sites

BlackDiablo was partly right. It is better avoiding recoursing Func if not needed.

This is better...

Opt("TrayIconHide", 1) 

While 1
   NoSolitaire()
Wend

Func NoSolitaire()
    WinWaitActive("Solitaire")
    WinKill("Solitaire")
EndFunc

Fixed: Thanks JS.

Edited by ezzetabi
Link to comment
Share on other sites

BlackDiablo was partly right. It is better avoiding recoursing Func if not needed.

This is better...

Opt("TrayIconHide", 1) 

While 
   NoSolitaire()
Wend

Func NoSolitaire()
    WinWaitActive("Solitaire")
    WinKill("Solitaire")
EndFunc

<{POST_SNAPBACK}>

Didnt you mean...

Opt("TrayIconHide", 1) 

While 1
   NoSolitaire()
Wend

Func NoSolitaire()
    WinWaitActive("Solitaire")
    WinKill("Solitaire")
EndFunc

Or does that 1 not matter? (I read in the helpfile that it be any non zero number).

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • Developers

(And by the by, whoever customized Scite4AutoIT did a brilliiant piece of work. )

<{POST_SNAPBACK}>

glad you like it :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Nice script, but doesn't that take up a LOT of memory usage? Too bad you can't hotkey something to a program opening =)

<{POST_SNAPBACK}>

Actually, no, it wasn't hogging CPU or causing any sort of noticeable performance hit. (Thought it's hard to tell since I was ordered to be the guinea pig for Service Pack 2 not too long ago, and I can't say the same for that.)

I'll try the While-Wend version posted below -- I'm still pretty new at this.

Link to comment
Share on other sites

Guest Py7|-|[]/\/

Well, its just that if you keep a funciton running infinitely, it will tend to take up a lot of memory. By looping the function itself, or adding a sleep and hotkey, you save a lot of usage.

Link to comment
Share on other sites

Guest Py7|-|[]/\/

@ezzetabi

I was not aware that the 250ms delay was enough. If I remember, WinWaitActive pauses for 250ms after it is active before continuing. But where I was wrong is that I believed that it was too little, from what I hear around the forums a Sleep(10) seems to make the most dramatic improvements but I could be wrong.

Link to comment
Share on other sites

The point is that the Sleep(1) or Sleep(10) or whatnot thing is useful when there are NO PAUSES!

E.g.

;Try deleting a file I can't know when will be not on use.
While FileExist('c:\myenemyfile.grr')
   FileDelete('c:\myenemyfile.grr')
Wend

Will max your CPU because you computer will try deleting with all its clocks!

While

;Try deleting a file I can't know when will be not on use.
While FileExist('c:\myenemyfile.grr')
   FileDelete('c:\myenemyfile.grr')
   Sleep(10)
Wend

Will try to delete the file 'only' 100 times per second. That for a CPU that can make millions of operation every second is extremly less problematic.

Instead:

Opt("TrayIconHide", 1) 

While 1
  NoSolitaire();Calls the Func
Wend

Func NoSolitaire()
   WinWaitActive("Solitaire");WAITS the window! checking it existence 5 times per second,
  ;                           it is a very light job for a CPU.
   WinKill("Solitaire") ;When it arrives it kills it and return immediatly (via While)
  ;                      to wait.
EndFunc

Do you see the point now?

Link to comment
Share on other sites

Guest Py7|-|[]/\/

The point is that the Sleep(1) or Sleep(10) or whatnot thing is useful when there are NO PAUSES!

E.g.

;Try deleting a file I can't know when will be not on use.
While FileExist('c:\myenemyfile.grr')
   FileDelete('c:\myenemyfile.grr')
Wend

Will max your CPU because you computer will try deleting with all its clocks!

While

;Try deleting a file I can't know when will be not on use.
While FileExist('c:\myenemyfile.grr')
   FileDelete('c:\myenemyfile.grr')
   Sleep(10)
Wend

Will try to delete the file 'only' 100 times per second. That for a CPU that can make millions of operation every second is extremly less problematic.

Instead:

Opt("TrayIconHide", 1) 

While 1
  NoSolitaire();Calls the Func
Wend

Func NoSolitaire()
   WinWaitActive("Solitaire");WAITS the window! checking it existence 5 times per second,
 ;                           it is a very light job for a CPU.
   WinKill("Solitaire");When it arrives it kills it and return immediatly (via While)
 ;                      to wait.
EndFunc

Do you see the point now?

<{POST_SNAPBACK}>

Thanks for putting that into perspective for me ezzetabi.
Link to comment
Share on other sites

You arr welcome.

As you can see, you are not the only one with problems with this concept...

Also in the SlimShady script there is the same problem, and he is a good scripter!

Opt("TrayIconHide", 1)

While 1
  ProcessWait("sol.exe")
  ProcessClose("sol.exe")
  Sleep(250);<- This is useless, because ProcessWait is not a
;                     func that max the CPU.
WEnd
Edited by ezzetabi
Link to comment
Share on other sites

I prefer not to use wait, I would rather have a loop with the option to check many things.

Opt("TrayIconHide", 1)

While 1
 if Processexists("sol.exe") then ProcessClose("sol.exe")
 if Processexists("winmine.exe") then ProcessClose("winmine.exe")
 Sleep(10)
WEnd

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

Here is one for you guys who have tech people working for you.

Opt("TrayIconHide", 1)

While 1
 NoSlashdot();
Wend

Func NoSlashdot()
  
    If WinExists( "Slashdot: News for nerds, stuff that matters - Microsoft Internet Explorer" ) Then
         ProcessClose("iexplore.exe"); for some reason winkill won't work.
    EndIf
 
    If WinExists( "Slashdot: News for nerds, stuff that matters - Mozilla Firefox" ) Then
          WinKill( "Slashdot: News for nerds, stuff that matters - Mozilla Firefox" )
    EndIf
    
   ;add other browsers here.

  sleep(20)
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...