cppman
Active Members-
Posts
1,495 -
Joined
-
Last visited
About cppman
- Birthday 09/22/1991
Profile Information
-
Member Title
Anonymous
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
cppman's Achievements
Universalist (7/7)
2
Reputation
-
GoogleGonnaSaveUs reacted to a post in a topic: How save Array to file ?
-
coffeeturtle reacted to a post in a topic: Functions in user32.dll
-
Slow GDI+ performance on some (XP?) machines
cppman replied to UEZ's topic in AutoIt Technical Discussion
That's odd. Maybe it's something about how Windows works prior to Vista. Other than that, I have no clue. -
Slow GDI+ performance on some (XP?) machines
cppman replied to UEZ's topic in AutoIt Technical Discussion
First of all, GDI+ is not hardware accelerated, so everything is done on the CPU. I'm going to make an assumption here and say that it is slow simply because when you have the alpha channel below 255, you're "enabling" alpha blending. Since this isn't hardware accelerated, the CPU has to go through each pixel and perform an equation (on each pixel) to get the right color. Edit: try running it on a Vista+ desktop. This should also run just fine. Vista+ is based on Direct3D, so GDI+ will indirectly be hardware accelerated. Edit: just tested it on a Vista desktop and it works just fine. However, on XP or lower it is very slow - so, my theory stands. -
"Undefined" is referring to the behavior of an uninitialized pointer rather than the pointer itself. The C++ specification just doesn't define the behavior of such a situation. A compiler can do whatever it wishes in this case, including giving the pointer a default value of 0.
-
I'm not exactly sure what you mean here. Whether you initialize the pointer or not, it is still a pointer to a character. If you mean the pointer is initialized to zero, that is not true. Variables (that includes pointers) will not be initialized to any specific value - it'll take the value of what was previously in that memory address (which sometimes happens to be 0).
-
This should work, assuming it is a normal message box. ; Wait for the window to become active... $title = "Hello World"; the message title WinWaitActive($title) ControlClick($title, "OK", "[CLASS:Button;INSTANCE:1]")
-
Create new public variable from method.
cppman replied to Kip's topic in AutoIt Technical Discussion
You can't. You could, however, if C++ was an interpreted language (and it supported such a strange feature). Since C++ is not interpreted, it has to know what data-type a variable is in order to generate the proper assembly. Why do you not want to use a variant? It would have the same effect except the "switch_type<blah>()" would be implied. -
That is not entirely true, because in a way they do. When you only have one CPU, each thread is given a certain amount of time (or instructions) to execute. After that thread is done being executed, the next thread gets a turn, and so on. The only reason this works is because just before the next thread is given a chance to execute, the OS has to save the state of the current thread (most of the registers). When that thread gets a chance to execute again, the state is restored. The same is true for multiple cores (and multiple CPUs). The only difference is, you'll have multiple processors doing what I just described above (roughly). And, if you are using a multithreaded operating system (like Windows or Linux), then this is happening every single microsecond (even less) - seems like a lot of speed loss and interruption of other threads.
-
First, in your code, you need to avoid division as much as possible - it is a relatively slow operation (replace it with multiplication). Calculate any of your constants (such as $Pi / 180) before hand, and simply multiply by that. "Sqrt" is also a relatively slow function (as is Cos, Sin, etc. unless they use a lookup table) - calculate it once at the beginning, and use the result as a constant. Secondly, that "Sleep" call in your "Pythagoras" function is pointless and slows down the program by quite a bit. Thirdly, anti-aliasing is a killer operation for any program (or game). Avoid using anti-aliasing unless it is absolutely required (such as quality rendering). Also use double-buffering. Render to an off-screen surface (back-buffer), then flip the back-buffer and front-buffer. Finally, avoid using GDI for speed critical graphics applications (hence why Vista/7 uses Direct3D for rendering). Use Direct3D or OpenGL for the rendering (even if it is just the off-screen rendering), and then if you must, you can copy over the back-buffer and render it using GDI. (And then, of course, you have the inevitable speed loss from using AutoIt.)
-
Open up command prompt, and there is a useful little utility that comes with windows. a2c [insource] [outsource]
-
I'm no longer working on this - it is really old. This is a very old thread, and since it was all ready bumped, I thought I'd take this opportunity to just post the source for anyone who still wants it. Global $g_UseMSNPM = False Opt("TrayAutoPause", 0) Opt("TrayMenuMode", 1) Opt("TrayOnEventMode", 1) #include <Constants.au3> #include <GUIConstants.au3> #include <file.au3> #include <GUICombo.au3> TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "ShowWindow") TraySetClick ( 8 ) SplashTextOn("Blox Online Radio", "Please wait while the station list is being updated...") ; Place the path to the station list here... INetGet("http://blox.no-ip.org/stations.txt", @TempDir & "\stations.txt") ;;;; SplashOff() $hWnd = GUICreate("Blox Online Radio", 387, 126) $hVolumeControl = GUICtrlCreateSlider(52, 40, 81, 25, BitOR($TBS_AUTOTICKS,$TBS_NOTICKS)) $hBalanceControl = GUICtrlCreateSlider(52+81+39, 40) GUICtrlSetLimit($hBalanceControl, 100, -100) GUICtrlCreateLabel("Volume", 4, 44, 39, 17) GUICtrlCreateLabel("Balance", 52+81, 44, 39, 17) GUICtrlCreateLabel("Station: ", 4, 16, 43, 17) $hStationList = GUICtrlCreateCombo("", 52, 12, 309, 25) GUICtrlCreateGroup("Status", 4, 76, 377, 45) $hStationStatus = GUICtrlCreateLabel("Status", 12, 96, 360) $hPlayButton = GUICtrlCreateButton("Play", 264, 40, 97, 25, 0) GUISetState(@SW_SHOW) ;Populate Station List Global $avStations _FileReadToArray(@TempDir & "\stations.txt", $avStations) For $i = 1 to $avStations[0] $sztmp = StringSplit($avStations[$i], "|") _GUICtrlComboAddString($hStationList, $sztmp[1]) Next $gMediaObject = _CreateWMPlayer() GUICtrlSetData($hVolumeControl, $gMediaObject.settings.volume) $lastStatus = _GetStatus($gMediaObject) ;Create Tray menu $TrayMenu_SetMsnPM = TrayCreateItem("Enable MSN Personal Message") $TrayMenu_UpdateStations = TrayCreateItem("Update Station List") $TrayMenu_SetStation = TrayCreateItem("Set Radio Station") $TrayMenu_SetBalance = TrayCreateItem("Set Balance") $TrayMenu_SetVolume = TrayCreateItem("Set Volume") $TrayMenu_Exit = TrayCreateItem("&Exit") TrayItemSetOnEvent($TrayMenu_Exit, "Close") TrayItemSetOnEvent($TrayMenu_SetVolume, "SetVol") TrayItemSetOnEvent($TrayMenu_SetBalance, "SetBal") TrayItemSetOnEvent($TrayMenu_SetStation, "SetStation") TrayItemSetOnEvent($TrayMenu_UpdateStations, "UpdateStations") TrayItemSetOnEvent($TrayMenu_SetMsnPM, "SetPM") While 1 $nMsg = GUIGetMsg() $status = _GetStatus($gMediaObject) if ($lastStatus <> $status) Then TraySetToolTip($status) GUICtrlSetData($hStationStatus, $status) $lastStatus = $status EndIf if ($g_useMSNPM == true) Then if (StringInStr($status, "Playing")) Then ChangeMSNMessage(3, true, $status) EndIf EndIf Switch $nMsg Case $GUI_EVENT_CLOSE Close() Case $hPlayButton if (GUICtrlRead($hPlayButton) == "Play") Then if (GUICtrlRead($hStationList) == "") Then MsgBox(48, "Blox Online Radio", "You must select a radio station from the drop-down box, or select your own.") ContinueLoop EndIf $nSel = _GUICtrlComboGetCurSel($hStationList)+1 $sztmp = StringSplit($avStations[$nSel], "|") $gMediaObject.URL = $sztmp[2] GUICtrlSetData($hStationStatus, _GetStatus($gMediaObject)) GUICtrlSetData($hPlayButton, "Stop") Else ChangeMSNMessage(3, false, "") $gMediaObject.controls.stop() GUICtrlSetData($hPlayButton, "Play") EndIf Case $hVolumeControl $gMediaObject.settings.volume = GUICtrlRead($hVolumeControl) Case $hBalanceControl $gMediaObject.settings.balance = GUICtrlRead($hBalanceControl) Case $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE) EndSwitch WEnd Func _CreateWMPlayer() $Object = ObjCreate("WMPlayer.OCX.7") $Object.URL = "" return $Object EndFunc Func _GetStatus($Object) return $Object.status EndFunc Func ShowWindow() GUISetState(@SW_SHOW) EndFunc Func Close() $nRes = MsgBox(BitOr(3, 32), "Blox Online Radio", "Are you sure you would like to exit?") if ( ($nRes = 2) or ($nRes = 7) ) Then Return Else ChangeMSNMessage(3, false, "") Exit EndIf EndFunc Func SetVol() $nRes = InputBox("Blox Online Radio", "Please input a number between 0 and 100 designation the volume you would like.", "50") GUICtrlSetData($hVolumeControl, $nRes) $gMediaObject.settings.volume = int($nRes) EndFunc Func SetBal() $nRes = InputBox("Blox Online Radio", "Please input a number between -100 and 100 designation the stereo balance you would like.", "0") GUICtrlSetData($hBalanceControl, $nRes) $gMediaObject.settings.balance = int($nRes) EndFunc Func SetStation() $nRes = InputBox("Blox Online Radio", "Please type in the URL of the streaming radio station you would like to listen to.") if ($nRes == "") Then MsgBox(48, "Blox Online Radio", "You must select a radio station from the drop-down box, or select your own.") Return EndIf $gMediaObject.url = $nRes EndFunc Func UpdateStations() _GUICtrlComboResetContent($hStationList) SplashTextOn("Blox Online Radio", "Please wait while the station list is being updated...") INetGet("http://blox.no-ip.org/stations.txt", @TempDir & "\stations.txt") SplashOff() _FileReadToArray(@TempDir & "\stations.txt", $avStations) For $i = 1 to $avStations[0] $sztmp = StringSplit($avStations[$i], "|") _GUICtrlComboAddString($hStationList, $sztmp[1]) Next EndFunc ;;; ; Thanks to CoePSX ;;; Func ChangeMSNMessage($iType, $bEnable, $szText) Local Const $szFormat = "CoePSX\\0%s\\0%d\\0{0}\\0%s\\0\\0\\0\\0\\0" Local Const $WM_COPYDATA = 0x4A Local $szType Local $szMessage Local $iSize Local $pMem Local $stCopyData Local $hWindow ;; Format the message ;; Switch ($iType) Case 1 $szType = "Games" Case 2 $szType = "Office" Case Else $szType = "Music" EndSwitch $szMessage = StringFormat($szFormat, $szType, $bEnable, $szText) ;; Create a unicode string ;; $iSize = StringLen($szMessage) + 1 $pMem = DllStructCreate("ushort[" & $iSize & "]") For $i = 0 To $iSize DllStructSetData($pMem, 1, Asc(StringMid($szMessage, $i, 1)), $i) Next DllStructSetData($pMem, 1, 0, $iSize) ;; Create the COPYDATASTRUCT ;; $stCopyData = DllStructCreate("uint;uint;ptr") DllStructSetData($stCopyData, 1, 0x547) ;dwData = MSN magic number DllStructSetData($stCopyData, 2, ($iSize * 2)) ;cbData = Size of the message DllStructSetData($stCopyData, 3, DllStructGetPtr($pMem)) ;lpData = Pointer to the message ;; Send the WM_COPYDATA message ;; $hWindow = DllCall("user32", "hwnd", "FindWindowExA", "int", 0, "int", 0, "str", "MsnMsgrUIManager", "int", 0) While ($hWindow[0]) DllCall("user32", "int", "SendMessageA", "hwnd", $hWindow[0], "int", $WM_COPYDATA, "int", 0, "ptr", DllStructGetPtr($stCopyData)) $hWindow = DllCall("user32", "hwnd", "FindWindowExA", "int", 0, "hwnd", $hWindow[0], "str", "MsnMsgrUIManager", "int", 0) WEnd ;; Cleanup ;; $pMem = 0 $stCopyData = 0 EndFunc ;==>ChangeMSNMessage Func SetPM() $text = TrayItemGetText($TrayMenu_SetMsnPm) if ($text = "Enable MSN Personal Message") Then TrayItemSetText($TrayMenu_SetMsnPm, "Disable MSN Pesonal Message") $g_UseMSNPM = True Else TrayItemSetText($TrayMenu_SetMsnPm, "Enable MSN Personal Message") ChangeMSNMessage(3, false, "") $g_UseMSNPM = False EndIf EndFunc
-
run, runwait, etc. - suggestion on hwnd
cppman replied to joseLB's topic in AutoIt Technical Discussion
Ah... I forgot about that. -
run, runwait, etc. - suggestion on hwnd
cppman replied to joseLB's topic in AutoIt Technical Discussion
I'm not really sure how practical this is (or even how "workable" it is). You can setup a windows shell hook. In your hook procedure, check for "HSHELL_WINDOWCREATED", then call GetWindowThreadProcessId to check if the Process ID of the window is the same as the process ID returned by Run. There was a callback UDF floating around the forum a while ago - it may come in handy if you use this method. http://msdn.microsoft.com/en-us/library/ms644990.aspx - SetWindowsHookEx http://msdn.microsoft.com/en-us/library/ms644991(VS.85).aspx - ShellProc http://msdn.microsoft.com/en-us/library/ms633522(VS.85).aspx - GetWindowThreadProcessId -
For now, you could just use your own. Func IsDigit($char) Local $nVal = Asc($char) return ( ($nVal >= 48) and ($nVal <= 57) ) EndFunc
-
I don't believe superscripts should be considered a digit (and hence why the superscript doesn't show up as a hexadecimal digit). A digit should only be considered to be the numbers 0-9 (as the c-standard library specifies).
-
Right after you accept the client, you can just use TCPSend to send information to that client. While 1 $ConnectedSocket[$CurrentSocket] = TCPAccept($ListenSocket) If $ConnectedSocket[$CurrentSocket] <> -1 Then $CurrentSocket = $CurrentSocket + 1 EndIf ; -------- ADD WHATEVER YOU WANT TO SEND HERE TCPSend($ConnectedSocket[$CurrentSocket], FileRead("welcome.txt")) ; ------------------------------------------------- For $INDEX = 0 To 15 If $ConnectedSocket[$INDEX] <> -1 Or $ConnectedSocket[$INDEX] <> "" Then $Recv = TCPRecv($ConnectedSocket[$INDEX],1024) If $Recv <> "" Then MsgBox(0,"CON#" & $INDEX,$Recv) EndIf EndIf Next Sleep(20) WEnd