Sunday, December 27, 2015

MsgBoxTimeOut function module

'//MsgBoxTimeOut module
'//Author          : s0ft
'//Contact         :
'//Blog            :
'//Usage Example   : MsgBoxTimeOut "Sample msgbox content",vbOkOnly,"Title",5000,500 'timeout of 5 seconds with initial delay of 0.5 seconds
'//Compile type    : P-Code. A lot of problems with CreateThread API in Native mode
'//Date/Time       : 2015/12/27 - 10:12 PM

Option Explicit

Private Declare Function CreateThread Lib "kernel32.dll" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, ByRef lpParameter As Any, ByVal dwCreationFlags As Long, ByRef lpThreadId As Long) As Long
Private Declare Function MessageBox Lib "user32" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function TerminateThread Lib "kernel32.dll" (ByVal hThread As Long, ByVal dwExitCode As Long) As Long

Dim strContent_ As String
Dim boxType_ As Long
Dim strTitle_ As String
Dim TimeOut_ As Long
Dim initialDelay_ As Long

Public Sub MsgBoxTimeOut(ByVal strContent As String, ByVal boxType As Long, ByVal strTitle As String, ByVal TimeOut As Long, ByVal initialDelay As Long)
strContent_ = strContent
boxType_ = boxType
strTitle_ = strTitle
TimeOut_ = TimeOut
initialDelay_ = initialDelay
Dim threadID As Long
CreateThread ByVal 0&, ByVal 0&, AddressOf step1, ByVal 0&, ByVal 0&, threadID
End Sub

Private Sub step1()
Dim threadID As Long
Dim hThread As Long
Sleep initialDelay_ '//the initial delay must be here, not inside the msgbox thread. that would be silly
hThread = CreateThread(ByVal 0&, ByVal 0&, AddressOf step2, ByVal 0&, ByVal 0&, threadID)
Sleep TimeOut_
TerminateThread hThread, 0
End Sub

Private Sub step2()
MessageBox 0, strContent_, strTitle_, boxType_
End Sub

Saturday, November 28, 2015

PokemonShowdown Helper

I'm back. It's been a long time, over a year. Lot of things have happened, lot have changed in RL. But a blog has to go on.
Today, browsing through my desktop HD, I found this project that I remember I had undertaken some months back, maybe a month after the quake, so that's May. I sometimes liked to play pokemonshowdown, still do. It was fun, very fun, until it wasn't. I used to be so interested for a while and when I had got enough, I used to stop. And this, I created when I was head over heels into it. Some point down the road, I lost interest and left it. And today, there it was, lying there on my desktop. I tested to see how well and if it worked. And it did, exactly as I remember it had.
About what it is all about, it parses through your ongoing battle and displays information that may be useful to you as a player, in real time(obviously). The pokemons involved, their attacks and their speeds are what are shown. Pressing the F9 key toggles display of some basic info regarding the currently active pokemons(their base stats) loaded from a txt file. F8 toggles the main window.
Optionally, it allows the pokemons and their attacks encountered in battles to be recorded or "learn"t in a file. This I probably added to make the recorded data more usable to players in future versions. Currently, this "knowledge vault" file serves no purpose within the program.
Oh, one thing, it only works with internet explorer.

Anyway, here it is.