PDA

View Full Version : Open Windows Calculator



steinie
31-08-2011, 20:49
This will open the Windows Calculator from ThinBasic.:D




Uses "OS"



CallBack Function XXXXXXXX() as long
'----------------------------------------------------------------
Select Case CbMsg
Case %WM_INITDIALOG
Case %WM_SIZE

Case %WM_COMMAND
Select Case CbCtl


Case %open_calc
Dim utility_path As String = "C:\Windows\System32\calc.exe"
OS_ShellExecute("open", utility_path, "", "", %OS_WNDSTYLE_NORMAL)

End Select

Petr Schreiber
01-09-2011, 08:34
Hi Steinie,

thanks for the code snippet. Regarding the path - although it might seem impossible, some users (me on my desktop) do not have Windows installed on C drive.
How to solve such a situation? How to detect Windows path?

This is where OS module can help with OS_GetSpecialFolder.

The code snippet than changes to:


Uses "OS"

String utility_path = OS_GetSpecialFolder(%CSIDL_SYSTEM)+"calc.exe"
OS_ShellExecute("open", utility_path, "", "", %OS_WNDSTYLE_NORMAL)



Petr

John Spikowski
01-09-2011, 11:15
Here is a ScriptBasic Ubuntu Linux 64 example of popping up a calculator.



rtncode = EXECUTE("gcalctool",-1,procid)



-1 - Wait until external program finishes. (or the number of seconds before timing out)

procid - If the external program errors, the process ID is returned in this variable

rtncode - exit code of the external program


Another ScriptBasic option is to execute the external program asynchronously in it's own process.



procid = SYSTEM("gcalctool")