Last active
May 7, 2017 07:44
-
-
Save mtask/7ee674a88a5a6108e33254ebaf6c0ea1 to your computer and use it in GitHub Desktop.
Python Ctypes Windows examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import * | |
# https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx | |
###################### | |
# Yes/No msg box | |
##################### | |
a = windll.user32.MessageBoxW(0, "Hello\n", "The Title\n",4) | |
print("Return code: "+str(a)) | |
if a == 6: | |
print("Yes was clicked") | |
elif a == 7: | |
print("No was clicked") | |
############## | |
# Info msg box witt ok button and info icon | |
############## | |
# Check link above for explanation to 0x40 | |
windll.user32.MessageBoxW(0,"info icon message\n","info title\n",0 | 0x40) | |
######### | |
# printf | |
######### | |
msvcrt = CDLL('msvcrt') | |
message_string = b"Printing with printf function\n" | |
msvcrt.printf(b"Testing: %s\n", message_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment